summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--ftplugin/nix.vim4
-rw-r--r--ftplugin/rust.vim9
l---------init.vim1
-rw-r--r--lua/completions.lua16
-rw-r--r--lua/leap-ast.lua51
-rw-r--r--lua/leap.lua10
-rw-r--r--lua/lsp.lua71
-rw-r--r--lua/treesitter.lua2
-rw-r--r--plugin/maps.vim4
-rw-r--r--spell/en.utf-8.add1
11 files changed, 121 insertions, 49 deletions
diff --git a/.gitignore b/.gitignore
index e883c08..cec7d96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
1init.lua
1.netrwhist 2.netrwhist
2after/.netrwhist 3after/.netrwhist
3autoload/ 4autoload/
diff --git a/ftplugin/nix.vim b/ftplugin/nix.vim
deleted file mode 100644
index f34ae88..0000000
--- a/ftplugin/nix.vim
+++ /dev/null
@@ -1,4 +0,0 @@
1augroup NixFmt
2 autocmd!
3 autocmd BufWritePost *.nix | silent! exec '!nixpkgs-fmt %' | silent! edit
4augroup END
diff --git a/ftplugin/rust.vim b/ftplugin/rust.vim
index fce69b4..50645fa 100644
--- a/ftplugin/rust.vim
+++ b/ftplugin/rust.vim
@@ -11,12 +11,3 @@ set errorformat=
11 \%Inote:\ %m, 11 \%Inote:\ %m,
12 \%C\ %#-->\ %f:%l:%c, 12 \%C\ %#-->\ %f:%l:%c,
13 \%E\ \ left:%m,%C\ right:%m\ %f:%l:%c,%Z 13 \%E\ \ left:%m,%C\ right:%m\ %f:%l:%c,%Z
14
15function! RustMake() abort
16 set makeprg=nix-shell\ --run\ \"cargo\ build\"
17 silent! make
18 set makeprg=nix-shell\ --run\ \"cargo\ clippy\"
19 silent! make
20endfunction
21
22nnoremap <leader>r :call RustMake() <bar> silent! redraw <bar> cwindow<cr>
diff --git a/init.vim b/init.vim
deleted file mode 120000
index bc11895..0000000
--- a/init.vim
+++ /dev/null
@@ -1 +0,0 @@
1/nix/store/2c32chzx6k2w0n18ijnsdlkklj58dx2h-home-manager-files/.config/nvim/init.vim \ No newline at end of file
diff --git a/lua/completions.lua b/lua/completions.lua
index f7598a6..bd90178 100644
--- a/lua/completions.lua
+++ b/lua/completions.lua
@@ -14,6 +14,22 @@ cmp.setup({
14 c = cmp.mapping.close(), 14 c = cmp.mapping.close(),
15 }), 15 }),
16 ['<CR>'] = cmp.mapping.confirm({ select = true }), 16 ['<CR>'] = cmp.mapping.confirm({ select = true }),
17
18 ['<C-n>'] = cmp.mapping(function(fallback)
19 if cmp.visible() then
20 cmp.select_next_item()
21 else
22 fallback()
23 end
24 end, { 'i', 's', 'c' }),
25
26 ['<C-p>'] = cmp.mapping(function(fallback)
27 if cmp.visible() then
28 cmp.select_prev_item()
29 else
30 fallback()
31 end
32 end, { 'i', 's', 'c' }),
17 }, 33 },
18 sources = cmp.config.sources({ 34 sources = cmp.config.sources({
19 { name = 'nvim_lsp' }, 35 { name = 'nvim_lsp' },
diff --git a/lua/leap-ast.lua b/lua/leap-ast.lua
new file mode 100644
index 0000000..22a5876
--- /dev/null
+++ b/lua/leap-ast.lua
@@ -0,0 +1,51 @@
1local api = vim.api
2-- Note: The functions used here will be upstreamed eventually.
3local ts_utils = require('nvim-treesitter.ts_utils')
4
5local function get_ast_nodes()
6 local wininfo = vim.fn.getwininfo(api.nvim_get_current_win())[1]
7 -- Get current TS node.
8 local cur_node = ts_utils.get_node_at_cursor(0)
9 if not cur_node then return end
10 -- Get parent nodes recursively.
11 local nodes = { cur_node }
12 local parent = cur_node:parent()
13 while parent do
14 table.insert(nodes, parent)
15 parent = parent:parent()
16 end
17 -- Create Leap targets from TS nodes.
18 local targets = {}
19 local startline, startcol
20 for _, node in ipairs(nodes) do
21 startline, startcol, _, _ = node:range() -- (0,0)
22 if startline + 1 >= wininfo.topline then
23 local target = { node = node, pos = { startline + 1, startcol + 1 } }
24 table.insert(targets, target)
25 end
26 end
27 if #targets >= 1 then return targets end
28end
29
30local function select_range(target)
31 local mode = api.nvim_get_mode().mode
32 if not mode:match('n?o') then
33 -- Force going back to Normal (implies mode = v | V | ).
34 vim.cmd('normal! ' .. mode)
35 end
36 ts_utils.update_selection(0, target.node,
37 mode:match('V') and 'linewise' or
38 mode:match('') and 'blockwise' or
39 'charwise'
40 )
41end
42
43local function leap()
44 require('leap').leap {
45 targets = get_ast_nodes(),
46 action = api.nvim_get_mode().mode ~= 'n' and select_range, -- or jump
47 backward = true
48 }
49end
50
51return { leap = leap }
diff --git a/lua/leap.lua b/lua/leap.lua
new file mode 100644
index 0000000..14be3bd
--- /dev/null
+++ b/lua/leap.lua
@@ -0,0 +1,10 @@
1local leap = require 'leap'
2leap.opts.safe_labels = {}
3leap.opts.labels = {
4 "a", "r", "s", "t", "n", "e", "i", "o", "d", "h",
5 "A", "R", "S", "T", "N", "E", "I", "O", "D", "H"
6}
7leap.opts.special_keys = {
8 next_target = '<c-n>',
9 prev_target = '<c-p>',
10}
diff --git a/lua/lsp.lua b/lua/lsp.lua
index 7509593..349c719 100644
--- a/lua/lsp.lua
+++ b/lua/lsp.lua
@@ -6,53 +6,51 @@ local on_attach = function(client, bufnr)
6 buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') 6 buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
7 7
8 -- Mappings. 8 -- Mappings.
9 local opts = { noremap=true, silent=true } 9 local bufopts = { noremap=true, silent=true, buffer=bufnr }
10 buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) 10 vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
11 buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) 11 vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
12 buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) 12 vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
13 buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) 13 vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
14 buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) 14 vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
15 buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
16 buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
17 buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
18 buf_set_keymap('n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
19 buf_set_keymap('n', '[g', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
20 buf_set_keymap('n', ']g', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
21 buf_set_keymap('n', '<leader>q', '<cmd>lua vim.diagnostic.set_qflist()<CR>', opts)
22 15
23 -- Set some keybinds conditional on server capabilities 16 local opts = { noremap=true, silent=true }
24 if client.server_capabilities.document_formatting then 17 vim.keymap.set('n', '<space>d', vim.diagnostic.open_float, opts)
25 buf_set_keymap("n", "<leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) 18 vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
26 elseif client.server_capabilities.document_range_formatting then 19 vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
27 buf_set_keymap("n", "<leader>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts) 20 vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
28 end 21 vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
29end 22end
30 23
31local servers = { "hls", "rnix", "bashls" } 24local servers = { "hls", "bashls" }
32for _, lsp in ipairs(servers) do 25for _, lsp in ipairs(servers) do
33 nvim_lsp[lsp].setup { 26 nvim_lsp[lsp].setup {
34 on_attach = on_attach, 27 on_attach = on_attach,
35 } 28 }
36end 29end
37 30
38local capabilities = vim.lsp.protocol.make_client_capabilities() 31local capabilities = require('cmp_nvim_lsp')
32 .default_capabilities(vim.lsp.protocol.make_client_capabilities())
33
39capabilities.textDocument.completion.completionItem.snippetSupport = true 34capabilities.textDocument.completion.completionItem.snippetSupport = true
40 35
41nvim_lsp.rust_analyzer.setup { 36-- nvim_lsp.rust_analyzer.setup {
42 capabilities = capabilities, 37-- on_attach = on_attach,
43 settings = { 38-- settings = {
44 ["rust-analyzer"] = { 39-- ["rust-analyzer"] = {
45 procMacro = { 40-- procMacro = {
46 enable = true 41-- enable = true
47 }, 42-- },
48 cargo = { 43-- cargo = {
49 allFeatures = true, 44-- allFeatures = false,
50 }, 45-- },
51 }, 46-- checkOnSave = false,
52 }, 47-- },
53} 48-- },
49-- }
54 50
55nvim_lsp.ccls.setup { 51nvim_lsp.ccls.setup {
52 capabilities = capabilities,
53 on_attach = on_attach,
56 init_options = { 54 init_options = {
57 index = { 55 index = {
58 threads = 0; 56 threads = 0;
@@ -63,3 +61,8 @@ nvim_lsp.ccls.setup {
63 }; 61 };
64 } 62 }
65} 63}
64
65nvim_lsp.jdtls.setup{
66 cmd = {"jdtls"};
67}
68
diff --git a/lua/treesitter.lua b/lua/treesitter.lua
index 344abf0..f63cb3b 100644
--- a/lua/treesitter.lua
+++ b/lua/treesitter.lua
@@ -1,6 +1,6 @@
1require'nvim-treesitter.configs'.setup { 1require'nvim-treesitter.configs'.setup {
2 highlight = { 2 highlight = {
3 enable = true, 3 enable = false,
4 -- disable = { "c"}, 4 -- disable = { "c"},
5 }, 5 },
6 incremental_selection = { 6 incremental_selection = {
diff --git a/plugin/maps.vim b/plugin/maps.vim
index b3e12da..b61e994 100644
--- a/plugin/maps.vim
+++ b/plugin/maps.vim
@@ -7,6 +7,7 @@ map <leader>cc :w !xclip -sel c<CR>
7 7
8" normal 8" normal
9nnoremap <Leader>o : only<cr> 9nnoremap <Leader>o : only<cr>
10nnoremap - : b#<cr>
10nnoremap <Leader>b : Buffers<cr> 11nnoremap <Leader>b : Buffers<cr>
11nnoremap <Leader>n : bnext<cr> 12nnoremap <Leader>n : bnext<cr>
12nnoremap <Leader>p : bprev<cr> 13nnoremap <Leader>p : bprev<cr>
@@ -25,6 +26,9 @@ nnoremap <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '>
25 \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" 26 \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
26 \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR> 27 \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
27 28
29nnoremap <Leader>s <Plug>(leap-forward-to)
30nnoremap <Leader>S <Plug>(leap-backward-to)
31
28cmap w!! %!sudo -S tee > /dev/null % 32cmap w!! %!sudo -S tee > /dev/null %
29 33
30" visual 34" visual
diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add
index 8bed7bf..333c6d8 100644
--- a/spell/en.utf-8.add
+++ b/spell/en.utf-8.add
@@ -19,3 +19,4 @@ Vasudeva
19Devaki 19Devaki
20Rakshasas 20Rakshasas
21right 21right
22#xersice