vigoux / ltex-ls.nvim

Enhanced integration of ltex-ls for neovim
BSD 2-Clause "Simplified" License
55 stars 7 forks source link

ltex-ls.nvim

Enhanced integration of ltex-ls for neovim.

Features:

Installation

Install this plugin using your favorite package manager. Remember that this plugin requires using nvim-lspconfig.


-- ltex-ls works without nvim-lspconfig
use { 'vigoux/ltex-ls.nvim' }

-- If you want to use nvim-lspconfig
use { 'vigoux/ltex-ls.nvim', requires = 'neovim/nvim-lspconfig' }

Note the the same feature set is provided with and without lspconfig, so I'd advise not specifying this dependency.

Usage

As this plugin is a wrapper around lspconfig here how to run it:

require'ltex-ls'.setup {
  use_spellfile = false, -- Uses the value of 'spellfile' as an external file when checking the document
  window_border = 'single', -- How the border should be rendered
  -- Put your lsp config here, just like with nvim-lspconfig
}

The plugin exposes multiple commands to help to interact with the server:

For example (with my own config):

require 'ltex-ls'.setup {
  on_attach = on_attach,
  capabilities = capabilities,
  use_spellfile = false,
  filetypes = { "latex", "tex", "bib", "markdown", "gitcommit", "text" },
  settings = {
    ltex = {
      enabled = { "latex", "tex", "bib", "markdown", },
      language = "auto",
      diagnosticSeverity = "information",
      sentenceCacheSize = 2000,
      additionalRules = {
        enablePickyRules = true,
        motherTongue = "fr",
      },
      disabledRules = {
        fr = { "APOS_TYP", "FRENCH_WHITESPACE" }
      },
      dictionary = (function()
        -- For dictionary, search for files in the runtime to have
        -- and include them as externals the format for them is
        -- dict/{LANG}.txt
        --
        -- Also add dict/default.txt to all of them
        local files = {}
        for _, file in ipairs(vim.api.nvim_get_runtime_file("dict/*", true)) do
          local lang = vim.fn.fnamemodify(file, ":t:r")
          local fullpath = vim.fs.normalize(file, ":p")
          files[lang] = { ":" .. fullpath }
        end

        if files.default then
          for lang, _ in pairs(files) do
            if lang ~= "default" then
              vim.list_extend(files[lang], files.default)
            end
          end
          files.default = nil
        end
        return files
      end)(),
    },
  },
}

TODOs