nvim 0.12 wip
This commit is contained in:
@@ -1,25 +1,5 @@
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
local opts = {
|
||||
install = { colorscheme = { "catppuccin" } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true },
|
||||
}
|
||||
|
||||
require("vim-options")
|
||||
require("lazy").setup("plugins", opts)
|
||||
require("config")
|
||||
require("plugins")
|
||||
|
||||
15
.config/nvim/lsp/lua_ls.lua
Normal file
15
.config/nvim/lsp/lua_ls.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
return {
|
||||
cmd = { "lua-language-server" },
|
||||
filetypes = { "lua" },
|
||||
root_markers = {
|
||||
".luarc.json", ".luarc.jsonc", ".luacheckrc",
|
||||
".stylua.toml", "stylua.toml", "selene.toml",
|
||||
"selene.yml", ".git"
|
||||
},
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = { version = "LuaJIT" }, -- Neovim uses LuaJIT
|
||||
diagnostics = { globals = { "vim" } }, -- Recognize 'vim' global
|
||||
},
|
||||
},
|
||||
}
|
||||
143
.config/nvim/lua/config/autocmds.lua
Normal file
143
.config/nvim/lua/config/autocmds.lua
Normal file
@@ -0,0 +1,143 @@
|
||||
local function augroup(name)
|
||||
return vim.api.nvim_create_augroup("user_" .. name, { clear = true })
|
||||
end
|
||||
|
||||
-- Check if we need to reload the file when it changed
|
||||
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, {
|
||||
group = augroup("checktime"),
|
||||
callback = function()
|
||||
if vim.o.buftype ~= "nofile" then
|
||||
vim.cmd("checktime")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Highlight on yank
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
group = augroup("highlight_yank"),
|
||||
callback = function()
|
||||
(vim.hl or vim.highlight).on_yank()
|
||||
end,
|
||||
})
|
||||
|
||||
-- resize splits if window got resized
|
||||
vim.api.nvim_create_autocmd({ "VimResized" }, {
|
||||
group = augroup("resize_splits"),
|
||||
callback = function()
|
||||
local current_tab = vim.fn.tabpagenr()
|
||||
vim.cmd("tabdo wincmd =")
|
||||
vim.cmd("tabnext " .. current_tab)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- make it easier to close man-files when opened inline
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = augroup("man_unlisted"),
|
||||
pattern = { "man" },
|
||||
callback = function(event)
|
||||
vim.bo[event.buf].buflisted = false
|
||||
end,
|
||||
})
|
||||
|
||||
-- close some filetypes with <q>
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = augroup("close_with_q"),
|
||||
pattern = {
|
||||
"PlenaryTestPopup",
|
||||
"checkhealth",
|
||||
"dbout",
|
||||
"gitsigns-blame",
|
||||
"grug-far",
|
||||
"help",
|
||||
"lspinfo",
|
||||
"neotest-output",
|
||||
"neotest-output-panel",
|
||||
"neotest-summary",
|
||||
"notify",
|
||||
"qf",
|
||||
"spectre_panel",
|
||||
"startuptime",
|
||||
"tsplayground",
|
||||
},
|
||||
callback = function(event)
|
||||
vim.bo[event.buf].buflisted = false
|
||||
vim.schedule(function()
|
||||
vim.keymap.set("n", "q", function()
|
||||
vim.cmd("close")
|
||||
pcall(vim.api.nvim_buf_delete, event.buf, { force = true })
|
||||
end, {
|
||||
buffer = event.buf,
|
||||
silent = true,
|
||||
desc = "Quit buffer",
|
||||
})
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
-- wrap and check for spell in text filetypes
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = augroup("wrap_spell"),
|
||||
pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" },
|
||||
callback = function()
|
||||
vim.opt_local.wrap = true
|
||||
vim.opt_local.spell = true
|
||||
end,
|
||||
})
|
||||
|
||||
-- Fix conceallevel for json files
|
||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
group = augroup("json_conceal"),
|
||||
pattern = { "json", "jsonc", "json5" },
|
||||
callback = function()
|
||||
vim.opt_local.conceallevel = 0
|
||||
end,
|
||||
})
|
||||
|
||||
-- Auto create dir when saving a file, in case some intermediate directory does not exist
|
||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
group = augroup("auto_create_dir"),
|
||||
callback = function(event)
|
||||
if event.match:match("^%w%w+:[/][/]") then
|
||||
return
|
||||
end
|
||||
local file = vim.uv.fs_realpath(event.match) or event.match
|
||||
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Set filetype for .env and .env.* files
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
||||
group = augroup("env_filetype"),
|
||||
pattern = { "*.env", ".env.*" },
|
||||
callback = function()
|
||||
vim.opt_local.filetype = "sh"
|
||||
end,
|
||||
})
|
||||
|
||||
-- Set filetype for .toml files
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
||||
group = augroup("toml_filetype"),
|
||||
pattern = { "*.tomg-config*" },
|
||||
callback = function()
|
||||
vim.opt_local.filetype = "toml"
|
||||
end,
|
||||
})
|
||||
|
||||
-- Set filetype for .ejs files
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
||||
group = augroup("ejs_filetype"),
|
||||
pattern = { "*.ejs", "*.ejs.t" },
|
||||
callback = function()
|
||||
vim.opt_local.filetype = "embedded_template"
|
||||
end,
|
||||
})
|
||||
|
||||
-- Set filetype for .code-snippets files
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
|
||||
group = augroup("code_snippets_filetype"),
|
||||
pattern = { "*.code-snippets" },
|
||||
callback = function()
|
||||
vim.opt_local.filetype = "json"
|
||||
end,
|
||||
})
|
||||
72
.config/nvim/lua/config/diagnostics.lua
Normal file
72
.config/nvim/lua/config/diagnostics.lua
Normal file
@@ -0,0 +1,72 @@
|
||||
--- diagnostic settings
|
||||
local map = vim.keymap.set
|
||||
|
||||
local palette = {
|
||||
err = "#51202A",
|
||||
warn = "#3B3B1B",
|
||||
info = "#1F3342",
|
||||
hint = "#1E2E1E",
|
||||
}
|
||||
|
||||
vim.api.nvim_set_hl(0, "DiagnosticErrorLine", { bg = palette.err, blend = 20 })
|
||||
vim.api.nvim_set_hl(0, "DiagnosticWarnLine", { bg = palette.warn, blend = 15 })
|
||||
vim.api.nvim_set_hl(0, "DiagnosticInfoLine", { bg = palette.info, blend = 10 })
|
||||
vim.api.nvim_set_hl(0, "DiagnosticHintLine", { bg = palette.hint, blend = 10 })
|
||||
|
||||
vim.api.nvim_set_hl(0, "DapBreakpointSign", { fg = "#FF0000", bg = nil, bold = true })
|
||||
vim.fn.sign_define("DapBreakpoint", {
|
||||
text = "●", -- a large dot; change as desired
|
||||
texthl = "DapBreakpointSign", -- the highlight group you just defined
|
||||
linehl = "", -- no full-line highlight
|
||||
numhl = "", -- no number-column highlight
|
||||
})
|
||||
|
||||
local sev = vim.diagnostic.severity
|
||||
|
||||
vim.diagnostic.config({
|
||||
-- keep underline & severity_sort on for quick scanning
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
update_in_insert = false, -- less flicker
|
||||
float = {
|
||||
border = "rounded",
|
||||
source = true,
|
||||
},
|
||||
-- keep signs & virtual text, but tune them as you like
|
||||
signs = {
|
||||
text = {
|
||||
[sev.ERROR] = " ",
|
||||
[sev.WARN] = " ",
|
||||
[sev.INFO] = " ",
|
||||
[sev.HINT] = " ",
|
||||
},
|
||||
},
|
||||
virtual_text = {
|
||||
spacing = 4,
|
||||
source = "if_many",
|
||||
prefix = "●",
|
||||
},
|
||||
-- NEW in 0.11 — dim whole line
|
||||
linehl = {
|
||||
[sev.ERROR] = "DiagnosticErrorLine",
|
||||
[sev.WARN] = "DiagnosticWarnLine",
|
||||
[sev.INFO] = "DiagnosticInfoLine",
|
||||
[sev.HINT] = "DiagnosticHintLine",
|
||||
},
|
||||
})
|
||||
|
||||
-- diagnostic keymaps
|
||||
local diagnostic_goto = function(next, severity)
|
||||
severity = severity and vim.diagnostic.severity[severity] or nil
|
||||
return function()
|
||||
vim.diagnostic.jump({ count = next and 1 or -1, float = true, severity = severity })
|
||||
end
|
||||
end
|
||||
|
||||
map("n", "<leader>cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" })
|
||||
map("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" })
|
||||
map("n", "[d", diagnostic_goto(false), { desc = "Prev Diagnostic" })
|
||||
map("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "Next Error" })
|
||||
map("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "Prev Error" })
|
||||
map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" })
|
||||
map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" })
|
||||
5
.config/nvim/lua/config/init.lua
Normal file
5
.config/nvim/lua/config/init.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
require("config.options")
|
||||
require("config.keymaps")
|
||||
require("config.diagnostics")
|
||||
require("config.autocmds")
|
||||
require("config.lsp")
|
||||
222
.config/nvim/lua/config/keymaps.lua
Normal file
222
.config/nvim/lua/config/keymaps.lua
Normal file
@@ -0,0 +1,222 @@
|
||||
local map = vim.keymap.set
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- BUFFER NAVIGATION (think browser tabs)
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Tab/Shift-Tab: Like browser tabs, feels natural
|
||||
map("n", "<Tab>", ":bnext<CR>", { desc = "Next buffer" })
|
||||
map("n", "<S-Tab>", ":bprevious<CR>", { desc = "Previous buffer" })
|
||||
|
||||
-- Alternative buffer switching (vim-style)
|
||||
map("n", "<leader>bn", ":bnext<CR>", { desc = "Next buffer" })
|
||||
map("n", "<leader>bp", ":bprevious<CR>", { desc = "Previous buffer" })
|
||||
map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev Buffer" })
|
||||
map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next Buffer" })
|
||||
map("n", "[b", "<cmd>bprevious<cr>", { desc = "Prev Buffer" })
|
||||
map("n", "]b", "<cmd>bnext<cr>", { desc = "Next Buffer" })
|
||||
|
||||
-- Quick switch to last edited file (super useful!)
|
||||
map("n", "<leader>bb", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" })
|
||||
map("n", "<leader>`", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" })
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- WINDOW MANAGEMENT (splitting and navigation)
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Move between windows with Ctrl+hjkl (like tmux)
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "Go to Left Window", remap = true })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "Go to Lower Window", remap = true })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "Go to Upper Window", remap = true })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "Go to Right Window", remap = true })
|
||||
|
||||
-- Resize windows with Ctrl+Shift+arrows (macOS friendly)
|
||||
map("n", "<C-S-Up>", "<cmd>resize +5<CR>", opts)
|
||||
map("n", "<C-S-Down>", "<cmd>resize -5<CR>", opts)
|
||||
map("n", "<C-S-Left>", "<cmd>vertical resize -5<CR>", opts)
|
||||
map("n", "<C-S-Right>", "<cmd>vertical resize +5<CR>", opts)
|
||||
|
||||
-- Window splitting
|
||||
map("n", "<leader>ww", "<C-W>p", { desc = "Other Window", remap = true })
|
||||
map("n", "<leader>wd", "<C-W>c", { desc = "Delete Window", remap = true })
|
||||
map("n", "<leader>w-", "<C-W>s", { desc = "Split Window Below", remap = true })
|
||||
map("n", "<leader>sh", "<C-W>s", { desc = "Split Window Below", remap = true })
|
||||
map("n", "<leader>w|", "<C-W>v", { desc = "Split Window Right", remap = true })
|
||||
map("n", "<leader>|", "<C-W>v", { desc = "Split Window Right", remap = true })
|
||||
map("n", "<leader>sv", "<C-W>v", { desc = "Split Window Right", remap = true })
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- SMART LINE MOVEMENT (the VSCode experience)
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Smart j/k: moves by visual lines when no count, real lines with count
|
||||
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true })
|
||||
map({ "n", "x" }, "<Down>", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true })
|
||||
map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { desc = "Up", expr = true, silent = true })
|
||||
map({ "n", "x" }, "<Up>", "v:count == 0 ? 'gk' : 'k'", { desc = "Up", expr = true, silent = true })
|
||||
|
||||
-- Move lines up/down (Alt+j/k like VSCode)
|
||||
map("n", "<A-j>", "<cmd>execute 'move .+' . v:count1<cr>==", { desc = "Move Down" })
|
||||
map("n", "<A-k>", "<cmd>execute 'move .-' . (v:count1 + 1)<cr>==", { desc = "Move Up" })
|
||||
map("i", "<A-j>", "<esc><cmd>m .+1<cr>==gi", { desc = "Move Down" })
|
||||
map("i", "<A-k>", "<esc><cmd>m .-2<cr>==gi", { desc = "Move Up" })
|
||||
map("v", "<A-j>", ":<C-u>execute \"'<,'>move '>+\" . v:count1<cr>gv=gv", { desc = "Move Down" })
|
||||
map("v", "<A-k>", ":<C-u>execute \"'<,'>move '<-\" . (v:count1 + 1)<cr>gv=gv", { desc = "Move Up" })
|
||||
|
||||
-- Alternative line movement (for terminals that don't support Alt)
|
||||
map("v", "J", ":move '>+1<CR>gv=gv", { desc = "Move Block Down" })
|
||||
map("v", "K", ":move '<-2<CR>gv=gv", { desc = "Move Block Up" })
|
||||
map("n", "<A-Down>", ":m .+1<CR>", opts)
|
||||
map("n", "<A-Up>", ":m .-2<CR>", opts)
|
||||
map("i", "<A-Down>", "<Esc>:m .+1<CR>==gi", opts)
|
||||
map("i", "<A-Up>", "<Esc>:m .-2<CR>==gi", opts)
|
||||
map("v", "<A-Down>", ":m '>+1<CR>gv=gv", opts)
|
||||
map("v", "<A-Up>", ":m '<-2<CR>gv=gv", opts)
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- SEARCH & NAVIGATION (ergonomic improvements)
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Better line start/end (more comfortable than $ and ^)
|
||||
map("n", "gl", "$", { desc = "Go to end of line" })
|
||||
map("n", "gh", "^", { desc = "Go to start of line" })
|
||||
map("n", "<A-h>", "^", { desc = "Go to start of line", silent = true })
|
||||
map("n", "<A-l>", "$", { desc = "Go to end of line", silent = true })
|
||||
|
||||
-- Select all content
|
||||
map("n", "==", "gg<S-v>G")
|
||||
map("n", "<A-a>", "ggVG", { noremap = true, silent = true, desc = "Select all" })
|
||||
|
||||
-- Clear search highlighting
|
||||
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and Clear hlsearch" })
|
||||
map("n", "<leader>ur", "<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>", { desc = "Redraw / Clear hlsearch / Diff Update" })
|
||||
|
||||
-- Smart search navigation (n always goes forward, N always backward)
|
||||
map("n", "n", "'Nn'[v:searchforward].'zv'", { expr = true, desc = "Next Search Result" })
|
||||
map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next Search Result" })
|
||||
map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next Search Result" })
|
||||
map("n", "N", "'nN'[v:searchforward].'zv'", { expr = true, desc = "Prev Search Result" })
|
||||
map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev Search Result" })
|
||||
map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev Search Result" })
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- SMART TEXT EDITING
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Better indenting (stay in visual mode)
|
||||
map("v", "<", "<gv")
|
||||
map("v", ">", ">gv")
|
||||
|
||||
-- Better paste (doesn't replace clipboard with deleted text)
|
||||
map("v", "p", '"_dP', opts)
|
||||
|
||||
-- Copy whole file to clipboard
|
||||
map("n", "<C-c>", ":%y+<CR>", opts)
|
||||
|
||||
-- Smart undo break-points (create undo points at logical stops)
|
||||
map("i", ",", ",<c-g>u")
|
||||
map("i", ".", ".<c-g>u")
|
||||
map("i", ";", ";<c-g>u")
|
||||
|
||||
-- Auto-close pairs (simple, no plugin needed)
|
||||
map("i", "`", "``<left>")
|
||||
map("i", '"', '""<left>')
|
||||
map("i", "(", "()<left>")
|
||||
map("i", "[", "[]<left>")
|
||||
map("i", "{", "{}<left>")
|
||||
map("i", "<", "<><left>")
|
||||
-- Note: Single quotes commented out to avoid conflicts in some contexts
|
||||
-- map("i", "'", "''<left>")
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- FILE OPERATIONS
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Save file (works in all modes)
|
||||
map({ "i", "x", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save File" })
|
||||
|
||||
-- Create new file
|
||||
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
|
||||
|
||||
-- Quit operations
|
||||
map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit All" })
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- DEVELOPMENT TOOLS
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Commenting (add comment above/below current line)
|
||||
map("n", "gco", "o<esc>Vcx<esc><cmd>normal gcc<cr>fxa<bs>", { desc = "Add Comment Below" })
|
||||
map("n", "gcO", "O<esc>Vcx<esc><cmd>normal gcc<cr>fxa<bs>", { desc = "Add Comment Above" })
|
||||
|
||||
-- Quickfix and location lists
|
||||
map("n", "<leader>xl", function()
|
||||
local success, err = pcall(vim.fn.getloclist(0, { winid = 0 }).winid ~= 0 and vim.cmd.lclose or vim.cmd.lopen)
|
||||
if not success and err then
|
||||
vim.notify(err, vim.log.levels.ERROR)
|
||||
end
|
||||
end, { desc = "Location List" })
|
||||
|
||||
map("n", "<leader>xq", function()
|
||||
local success, err = pcall(vim.fn.getqflist({ winid = 0 }).winid ~= 0 and vim.cmd.cclose or vim.cmd.copen)
|
||||
if not success and err then
|
||||
vim.notify(err, vim.log.levels.ERROR)
|
||||
end
|
||||
end, { desc = "Quickfix List" })
|
||||
|
||||
map("n", "[q", vim.cmd.cprev, { desc = "Previous Quickfix" })
|
||||
map("n", "]q", vim.cmd.cnext, { desc = "Next Quickfix" })
|
||||
|
||||
-- Inspection tools (useful for debugging highlights and treesitter)
|
||||
map("n", "<leader>ui", vim.show_pos, { desc = "Inspect Pos" })
|
||||
map("n", "<leader>uI", "<cmd>InspectTree<cr>", { desc = "Inspect Tree" })
|
||||
|
||||
-- Keyword program (K for help on word under cursor)
|
||||
map("n", "<leader>K", "<cmd>norm! K<cr>", { desc = "Keywordprg" })
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- TERMINAL INTEGRATION
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Terminal mode navigation
|
||||
map("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })
|
||||
map("t", "<C-h>", "<cmd>wincmd h<cr>", { desc = "Go to Left Window" })
|
||||
map("t", "<C-j>", "<cmd>wincmd j<cr>", { desc = "Go to Lower Window" })
|
||||
map("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to Upper Window" })
|
||||
map("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to Right Window" })
|
||||
map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
|
||||
map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- TAB MANAGEMENT (when you need multiple workspaces)
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
map("n", "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last Tab" })
|
||||
map("n", "<leader><tab>o", "<cmd>tabonly<cr>", { desc = "Close Other Tabs" })
|
||||
map("n", "<leader><tab>f", "<cmd>tabfirst<cr>", { desc = "First Tab" })
|
||||
map("n", "<leader><tab><tab>", "<cmd>tabnew<cr>", { desc = "New Tab" })
|
||||
map("n", "<leader><tab>]", "<cmd>tabnext<cr>", { desc = "Next Tab" })
|
||||
map("n", "<leader><tab>d", "<cmd>tabclose<cr>", { desc = "Close Tab" })
|
||||
map("n", "<leader><tab>[", "<cmd>tabprevious<cr>", { desc = "Previous Tab" })
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- FOLDING NAVIGATION (for code organization)
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Close all folds except current one (great for focus)
|
||||
map("n", "zv", "zMzvzz", { desc = "Close all folds except the current one" })
|
||||
|
||||
-- Smart fold navigation (closes current, opens next/previous)
|
||||
map("n", "zj", "zcjzOzz", { desc = "Close current fold when open. Always open next fold." })
|
||||
map("n", "zk", "zckzOzz", { desc = "Close current fold when open. Always open previous fold." })
|
||||
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
-- UTILITY SHORTCUTS
|
||||
-- ═══════════════════════════════════════════════════════════
|
||||
|
||||
-- Toggle line wrapping
|
||||
map("n", "<leader>tw", "<cmd>set wrap!<CR>", { desc = "Toggle Wrap", silent = true })
|
||||
|
||||
-- Fix spelling (picks first suggestion)
|
||||
map("n", "z0", "1z=", { desc = "Fix word under cursor" })
|
||||
62
.config/nvim/lua/config/lsp.lua
Normal file
62
.config/nvim/lua/config/lsp.lua
Normal file
@@ -0,0 +1,62 @@
|
||||
-- LSP
|
||||
local function augroup(name)
|
||||
return vim.api.nvim_create_augroup("user_" .. name, { clear = true })
|
||||
end
|
||||
|
||||
local default_keymaps = {
|
||||
{ keys = "<leader>ca", func = vim.lsp.buf.code_action, desc = "Code Actions" },
|
||||
{ keys = "<leader>cr", func = vim.lsp.buf.rename, desc = "Code Rename" },
|
||||
{ keys = "<leader>k", func = vim.lsp.buf.hover, desc = "Hover Documentation", has = "hoverProvider" },
|
||||
{ keys = "K", func = vim.lsp.buf.hover, desc = "Hover (alt)", has = "hoverProvider" },
|
||||
{ keys = "gd", func = vim.lsp.buf.definition, desc = "Goto Definition", has = "definitionProvider" },
|
||||
}
|
||||
|
||||
-- I use blink.cmp for completion, but you can use native completion too
|
||||
local completion = vim.g.completion_mode or "blink" -- or 'native' for built-in completion
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = augroup("lsp_attach"),
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
local buf = args.buf
|
||||
if client then
|
||||
-- Built-in completion
|
||||
if completion == "native" and client:supports_method("textDocument/completion") then
|
||||
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
|
||||
end
|
||||
|
||||
-- Inlay hints
|
||||
if client:supports_method("textDocument/inlayHints") then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = args.buf })
|
||||
end
|
||||
|
||||
if client:supports_method("textDocument/documentColor") then
|
||||
vim.lsp.document_color.enable(true, args.buf, {
|
||||
style = "background", -- 'background', 'foreground', or 'virtual'
|
||||
})
|
||||
end
|
||||
|
||||
for _, km in ipairs(default_keymaps) do
|
||||
-- Only bind if there's no `has` requirement, or the server supports it
|
||||
if not km.has or client.server_capabilities[km.has] then
|
||||
vim.keymap.set(
|
||||
km.mode or "n",
|
||||
km.keys,
|
||||
km.func,
|
||||
{ buffer = buf, desc = "LSP: " .. km.desc, nowait = km.nowait }
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Enable LSP servers for Neovim 0.11+
|
||||
vim.lsp.enable({
|
||||
"lua_ls",
|
||||
})
|
||||
|
||||
-- Load Lsp on-demand, e.g: eslint is disable by default
|
||||
-- e.g: We could enable eslint by set vim.g.lsp_on_demands = {"eslint"}
|
||||
if vim.g.lsp_on_demands then
|
||||
vim.lsp.enable(vim.g.lsp_on_demands)
|
||||
end
|
||||
137
.config/nvim/lua/config/options.lua
Normal file
137
.config/nvim/lua/config/options.lua
Normal file
@@ -0,0 +1,137 @@
|
||||
local opt = vim.opt
|
||||
|
||||
opt.number = true -- Line numbers
|
||||
opt.relativenumber = true -- Relative line numbers
|
||||
opt.cursorline = true -- Highlight current line
|
||||
opt.wrap = false -- Don't wrap lines
|
||||
opt.scrolloff = 10 -- Keep 10 lines above/below cursor
|
||||
opt.sidescrolloff = 8 -- Keep 8 columns left/right of cursor
|
||||
|
||||
-- Indentation
|
||||
opt.tabstop = 2 -- Tab width
|
||||
opt.shiftwidth = 2 -- Indent width
|
||||
opt.softtabstop = 2 -- Soft tab stop
|
||||
opt.expandtab = true -- Use spaces instead of tabs
|
||||
opt.smartindent = true -- Smart auto-indenting
|
||||
opt.autoindent = true -- Copy indent from current line
|
||||
|
||||
-- Search settings
|
||||
opt.ignorecase = true -- Case insensitive search
|
||||
opt.smartcase = true -- Case sensitive if uppercase in search
|
||||
opt.hlsearch = false -- Don't highlight search results
|
||||
opt.incsearch = true -- Show matches as you type
|
||||
|
||||
-- Visual settings
|
||||
opt.termguicolors = true -- Enable 24-bit colors
|
||||
opt.signcolumn = "yes" -- Always show sign column
|
||||
opt.showmatch = true -- Highlight matching brackets
|
||||
opt.matchtime = 2 -- How long to show matching bracket
|
||||
opt.cmdheight = 1 -- Command line height
|
||||
opt.showmode = false -- Don't show mode in command line
|
||||
opt.pumheight = 10 -- Popup menu height
|
||||
opt.pumblend = 10 -- Popup menu transparency
|
||||
opt.winblend = 0 -- Floating window transparency
|
||||
opt.completeopt = "menu,menuone,noselect"
|
||||
opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions
|
||||
opt.confirm = true -- Confirm to save changes before exiting modified buffer
|
||||
opt.concealcursor = "" -- Don't hide cursor line markup
|
||||
opt.synmaxcol = 300 -- Syntax highlighting limit
|
||||
opt.ruler = false -- Disable the default ruler
|
||||
opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode
|
||||
opt.winminwidth = 5 -- Minimum window width
|
||||
|
||||
-- File handling
|
||||
opt.backup = false -- Don't create backup files
|
||||
opt.writebackup = false -- Don't create backup before writing
|
||||
opt.swapfile = false -- Don't create swap files
|
||||
opt.undofile = true -- Persistent undo
|
||||
opt.undolevels = 10000
|
||||
opt.undodir = vim.fn.expand("~/.vim/undodir") -- Undo directory
|
||||
opt.updatetime = 300 -- Faster completion
|
||||
opt.timeoutlen = vim.g.vscode and 1000 or 300 -- Lower than default (1000) to quickly trigger which-key
|
||||
opt.ttimeoutlen = 0 -- Key code timeout
|
||||
opt.autoread = true -- Auto reload files changed outside vim
|
||||
opt.autowrite = true -- Auto save
|
||||
|
||||
-- Behavior settings
|
||||
opt.hidden = true -- Allow hidden buffers
|
||||
opt.errorbells = false -- No error bells
|
||||
opt.backspace = "indent,eol,start" -- Better backspace behavior
|
||||
opt.autochdir = false -- Don't auto change directory
|
||||
opt.iskeyword:append("-") -- Treat dash as part of word
|
||||
opt.path:append("**") -- include subdirectories in search
|
||||
opt.selection = "exclusive" -- Selection behavior
|
||||
opt.mouse = "a" -- Enable mouse support
|
||||
opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard
|
||||
opt.modifiable = true -- Allow buffer modifications
|
||||
opt.encoding = "UTF-8" -- Set encoding
|
||||
|
||||
-- Folding settings
|
||||
opt.smoothscroll = true
|
||||
vim.wo.foldmethod = "expr"
|
||||
opt.foldlevel = 99 -- Start with all folds open
|
||||
opt.formatoptions = "jcroqlnt" -- tcqj
|
||||
opt.grepformat = "%f:%l:%c:%m"
|
||||
opt.grepprg = "rg --vimgrep"
|
||||
|
||||
-- Split behavior
|
||||
opt.splitbelow = true -- Horizontal splits go below
|
||||
opt.splitright = true -- Vertical splits go right
|
||||
opt.splitkeep = "screen"
|
||||
|
||||
-- Command-line completion
|
||||
opt.wildmenu = true
|
||||
opt.wildmode = "longest:full,full"
|
||||
opt.wildignore:append({ "*.o", "*.obj", "*.pyc", "*.class", "*.jar" })
|
||||
|
||||
-- Better diff options
|
||||
opt.diffopt:append("linematch:60")
|
||||
|
||||
-- Performance improvements
|
||||
opt.redrawtime = 10000
|
||||
opt.maxmempattern = 20000
|
||||
|
||||
-- Create undo directory if it doesn't exist
|
||||
local undodir = vim.fn.expand("~/.vim/undodir")
|
||||
if vim.fn.isdirectory(undodir) == 0 then
|
||||
vim.fn.mkdir(undodir, "p")
|
||||
end
|
||||
|
||||
vim.g.autoformat = true
|
||||
vim.g.trouble_lualine = true
|
||||
|
||||
--[[
|
||||
opt.fillchars = {
|
||||
foldopen = "",
|
||||
foldclose = "",
|
||||
fold = " ",
|
||||
foldsep = " ",
|
||||
diff = "╱",
|
||||
eob = " ",
|
||||
}
|
||||
]]
|
||||
|
||||
opt.jumpoptions = "view"
|
||||
opt.laststatus = 3 -- global statusline
|
||||
opt.list = false
|
||||
opt.linebreak = true -- Wrap lines at convenient points
|
||||
opt.list = true -- Show some invisible characters (tabs...
|
||||
opt.shiftround = true -- Round indent
|
||||
opt.shiftwidth = 2 -- Size of an indent
|
||||
opt.shortmess:append({ W = true, I = true, c = true, C = true })
|
||||
|
||||
vim.g.markdown_recommended_style = 0
|
||||
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
env = "dotenv",
|
||||
},
|
||||
filename = {
|
||||
[".env"] = "dotenv",
|
||||
["env"] = "dotenv",
|
||||
},
|
||||
pattern = {
|
||||
["[jt]sconfig.*.json"] = "jsonc",
|
||||
["%.env%.[%w_.-]+"] = "dotenv",
|
||||
},
|
||||
})
|
||||
@@ -1,17 +0,0 @@
|
||||
return {
|
||||
"catppuccin/nvim",
|
||||
name = "catppuccin",
|
||||
priority = 1000,
|
||||
config = function()
|
||||
local config = require("catppuccin")
|
||||
config.setup({
|
||||
auto_integrations = true,
|
||||
flavour = "mocha",
|
||||
background = {
|
||||
light = "mocha",
|
||||
dark = "mocha",
|
||||
},
|
||||
})
|
||||
vim.cmd.colorscheme "catppuccin-mocha"
|
||||
end
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
return {
|
||||
-- {
|
||||
-- 'milanglacier/minuet-ai.nvim',
|
||||
-- dependencies = {
|
||||
-- 'nvim-lua/plenary.nvim',
|
||||
-- 'Saghen/blink.cmp'
|
||||
-- },
|
||||
-- config = function()
|
||||
-- require('minuet').setup {
|
||||
-- provider = 'openai_fim_compatible',
|
||||
-- n_completions = 1, -- recommend for local model for resource saving
|
||||
-- -- I recommend beginning with a small context window size and incrementally
|
||||
-- -- expanding it, depending on your local computing power. A context window
|
||||
-- -- of 512, serves as an good starting point to estimate your computing
|
||||
-- -- power. Once you have a reliable estimate of your local computing power,
|
||||
-- -- you should adjust the context window to a larger value.
|
||||
-- context_window = 512,
|
||||
-- provider_options = {
|
||||
-- openai_fim_compatible = {
|
||||
-- -- For Windows users, TERM may not be present in environment variables.
|
||||
-- -- Consider using APPDATA instead.
|
||||
-- api_key = 'TERM',
|
||||
-- name = 'Llama.cpp',
|
||||
-- end_point = 'http://localhost:1234/v1/completions',
|
||||
-- model = 'qwen2.5-coder-7b-instruct',
|
||||
---- template = {
|
||||
---- prompt = function(context_before_cursor, context_after_cursor, _)
|
||||
---- return '<|fim_prefix|>'
|
||||
---- .. context_before_cursor
|
||||
---- .. '<|fim_suffix|>'
|
||||
---- .. context_after_cursor
|
||||
---- .. '<|fim_middle|>'
|
||||
---- end,
|
||||
---- suffix = false,
|
||||
---- },
|
||||
-- },
|
||||
-- },
|
||||
-- }
|
||||
-- end,
|
||||
-- },
|
||||
{
|
||||
'saghen/blink.cmp',
|
||||
-- optional: provides snippets for the snippet source
|
||||
dependencies = { 'rafamadriz/friendly-snippets' },
|
||||
|
||||
-- use a release tag to download pre-built binaries
|
||||
version = '1.*',
|
||||
-- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
|
||||
-- build = 'cargo build --release',
|
||||
-- If you use nix, you can build from source using latest nightly rust with:
|
||||
-- build = 'nix run .#build-plugin',
|
||||
|
||||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
opts = {
|
||||
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
|
||||
-- 'super-tab' for mappings similar to vscode (tab to accept)
|
||||
-- 'enter' for enter to accept
|
||||
-- 'none' for no mappings
|
||||
--
|
||||
-- All presets have the following mappings:
|
||||
-- C-space: Open menu or open docs if already open
|
||||
-- C-n/C-p or Up/Down: Select next/previous item
|
||||
-- C-e: Hide menu
|
||||
-- C-k: Toggle signature help (if signature.enabled = true)
|
||||
--
|
||||
-- See :h blink-cmp-config-keymap for defining your own keymap
|
||||
keymap = { preset = 'default' },
|
||||
|
||||
appearance = {
|
||||
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||
-- Adjusts spacing to ensure icons are aligned
|
||||
nerd_font_variant = 'mono'
|
||||
},
|
||||
|
||||
completion = { trigger = { prefetch_on_insert = false }, documentation = { auto_show = false } },
|
||||
|
||||
-- Default list of enabled providers defined so that you can extend it
|
||||
-- elsewhere in your config, without redefining it, due to `opts_extend`
|
||||
sources = {
|
||||
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||
},
|
||||
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||
--
|
||||
-- See the fuzzy documentation for more information
|
||||
fuzzy = { implementation = "prefer_rust_with_warning" }
|
||||
},
|
||||
-- config = function()
|
||||
-- require('blink-cmp').setup {
|
||||
-- sources = {
|
||||
-- default = { 'lsp', 'path', 'buffer', 'snippets', 'minuet' },
|
||||
-- providers = {
|
||||
-- minuet = {
|
||||
-- name = 'minuet',
|
||||
-- module = 'minuet.blink',
|
||||
-- async = true,
|
||||
-- -- Should match minuet.config.request_timeout * 1000,
|
||||
-- -- since minuet.config.request_timeout is in seconds
|
||||
-- timeout_ms = 3000,
|
||||
-- score_offset = 50, -- Gives minuet higher priority among suggestions
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- }
|
||||
-- end
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
config = function()
|
||||
local dap = require('dap')
|
||||
dap.adapters.codelldb = {
|
||||
type = "executable",
|
||||
command = "codelldb"
|
||||
}
|
||||
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = false,
|
||||
},
|
||||
}
|
||||
|
||||
dap.configurations.c = dap.configurations.cpp
|
||||
dap.configurations.rust = dap.configurations.cpp
|
||||
dap.configurations.zig = dap.configurations.cpp
|
||||
|
||||
vim.keymap.set("n", "<leader>dt", ":DapToggleBreakpoint<CR>")
|
||||
vim.keymap.set("n", "<leader>dc", ":DapContinue<CR>")
|
||||
vim.keymap.set("n", "<leader>dx", ":DapTerminate<CR>")
|
||||
vim.keymap.set("n", "<leader>do", ":DapStepOver<CR>")
|
||||
end
|
||||
},
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
dependencies = {
|
||||
"mfussenegger/nvim-dap",
|
||||
"nvim-neotest/nvim-nio"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
return {
|
||||
"sindrets/diffview.nvim"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"tpope/vim-fugitive"
|
||||
},
|
||||
{
|
||||
"lewis6991/gitsigns.nvim"
|
||||
},
|
||||
}
|
||||
5
.config/nvim/lua/plugins/init.lua
Normal file
5
.config/nvim/lua/plugins/init.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
require("plugins.whichkey")
|
||||
require("plugins.treesitter")
|
||||
require("plugins.neotree")
|
||||
require("plugins.telescope")
|
||||
require("plugins.theme")
|
||||
@@ -1,4 +0,0 @@
|
||||
return {
|
||||
"fei6409/log-highlight.nvim",
|
||||
opts = {},
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
lazy = false,
|
||||
config = function()
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
|
||||
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, {})
|
||||
vim.keymap.set("n", "<leader>gr", vim.lsp.buf.references, {})
|
||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, {})
|
||||
vim.keymap.set("n", '<leader>rn', vim.lsp.buf.rename, {})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
lazy = false,
|
||||
config = function()
|
||||
require("mason").setup({
|
||||
registries = {
|
||||
"github:mason-org/mason-registry",
|
||||
"github:Crashdummyy/mason-registry",
|
||||
},
|
||||
})
|
||||
end
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
lazy = false,
|
||||
opts = {
|
||||
auto_install = true,
|
||||
},
|
||||
},
|
||||
{
|
||||
"seblyng/roslyn.nvim",
|
||||
---@module 'roslyn.config'
|
||||
---@type RoslynNvimConfig
|
||||
opts = {
|
||||
-- your configuration comes here; leave empty for default settings
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
return {
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
branch = "v3.x",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
config = function()
|
||||
vim.keymap.set('n', '<C-n>', ':Neotree filesystem reveal float<CR>')
|
||||
end
|
||||
}
|
||||
11
.config/nvim/lua/plugins/neotree.lua
Normal file
11
.config/nvim/lua/plugins/neotree.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
vim.pack.add({
|
||||
{
|
||||
src = 'https://github.com/nvim-neo-tree/neo-tree.nvim',
|
||||
version = vim.version.range('3')
|
||||
},
|
||||
-- dependencies
|
||||
"https://github.com/nvim-lua/plenary.nvim",
|
||||
"https://github.com/MunifTanjim/nui.nvim",
|
||||
-- optional, but recommended
|
||||
"https://github.com/nvim-tree/nvim-web-devicons",
|
||||
})
|
||||
@@ -1,19 +0,0 @@
|
||||
return {
|
||||
'NickvanDyke/opencode.nvim',
|
||||
dependencies = { 'folke/snacks.nvim', },
|
||||
---@type opencode.Config
|
||||
opts = {
|
||||
-- Your configuration, if any
|
||||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ '<leader>ot', function() require('opencode').toggle() end, desc = 'Toggle embedded opencode', },
|
||||
{ '<leader>oa', function() require('opencode').ask() end, desc = 'Ask opencode', mode = 'n', },
|
||||
{ '<leader>oa', function() require('opencode').ask('@selection: ') end, desc = 'Ask opencode about selection', mode = 'v', },
|
||||
{ '<leader>op', function() require('opencode').select_prompt() end, desc = 'Select prompt', mode = { 'n', 'v', }, },
|
||||
{ '<leader>on', function() require('opencode').command('session_new') end, desc = 'New session', },
|
||||
{ '<leader>oy', function() require('opencode').command('messages_copy') end, desc = 'Copy last message', },
|
||||
{ '<S-C-u>', function() require('opencode').command('messages_half_page_up') end, desc = 'Scroll messages up', },
|
||||
{ '<S-C-d>', function() require('opencode').command('messages_half_page_down') end, desc = 'Scroll messages down', },
|
||||
},
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
return {
|
||||
"mtth/scratch.vim"
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
return {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
config = function()
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'auto',
|
||||
component_separators = { left = '', right = ''},
|
||||
section_separators = { left = '', right = ''},
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
always_show_tabline = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
refresh_time = 16, -- ~60fps
|
||||
events = {
|
||||
'WinEnter',
|
||||
'BufEnter',
|
||||
'BufWritePost',
|
||||
'SessionLoadPost',
|
||||
'FileChangedShellPost',
|
||||
'VimResized',
|
||||
'Filetype',
|
||||
'CursorMoved',
|
||||
'CursorMovedI',
|
||||
'ModeChanged',
|
||||
},
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {'location'}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {}
|
||||
}
|
||||
end
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.8",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<C-p>", builtin.find_files, {})
|
||||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
|
||||
end
|
||||
}
|
||||
vim.pack.add({"https://github.com/nvim-telescope/telescope.nvim",
|
||||
"https://github.com/nvim-lua/plenary.nvim",
|
||||
"https://github.com/BurntSushi/ripgrep",
|
||||
"https://github.com/nvim-telescope/telescope-fzf-native.nvim",
|
||||
"https://github.com/sharkdp/fd",
|
||||
"https://github.com/nvim-tree/nvim-web-devicons"}
|
||||
)
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
|
||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
|
||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
|
||||
|
||||
3
.config/nvim/lua/plugins/theme.lua
Normal file
3
.config/nvim/lua/plugins/theme.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
vim.pack.add({"https://github.com/catppuccin/nvim"})
|
||||
|
||||
vim.cmd("colorscheme catppuccin")
|
||||
@@ -1,7 +1,144 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require('nvim-treesitter').install({ 'zig', 'c', 'vim', 'rasi', 'cpp', 'javascript', 'markdown', 'markdown_inline', 'lua' }):wait(300000) -- wait max. 5 minutes
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-treesitter/nvim-treesitter",
|
||||
version = "main",
|
||||
},
|
||||
{
|
||||
src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
|
||||
version = "main",
|
||||
},
|
||||
})
|
||||
|
||||
require("nvim-treesitter").setup({})
|
||||
require("nvim-treesitter").install({
|
||||
"bash",
|
||||
"blade",
|
||||
"c",
|
||||
"comment",
|
||||
"css",
|
||||
"diff",
|
||||
"dockerfile",
|
||||
"fish",
|
||||
"gitcommit",
|
||||
"gitignore",
|
||||
"go",
|
||||
"gomod",
|
||||
"gosum",
|
||||
"gowork",
|
||||
"html",
|
||||
"ini",
|
||||
"javascript",
|
||||
"jsdoc",
|
||||
"json",
|
||||
"lua",
|
||||
"luadoc",
|
||||
"luap",
|
||||
"make",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"nginx",
|
||||
"nix",
|
||||
"proto",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"rust",
|
||||
"scss",
|
||||
"sql",
|
||||
"terraform",
|
||||
"toml",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"xml",
|
||||
"yaml",
|
||||
"zig",
|
||||
})
|
||||
|
||||
require("nvim-treesitter-textobjects").setup({
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
selection_modes = {
|
||||
["@parameter.outer"] = "v", -- charwise
|
||||
["@function.outer"] = "V", -- linewise
|
||||
["@class.outer"] = "<c-v>", -- blockwise
|
||||
},
|
||||
include_surrounding_whitespace = false,
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true,
|
||||
},
|
||||
})
|
||||
|
||||
-- SELECT keymaps
|
||||
local sel = require("nvim-treesitter-textobjects.select")
|
||||
for _, map in ipairs({
|
||||
{ { "x", "o" }, "af", "@function.outer" },
|
||||
{ { "x", "o" }, "if", "@function.inner" },
|
||||
{ { "x", "o" }, "ac", "@class.outer" },
|
||||
{ { "x", "o" }, "ic", "@class.inner" },
|
||||
{ { "x", "o" }, "aa", "@parameter.outer" },
|
||||
{ { "x", "o" }, "ia", "@parameter.inner" },
|
||||
{ { "x", "o" }, "ad", "@comment.outer" },
|
||||
{ { "x", "o" }, "as", "@statement.outer" },
|
||||
}) do
|
||||
vim.keymap.set(map[1], map[2], function()
|
||||
sel.select_textobject(map[3], "textobjects")
|
||||
end, { desc = "Select " .. map[3] })
|
||||
end
|
||||
|
||||
-- MOVE keymaps
|
||||
local mv = require("nvim-treesitter-textobjects.move")
|
||||
for _, map in ipairs({
|
||||
{ { "n", "x", "o" }, "]m", mv.goto_next_start, "@function.outer" },
|
||||
{ { "n", "x", "o" }, "[m", mv.goto_previous_start, "@function.outer" },
|
||||
{ { "n", "x", "o" }, "]]", mv.goto_next_start, "@class.outer" },
|
||||
{ { "n", "x", "o" }, "[[", mv.goto_previous_start, "@class.outer" },
|
||||
{ { "n", "x", "o" }, "]M", mv.goto_next_end, "@function.outer" },
|
||||
{ { "n", "x", "o" }, "[M", mv.goto_previous_end, "@function.outer" },
|
||||
{ { "n", "x", "o" }, "]o", mv.goto_next_start, { "@loop.inner", "@loop.outer" } },
|
||||
{ { "n", "x", "o" }, "[o", mv.goto_previous_start, { "@loop.inner", "@loop.outer" } },
|
||||
}) do
|
||||
local modes, lhs, fn, query = map[1], map[2], map[3], map[4]
|
||||
-- build a human-readable desc
|
||||
local qstr = (type(query) == "table") and table.concat(query, ",") or query
|
||||
vim.keymap.set(modes, lhs, function()
|
||||
fn(query, "textobjects")
|
||||
end, { desc = "Move to " .. qstr })
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("PackChanged", {
|
||||
desc = "Handle nvim-treesitter updates",
|
||||
group = vim.api.nvim_create_augroup("nvim-treesitter-pack-changed-update-handler", { clear = true }),
|
||||
callback = function(event)
|
||||
if event.data.kind == "update" then
|
||||
local ok = pcall(vim.cmd, "TSUpdate")
|
||||
if ok then
|
||||
vim.notify("TSUpdate completed successfully!", vim.log.levels.INFO)
|
||||
else
|
||||
vim.notify("TSUpdate command not available yet, skipping", vim.log.levels.WARN)
|
||||
end
|
||||
}
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "*" },
|
||||
callback = function()
|
||||
local filetype = vim.bo.filetype
|
||||
if filetype and filetype ~= "" then
|
||||
local success = pcall(function()
|
||||
vim.treesitter.start()
|
||||
end)
|
||||
if not success then
|
||||
return
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
98
.config/nvim/lua/plugins/whichkey.lua
Normal file
98
.config/nvim/lua/plugins/whichkey.lua
Normal file
@@ -0,0 +1,98 @@
|
||||
vim.pack.add({
|
||||
"https://github.com/folke/which-key.nvim",
|
||||
})
|
||||
|
||||
local wk = require("which-key")
|
||||
wk.setup({
|
||||
preset = "helix",
|
||||
})
|
||||
wk.add({
|
||||
{ "<leader><tab>", group = "tabs" },
|
||||
{ "<leader>c", group = "code" },
|
||||
{ "<leader>d", group = "debug" },
|
||||
{ "<leader>D", group = "Diffview", icon = { icon = "", color = "orange" } },
|
||||
{ "<leader>p", group = "Yanky", icon = { icon = " ", color = "yellow" } },
|
||||
{ "<leader>dp", group = "profiler" },
|
||||
{ "<leader>f", group = "file/find" },
|
||||
{ "<leader>g", group = "git" },
|
||||
{ "<leader>gh", group = "hunks" },
|
||||
{ "<leader>q", group = "quit/session" },
|
||||
{ "<leader>s", group = "search" },
|
||||
{ "<leader>u", group = "ui", icon = { icon = " ", color = "cyan" } },
|
||||
{ "<leader>x", group = "diagnostics/quickfix", icon = { icon = " ", color = "green" } },
|
||||
{ "[", group = "prev" },
|
||||
{ "]", group = "next" },
|
||||
{ "g", group = "goto" },
|
||||
{ "gs", group = "surround" },
|
||||
{ "z", group = "fold" },
|
||||
{
|
||||
"<leader>b",
|
||||
group = "buffer",
|
||||
expand = function()
|
||||
return require("which-key.extras").expand.buf()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"<leader>w",
|
||||
group = "windows",
|
||||
proxy = "<c-w>",
|
||||
expand = function()
|
||||
return require("which-key.extras").expand.win()
|
||||
end,
|
||||
},
|
||||
-- better descriptions
|
||||
{ "gx", desc = "Open with system app" },
|
||||
{
|
||||
"<leader>fC",
|
||||
group = "Copy Path",
|
||||
{
|
||||
"<leader>fCf",
|
||||
function()
|
||||
vim.fn.setreg("+", vim.fn.expand("%:p")) -- Copy full file path to clipboard
|
||||
vim.notify("Copied full file path: " .. vim.fn.expand("%:p"))
|
||||
end,
|
||||
desc = "Copy full file path",
|
||||
},
|
||||
{
|
||||
"<leader>fCn",
|
||||
function()
|
||||
vim.fn.setreg("+", vim.fn.expand("%:t")) -- Copy file name to clipboard
|
||||
vim.notify("Copied file name: " .. vim.fn.expand("%:t"))
|
||||
end,
|
||||
desc = "Copy file name",
|
||||
},
|
||||
{
|
||||
"<leader>fCr",
|
||||
function()
|
||||
local cwd = vim.fn.getcwd() -- Current working directory
|
||||
local full_path = vim.fn.expand("%:p") -- Full file path
|
||||
local rel_path = full_path:sub(#cwd + 2) -- Remove cwd prefix and leading slash
|
||||
vim.fn.setreg("+", rel_path) -- Copy relative file path to clipboard
|
||||
vim.notify("Copied relative file path: " .. rel_path)
|
||||
end,
|
||||
desc = "Copy relative file path",
|
||||
},
|
||||
{
|
||||
"<leader>?",
|
||||
function()
|
||||
require("which-key").show({ global = false })
|
||||
end,
|
||||
desc = "Buffer Keymaps (which-key)",
|
||||
},
|
||||
{
|
||||
"<c-w><space>",
|
||||
function()
|
||||
require("which-key").show({ keys = "<c-w>", loop = true })
|
||||
end,
|
||||
desc = "Window Hydra Mode (which-key)",
|
||||
},
|
||||
},
|
||||
{
|
||||
-- Nested mappings are allowed and can be added in any order
|
||||
-- Most attributes can be inherited or overridden on any level
|
||||
-- There's no limit to the depth of nesting
|
||||
mode = { "n", "v" }, -- NORMAL and VISUAL mode
|
||||
{ "<leader>q", "<cmd>q<cr>", desc = "Quit" }, -- no need to specify mode since it's inherited
|
||||
{ "<leader>w", "<cmd>w<cr>", desc = "Write" },
|
||||
},
|
||||
})
|
||||
@@ -1,14 +0,0 @@
|
||||
vim.g.mapleader= " "
|
||||
vim.o.termguicolors = true
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
vim.o.signcolumn = "yes"
|
||||
vim.o.expandtab = true
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 2
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.termguicolors = true
|
||||
vim.o.winborder = "rounded"
|
||||
vim.o.cursorline = true
|
||||
vim.o.list = true
|
||||
vim.o.scrolloff = 8
|
||||
55
.config/nvim/nvim-pack-lock.json
Normal file
55
.config/nvim/nvim-pack-lock.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"plugins": {
|
||||
"fd": {
|
||||
"rev": "5f95a78",
|
||||
"src": "https://github.com/sharkdp/fd"
|
||||
},
|
||||
"neo-tree.nvim": {
|
||||
"rev": "f3df514",
|
||||
"src": "https://github.com/nvim-neo-tree/neo-tree.nvim",
|
||||
"version": "3.0.0 - 4.0.0"
|
||||
},
|
||||
"nui.nvim": {
|
||||
"rev": "de74099",
|
||||
"src": "https://github.com/MunifTanjim/nui.nvim"
|
||||
},
|
||||
"nvim": {
|
||||
"rev": "6efc53e",
|
||||
"src": "https://github.com/catppuccin/nvim"
|
||||
},
|
||||
"nvim-treesitter": {
|
||||
"rev": "b033ab33",
|
||||
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
|
||||
"version": "'main'"
|
||||
},
|
||||
"nvim-treesitter-textobjects": {
|
||||
"rev": "28a3494",
|
||||
"src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
|
||||
"version": "'main'"
|
||||
},
|
||||
"nvim-web-devicons": {
|
||||
"rev": "6788013",
|
||||
"src": "https://github.com/nvim-tree/nvim-web-devicons"
|
||||
},
|
||||
"plenary.nvim": {
|
||||
"rev": "b9fd522",
|
||||
"src": "https://github.com/nvim-lua/plenary.nvim"
|
||||
},
|
||||
"ripgrep": {
|
||||
"rev": "0a88ccc",
|
||||
"src": "https://github.com/BurntSushi/ripgrep"
|
||||
},
|
||||
"telescope-fzf-native.nvim": {
|
||||
"rev": "6fea601",
|
||||
"src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
|
||||
},
|
||||
"telescope.nvim": {
|
||||
"rev": "3333a52",
|
||||
"src": "https://github.com/nvim-telescope/telescope.nvim"
|
||||
},
|
||||
"which-key.nvim": {
|
||||
"rev": "3aab214",
|
||||
"src": "https://github.com/folke/which-key.nvim"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user