diff options
Diffstat (limited to '.config/nvim/lua/user/lsp')
-rw-r--r-- | .config/nvim/lua/user/lsp/common.lua | 36 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/rust.lua | 47 |
2 files changed, 60 insertions, 23 deletions
diff --git a/.config/nvim/lua/user/lsp/common.lua b/.config/nvim/lua/user/lsp/common.lua index 7873752..1b1920c 100644 --- a/.config/nvim/lua/user/lsp/common.lua +++ b/.config/nvim/lua/user/lsp/common.lua @@ -1,5 +1,32 @@ -- this file contains setup for snippets and common LSP options +-- nvim diagnostics setup + +local define_sign = function(options) + vim.fn.sign_define(options.name, { texthl = options.name, text = options.textm, numhl = '' }) +end + +define_sign({name = "DiagnosticSignError", text = ''}) +define_sign({name = "DiagnosticSignWarn", text = ''}) +define_sign({name = "DiagnosticSignHint", text = ''}) +define_sign({name = "DiagnosticSignInfo", text = ''}) + +vim.diagnostic.config{ + virtual_text = true, + signs = true, + update_in_insert = false, + underline = true, + severity_sort = true, + float = { + source = 'always', + }, +} + +vim.cmd[[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]] + -- WHY THE FUCK DID THE PROTECTED CALL SOLVE THE ISSUE UGH local cmp_status, cmp = pcall(require, 'cmp') if not cmp_status then @@ -8,7 +35,8 @@ if not cmp_status then end autopairs_cmp = require 'nvim-autopairs.completion.cmp' luasnip = require 'luasnip' -luasnip.setup() +-- require 'user.snippets' +-- luasnip.setup() local expnoresilent = {expr = true, noremap = true, silent = true} local noresilent = {noremap = true, silent = true} @@ -44,8 +72,6 @@ local supertabforward = function(fallback) cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() - -- elseif stolen_function() then - -- cmp.complete() else fallback() end @@ -80,8 +106,8 @@ cmp.setup { }, ["<Tab>"] = map(supertabforward, inselect), ["<S-Tab>"] = map(supertabbackward, inselect), - ["<C-k>"] = map(supertabforward, inselect), - ["<C-j>"] = map(supertabbackward, inselect), + ["<C-k>"] = map.scroll_docs(2), + ["<C-j>"] = map.scroll_docs(-2), ["<C-l>"] = map(superenterconfirm, inselect), ["<C-h>"] = map(function(fallback) if cmp.visible() then diff --git a/.config/nvim/lua/user/lsp/rust.lua b/.config/nvim/lua/user/lsp/rust.lua index def29af..41cb03c 100644 --- a/.config/nvim/lua/user/lsp/rust.lua +++ b/.config/nvim/lua/user/lsp/rust.lua @@ -1,24 +1,35 @@ -lsp = require 'lspconfig' +local lsp = require 'lspconfig' +local rust = require 'rust-tools' -vim.cmd [[ - autocmd FileType rust highlight link rustLifetime SpecialComment -]] +-- vim.cmd [[ +-- autocmd FileType rust highlight link rustLifetime SpecialComment +-- ]] -vim.cmd [[ - autocmd FileType rust setlocal inccommand=nosplit -]] +-- vim.cmd [[ +-- autocmd FileType rust setlocal inccommand=nosplit +-- ]] -lsp.rust_analyzer.setup{ - cmd = {"rust-analyzer"}, - filetypes = {"rust", "rs"}, - root_dir = lsp.util.root_pattern("Cargo.toml"), - -- fucking magic - capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), - settings = { - ["rust-analyzer"] = { - disgnostics = { enable = true }, - inlayHints = { typeHints = true }, - }, +-- lsp.rust_analyzer.setup{ +-- cmd = {"rust-analyzer"}, +-- filetypes = {"rust", "rs"}, +-- root_dir = lsp.util.root_pattern("Cargo.toml"), +-- -- fucking magic +-- capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), +-- settings = { +-- ["rust-analyzer"] = { +-- disgnostics = { enable = true }, +-- inlayHints = { typeHints = true }, +-- }, +-- }, +-- } + +rust.setup{ + server = { + on_attach = function(_, bufnr) + vim.keymap.set("n", "<leader> ", rust.hover_actions.hover_actions, { buffer = bufnr }) + vim.keymap.set("n", "<leader>a", rust.code_action_group.code_action_group, { buffer = bufnr }) + end, }, } + |