nvim-config

Log | Files | Refs | Submodules | README

commit 2ad6ec852a4272b0f8834cb9a53a4ba321c94ee1
parent 8ba4f569959957ad8aae316e658ed44c58f4bc95
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date:   Wed,  8 Dec 2021 10:22:01 +0100

Update

Diffstat:
Mafter/ftplugin/tex.vim | 3+--
Mafter/plugin/config/templar.lua | 1+
Mlua/lsp_config.lua | 189++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mlua/plugins.lua | 4++--
Atemplates/template.shell.nix | 10++++++++++
5 files changed, 119 insertions(+), 88 deletions(-)

diff --git a/after/ftplugin/tex.vim b/after/ftplugin/tex.vim @@ -1,5 +1,4 @@ -" Last Change: 2021 Jan 08 -setlocal spell +" Last Change: 2021 Nov 24 setlocal formatoptions+=tc setlocal textwidth=100 set conceallevel=0 diff --git a/after/plugin/config/templar.lua b/after/plugin/config/templar.lua @@ -3,3 +3,4 @@ templar.register('*.vim') templar.register('*.h') templar.register('*.sh') templar.register('*.lua') +templar.register('shell.nix') diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua @@ -1,4 +1,5 @@ local lsp = require'lspconfig' +local lsp_installer_servers = require'nvim-lsp-installer.servers' require("grammar-guard").init() vim.cmd[[packadd nvim-lspconfig]] @@ -50,87 +51,6 @@ local function on_attach(client, bufnr) end) end -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true -local default_config = { capabilities = capabilities, on_attach = on_attach } - -local lsps = { - -- Default configs - ccls = default_config, - als = default_config, - ghcide = default_config, - pylsp = default_config, - ocamllsp = default_config, - rnix = default_config, - - -- 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 = {}, - }, - }, - }, - 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" - - 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, - }, - }, - }, - } - end)() -} - -for lname,config in pairs(lsps) do - lsp[lname].setup(config) -end - --- texlab local function texlab_attach(client, bufnr) vim.lsp.protocol.SymbolKind = { 'file'; @@ -190,8 +110,109 @@ local function texlab_attach(client, bufnr) on_attach(client, bufnr) end -lsp.texlab.setup{ - cmd = {vim.fn.expand("$HOME") ..'/.cargo/bin/texlab'}, - on_attach = texlab_attach, +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true +local default_config = { capabilities = capabilities, on_attach = on_attach } + +local lsps = { + -- Default configs + ccls = default_config, + als = default_config, + ghcide = default_config, + pylsp = default_config, + ocamllsp = default_config, + rnix = default_config, + vimls = default_config, + + -- Special cases + rust_analyzer = { + capabilities = capabilities, + on_attach = on_attach, + cmd = {"rustup", "run", "nightly", "rust-analyzer"} + }, + sumneko_lua = (function() + return { + 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, + }, + }, + }, + } + end)(), + texlab = { + cmd = {vim.fn.expand("$HOME") ..'/.cargo/bin/texlab'}, + on_attach = texlab_attach, + } +} + +for lname,config in pairs(lsps) do + local server_available, requested_server = lsp_installer_servers.get_server(lname) + if server_available then + requested_server:on_ready(function () + local opts = {} + requested_server:setup(config) + end) + if not requested_server:is_installed() then + -- Queue the server to be installed + requested_server:install() + end + end +end + +local specials = { + grammar_guard = { + on_attach = on_attach, + capabilities = capabilities, + filetypes = { "latex", "tex", "bib", "markdown", "gitcommit" }, + on_init = function(client) + local langs = vim.opt.spellang:get() + if #langs > 0 then + client.config.settings.ltex.language = langs[0] + else + client.config.settings.ltex.language = "auto" + end + client.notify("workspace/didChangeConfiguration") + return true + end, + settings = { + ltex = { + enabled = { "latex", "tex", "bib", "markdown", }, + language = "auto", + diagnosticSeverity = "information", + setenceCacheSize = 2000, + additionalRules = { + enablePickyRules = true, + motherTongue = "fr", + }, + trace = { server = "verbose" }, + dictionary = {}, + disabledRules = {}, + hiddenFalsePositives = {}, + }, + }, + }, } +for lname,config in pairs(specials) do + lsp[lname].setup(config) +end diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -47,11 +47,11 @@ return require"packer".startup(function(use) use 'tpope/vim-surround' -- LSP related - use 'neovim/nvim-lspconfig' + use {'neovim/nvim-lspconfig', requires = "williamboman/nvim-lsp-installer"} use 'nvim-lua/lsp-status.nvim' use { "brymer-meneses/grammar-guard.nvim", - requires = "neovim/nvim-lspconfig" + requires = {"neovim/nvim-lspconfig", "williamboman/nvim-lsp-installer"} } -- Treesitter related diff --git a/templates/template.shell.nix b/templates/template.shell.nix @@ -0,0 +1,10 @@ +{ pkgs ? import <nixpkgs> {} }: +pkgs.mkShell { + name = "shell"; + buildInputs = [ + %{CURSOR} + ]; + shellHook = '' + echo "Entered" + ''; +}