- commit
- 04cb304
- parent
- 0701ba3
- author
- Eric Bower
- date
- 2025-09-18 22:42:47 -0400 EDT
refactor(nvim): even more minimal
1 files changed,
+19,
-35
+19,
-35
1@@ -28,7 +28,7 @@ o.undofile = true
2 o.ignorecase = true
3 o.smartcase = true
4 o.swapfile = false
5-o.foldmethod = "expr"
6+o.foldmethod = "indent"
7 o.foldlevel = 99
8 o.foldnestmax = 1
9 vim.g.mapleader = ","
10@@ -41,21 +41,19 @@ local opts = { silent = true }
11 local map = vim.keymap.set
12 map("t", "<Esc>", [[<C-\><C-n>]], opts) -- exit terminal mode
13 map("n", "Q", "<nop>", opts) -- disable "Q"
14-map("n", "<C-k>", ":wincmd k<CR>", opts) -- navigate splits
15-map("n", "<C-j>", ":wincmd j<CR>", opts)
16-map("n", "<C-h>", ":wincmd h<CR>", opts)
17-map("n", "<C-l>", ":wincmd l<CR>", opts)
18-map("n", "<leader>t", ":bd!<CR>", opts)
19+map("n", "<C-k>", "<cmd>wincmd k<cr>", opts) -- navigate splits
20+map("n", "<C-j>", "<cmd>wincmd j<cr>", opts)
21+map("n", "<C-h>", "<cmd>wincmd h<cr>", opts)
22+map("n", "<C-l>", "<cmd>wincmd l<cr>", opts)
23+map("n", "<C-u>", "<C-u>zz", opts) -- half step + center cursor, less disorienting page movements
24+map("n", "<C-d>", "<C-d>zz", opts)
25+map("n", "<leader>t", "<cmd>bd!<cr>", opts)
26 map("n", "<leader>e", vim.diagnostic.open_float, opts)
27 map("n", "<leader>q", vim.diagnostic.setloclist, opts)
28 map({ "n", "v" }, "<leader>gy", "<cmd>GitLink<cr>", opts)
29 map("n", "<leader>y", function() -- copy relative filepath to clipboard
30 vim.fn.setreg("+", vim.fn.expand("%"))
31 end)
32--- https://github.com/shell-pool/shpool/issues/71#issuecomment-2632396805
33-map({ "n", "v", "i", "t" }, "<C-space><C-d>", function()
34- vim.cmd("!shpool detach")
35-end)
36 -- https://github.com/shell-pool/shpool/issues/240#issuecomment-3097566679
37 map("n", "<leader>l", function()
38 io.stdout:write("\027[?2048h")
39@@ -80,16 +78,11 @@ local function setup_lsp()
40 autocmd("LspAttach", {
41 group = augroup,
42 callback = function(ev)
43- local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
44 local bufopts = { noremap = true, silent = true, buffer = ev.buf }
45- map("i", "<C-k>", vim.lsp.completion.get, bufopts) -- open completion menu manually
46 map("n", "grd", vim.lsp.buf.definition, bufopts)
47-
48- local methods = vim.lsp.protocol.Methods
49- -- https://github.com/neovim/neovim/blob/b2828af5b5aba044cd40594a519d2d9f5dbb69cb/runtime/lua/vim/lsp/protocol.lua?plain=1#L858
50- if client:supports_method(methods.textDocument_completion) then
51- vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
52- end
53+ map("i", "<C-k>", vim.lsp.completion.get, bufopts) -- open completion menu manually
54+ local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
55+ vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
56 end,
57 })
58 end
59@@ -114,15 +107,19 @@ local function setup_fzf()
60 local fzf_jumps = function()
61 fzf.jumps(with_prev)
62 end
63+ local fzf_git_diff = function()
64+ fzf.git_diff(with_prev)
65+ end
66 map("n", "<leader>s", fzf_files, { desc = "fzf files", noremap = true, silent = true })
67 map("n", "<leader>F", fzf_symbols, { desc = "fzf symbols", noremap = true, silent = true })
68 map("n", "<leader>f", fzf_buffers, { desc = "fzf buffers", noremap = true, silent = true })
69 map("n", "<leader>S", fzf_live_grep, { desc = "fzf grep", noremap = true, silent = true })
70 map("n", "<leader>j", fzf_jumps, { desc = "fzf jumplist", noremap = true, silent = true })
71+ map("n", "<leader>d", fzf_git_diff, { desc = "fzf git diff", noremap = true, silent = true })
72 fzf.setup({ "max-perf" })
73 end
74
75-local function setup_treesitter()
76+local function setup_ts()
77 local ts_parsers = {
78 "bash",
79 "c",
80@@ -169,12 +166,7 @@ local function setup_treesitter()
81 local filetype = ev.match
82 local lang = vim.treesitter.language.get_lang(filetype)
83 if vim.treesitter.language.add(lang) then
84- if vim.treesitter.query.get(filetype, "indents") then
85- vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
86- end
87- if vim.treesitter.query.get(filetype, "folds") then
88- vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
89- end
90+ vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
91 vim.treesitter.start()
92 end
93 end,
94@@ -186,20 +178,12 @@ vim.pack.add({
95 "https://github.com/nvim-treesitter/nvim-treesitter-context",
96 "https://github.com/neovim/nvim-lspconfig",
97 "https://github.com/ibhagwan/fzf-lua",
98- "https://github.com/karb94/neoscroll.nvim",
99 "https://github.com/linrongbin16/gitlinker.nvim",
100 "https://github.com/tpope/vim-fugitive",
101 })
102
103-setup_treesitter()
104+setup_ts()
105 setup_lsp()
106 setup_fzf()
107-require("neoscroll").setup({ duration_multiplier = 0.4 })
108 require("gitlinker").setup()
109-require("treesitter-context").setup({
110- max_lines = 3,
111- multiline_threshold = 1,
112- separator = "-",
113- min_window_height = 20,
114- line_numbers = false,
115-})
116+require("treesitter-context").setup({ max_lines = 3, separator = ">" })