From 73c1389435e9e57e1887d749dfd7440f6967601d Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Tue, 18 Apr 2023 15:55:03 +0200 Subject: [PATCH] neovim: Add LanguageTool language server --- users/simon/modules/git.nix | 5 ++++ users/simon/modules/neovim/default.nix | 1 + users/simon/modules/neovim/init.lua | 41 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/users/simon/modules/git.nix b/users/simon/modules/git.nix index fbb8433..fedff33 100644 --- a/users/simon/modules/git.nix +++ b/users/simon/modules/git.nix @@ -11,6 +11,11 @@ }; extraConfig = { + # Make LTeX not check anything below this. + # I often use git commit -v, which adds a full diff that should not be checked. + commit.template = toString (pkgs.writeText "git-commit-template" '' + + # LTeX: enabled=false''); core.quotepath = "off"; pull.ff = "only"; diff = { diff --git a/users/simon/modules/neovim/default.nix b/users/simon/modules/neovim/default.nix index 6e8d389..4ae7117 100644 --- a/users/simon/modules/neovim/default.nix +++ b/users/simon/modules/neovim/default.nix @@ -48,6 +48,7 @@ in gopls haskell-language-server jdt-language-server + unstable.ltex-ls rnix-lsp rust-analyzer (python3.withPackages (ps: with ps; [ diff --git a/users/simon/modules/neovim/init.lua b/users/simon/modules/neovim/init.lua index a604f91..ac25cd1 100644 --- a/users/simon/modules/neovim/init.lua +++ b/users/simon/modules/neovim/init.lua @@ -290,6 +290,47 @@ lsp.jdtls.setup { on_attach = on_attach, cmd = {'jdt-language-server', '-configuration', '/home/simon/.cache/jdtls/config', '-data', '/home/simon/.cache/jdtls/workspace'}, -- copied from upstream, but changed executable name } +lsp.ltex.setup { + on_attach = on_attach, + settings = { + ltex = { + language = 'en-GB', + languageToolHttpServerUri = 'https://languagetool.sbruder.de/', + }, + }, + -- both taken from upstream, extended + filetypes = { + 'bib', + 'gitcommit', + 'mail', + 'markdown', + 'org', + 'plaintex', + 'rst', + 'rnoweb', + 'tex', + 'pandoc' + }, + get_language_id = function(_, filetype) + local language_id_mapping = { + bib = 'bibtex', + gitcommit = 'git-commit', + mail = 'markdown', -- quite wrong, but allows magic commands + pandoc = 'markdown', + plaintex = 'tex', + rnoweb = 'sweave', + rst = 'restructuredtext', + tex = 'latex', + xhtml = 'xhtml', + } + local language_id = language_id_mapping[filetype] + if language_id then + return language_id + else + return filetype + end + end, +} lsp.pylsp.setup { on_attach = on_attach, }