nvim-config

Log | Files | Refs | Submodules | README

commit 6439915eff268eba0bb38aeb24306b0757545807
parent 859d7d5b2361bf05b9b7533ccd2452f2296f16b5
Author: Thomas Vigouroux <tomvig38@gmail.com>
Date:   Wed, 10 Nov 2021 12:44:08 +0100

Update lsp config

Diffstat:
Mlua/lsp_config.lua | 145++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mlua/tele_config.lua | 4++--
2 files changed, 82 insertions(+), 67 deletions(-)

diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua @@ -1,4 +1,5 @@ local lsp = require'lspconfig' +require("grammar-guard").init() vim.cmd[[packadd nvim-lspconfig]] @@ -26,16 +27,22 @@ local function on_attach(client, bufnr) buf_set_keymap('<C-S-K>', 'vim.lsp.buf.signature_help()') buf_set_keymap('gr', 'vim.lsp.buf.rename()') buf_set_keymap('<Leader>a', 'vim.lsp.buf.code_action()') - buf_set_keymap('[d', 'vim.lsp.diagnostic.goto_prev()') - buf_set_keymap(']d', 'vim.lsp.diagnostic.goto_next()') - buf_set_keymap('<Leader>l', 'vim.lsp.diagnostic.set_loclist()') - buf_set_keymap('<Leader>q', 'vim.lsp.diagnostic.set_qflist()') + buf_set_keymap('[d', 'vim.diagnostic.goto_prev()') + buf_set_keymap(']d', 'vim.diagnostic.goto_next()') + buf_set_keymap('<Leader>l', 'vim.diagnostic.setloclist()') + buf_set_keymap('<Leader>q', 'vim.diagnostic.setqflist()') buf_set_keymap('<Leader>=', 'vim.lsp.buf.formatting()') buf_set_keymap('gR', 'require"telescope.builtin".lsp_references()') buf_set_keymap('<Leader>s', 'require"telescope.builtin".lsp_dynamic_workspace_symbols()') + -- I always have telecope on, but we never know + local f = vim.lsp.buf.list_workspace_folders()[1] + if pcall(require, 'telescope') and f then + buf_set_keymap('<Leader>e', string.format('require"telescope.builtin".fd{ cwd = "%s" }', f)) + end + vim.api.nvim_buf_call(bufnr, function() - vim.api.nvim_command [[autocmd CursorHold <buffer> lua pcall(vim.lsp.diagnostic.show_position_diagnostics, {focusable = false})]] + vim.api.nvim_command [[autocmd CursorHold <buffer> lua pcall(vim.diagnostic.open_float, 0, {focusable = false, scope = 'cursor'})]] if client.supports_method('textDocument/documentHighlight') then vim.api.nvim_command [[autocmd CursorHold <buffer> lua pcall(vim.lsp.buf.document_highlight)]] vim.api.nvim_command [[autocmd CursorMoved <buffer> lua pcall(vim.lsp.buf.clear_references)]] @@ -45,76 +52,84 @@ end local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true -local default_lsps = { - 'ccls', - 'als', - 'rust_analyzer', - 'ghcide', - 'pylsp', - 'ocamllsp', - 'rnix', -} - -for _,lname in ipairs(default_lsps) do - lsp[lname].setup { capabilities = capabilities, on_attach = on_attach } -end +local default_config = { capabilities = capabilities, on_attach = on_attach } -require("grammar-guard").init() +local lsps = { + -- Default configs + ccls = default_config, + als = default_config, + ghcide = default_config, + pylsp = default_config, + ocamllsp = default_config, + rnix = default_config, -lsp.grammar_guard.setup { - on_attach = on_attach, - capabilities = capabilities, - settings = { - ltex = { - enabled = { "latex", "tex", "bib", "markdown" }, - language = "auto", - diagnosticSeverity = "information", - setenceCacheSize = 2000, - additionalRules = { - enablePickyRules = true, - motherTongue = "fr", + -- Special cases + rust_analyzer = { + capabilities = capabilities, + on_attach = on_attach, + cmd = {"rustup", "run", "nightly", "rust-analyzer"} + }, + grammar_guard = { + on_attach = on_attach, + capabilities = capabilities, + filetypes = { "latex", "tex", "bib", "markdown", "gitcommit" }, + settings = { + ltex = { + enabled = { "latex", "tex", "bib", "markdown", }, + language = "auto", + diagnosticSeverity = "information", + setenceCacheSize = 2000, + additionalRules = { + enablePickyRules = true, + motherTongue = "fr", + }, + trace = { server = "verbose" }, + dictionary = {}, + disabledRules = {}, + hiddenFalsePositives = {}, }, - trace = { server = "verbose" }, - dictionary = {}, - disabledRules = {}, - hiddenFalsePositives = {}, }, }, -} + sumneko_lua = (function() + local sumneko_root_path = vim.fn.expand('$HOME')..'/src/lua-language-server' + local sumneko_binary = sumneko_root_path.."/bin/Linux/lua-language-server" -local sumneko_root_path = vim.fn.expand('$HOME')..'/src/lua-language-server' -local sumneko_binary = sumneko_root_path.."/bin/Linux/lua-language-server" - -lsp.sumneko_lua.setup { - on_attach = on_attach, - cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}; - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = vim.split(package.path, ';'), - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = {'vim'}, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = { - [vim.fn.expand('$VIMRUNTIME/lua')] = true, - [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + return { + on_attach = on_attach, + cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}; + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = vim.split(package.path, ';'), + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'}, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + }, + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, }, }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - }, + } + end)() } +for lname,config in pairs(lsps) do + lsp[lname].setup(config) +end + -- texlab local function texlab_attach(client, bufnr) vim.lsp.protocol.SymbolKind = { diff --git a/lua/tele_config.lua b/lua/tele_config.lua @@ -18,9 +18,9 @@ local function map(mode, lhs, rhs, opts) vim.api.nvim_set_keymap(mode, lhs, rhs, opts or { silent = true, noremap = true}) end -map('n', '<Leader>e', lua_call('telescope.builtin', 'find_files')) +map('n', '<Leader>e', lua_call('telescope.builtin', 'fd')) map('n', '<Leader>h', lua_call('telescope.builtin', 'help_tags')) -map('n', '<Leader>oc', lua_call('telescope.builtin', 'find_files', { cwd = vim.fn.stdpath'config' })) +map('n', '<Leader>oc', lua_call('telescope.builtin', 'fd', { cwd = vim.fn.stdpath'config' })) map('n', '<Leader>b', lua_call('telescope.builtin', 'buffers')) map('n', '<Leader>q', lua_call('telescope.builtin', 'quickfix')) map('n', '<Leader>r', lua_call('telescope.builtin', 'live_grep'))