Enhanced integration of ltex-ls
for neovim.
Features:
nvim
options:
spellfile
Add to dictionnary
Disable rule
Hide false positive
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.
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:
LtexCheckDocument
: checks the current bufferLtexClearCache
: using a simple ui, clears parts of or all the
local config[range]LtexDisableHere
: disables ltex for this range of text.LtexServerStatus
: very simple status report of the server, useful
for debuggingFor 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)(),
},
},
}
spelllang
into ltex.language
spellfile
into ltex.dictionnary
_ltex.addToDictionary
_ltex.disableRules
_ltex.hideFalsePositives
_ltex.checkDocument
:LtexCheckDocument
_ltex.getServerStatus
:LtexServerStatus
ltex/workspaceSpecificConfiguration