diff options
author | Akshay <[email protected]> | 2021-02-15 08:52:32 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2021-02-15 08:52:32 +0000 |
commit | fcaf13a267b7bacd26ad8b2e952a793645e42bba (patch) | |
tree | 6e795b46b1fbefb05151e95c0346951d67fac4e7 /lua |
init
Diffstat (limited to 'lua')
-rw-r--r-- | lua/lsp.lua | 59 | ||||
-rw-r--r-- | lua/treesitter.lua | 18 |
2 files changed, 77 insertions, 0 deletions
diff --git a/lua/lsp.lua b/lua/lsp.lua new file mode 100644 index 0000000..f921c70 --- /dev/null +++ b/lua/lsp.lua | |||
@@ -0,0 +1,59 @@ | |||
1 | local nvim_lsp = require('lspconfig') | ||
2 | local on_attach = function(client, bufnr) | ||
3 | local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end | ||
4 | local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end | ||
5 | |||
6 | buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') | ||
7 | |||
8 | -- Mappings. | ||
9 | local opts = { noremap=true, silent=true } | ||
10 | buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) | ||
11 | buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) | ||
12 | buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) | ||
13 | buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) | ||
14 | buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) | ||
15 | buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) | ||
16 | buf_set_keymap('n', '<space>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', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts) | ||
19 | buf_set_keymap('n', '[g', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) | ||
20 | buf_set_keymap('n', ']g', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) | ||
21 | buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts) | ||
22 | |||
23 | -- Set some keybinds conditional on server capabilities | ||
24 | if client.resolved_capabilities.document_formatting then | ||
25 | buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) | ||
26 | elseif client.resolved_capabilities.document_range_formatting then | ||
27 | buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts) | ||
28 | end | ||
29 | end | ||
30 | |||
31 | local servers = { "hls", "rnix", "bashls", "pyls" } | ||
32 | for _, lsp in ipairs(servers) do | ||
33 | nvim_lsp[lsp].setup { on_attach = on_attach } | ||
34 | end | ||
35 | |||
36 | local capabilities = vim.lsp.protocol.make_client_capabilities() | ||
37 | capabilities.textDocument.completion.completionItem.snippetSupport = true | ||
38 | |||
39 | nvim_lsp.rust_analyzer.setup { | ||
40 | capabilities = capabilities, | ||
41 | settings = { | ||
42 | ["rust-analyzer"] = { | ||
43 | procMacro = { | ||
44 | enable = true | ||
45 | }, | ||
46 | }, | ||
47 | }, | ||
48 | } | ||
49 | |||
50 | nvim_lsp.ccls.setup { | ||
51 | init_options = { | ||
52 | index = { | ||
53 | threads = 0; | ||
54 | }; | ||
55 | clang = { | ||
56 | excludeArgs = { "-frounding-math"} ; | ||
57 | }; | ||
58 | } | ||
59 | } | ||
diff --git a/lua/treesitter.lua b/lua/treesitter.lua new file mode 100644 index 0000000..d503b46 --- /dev/null +++ b/lua/treesitter.lua | |||
@@ -0,0 +1,18 @@ | |||
1 | require'nvim-treesitter.configs'.setup { | ||
2 | highlight = { | ||
3 | enable = true, | ||
4 | |||
5 | }, | ||
6 | incremental_selection = { | ||
7 | enable = true, | ||
8 | keymaps = { | ||
9 | init_selection = "gnn", | ||
10 | node_incremental = "g}", | ||
11 | scope_incremental = "grc", | ||
12 | node_decremental = "g{", | ||
13 | }, | ||
14 | }, | ||
15 | indent = { | ||
16 | enable = false | ||
17 | } | ||
18 | } | ||