LTeX
language server provides some code actions off the LSP specifications.
These commands require client implementations for things like file system
operations.
LTeX_extra
is a companion plugin for LTeX
language server that provides
such implementations for Neovim. The current supported methods are:
addToDictionary
,
disableRule
,
hideFalsePositive
.
Warning
The following demos may contain orthographic horrors.
Add word to dictionary, Hide false positive, and Disable rule
01-CodeAction.mp4
Give you compatibility with official vscode extension, and flexibility to do things like global dictionaries.
02-CustomPath.mp4
Load ltex files on server start.
03-Autoload.mp4
🚧 This plugin will be rewritten and as consequence I want to support just one method to initialize the plugin. The chosen one probably will be based on the LspAttach autocommand. I won't support the server initialization through this plugin anymore. It was a bad decision, doesn't provide much value and is hard to maintain.
This plugin requires an instance of ltex_ls
language server available to attach.
ltex-ls
is available at mason.nvim
.
Install the plugin with your favorite plugin manager using {"barreiroleo/ltex-extra.nvim"}
.
Then add require("ltex_extra").setup()
to your config.
There are two recommended methods:
-
Call the
setup
fromon_attach
function of your server. Example withlspconfig
, minor changes are required formason
handler:lua require("lspconfig").ltex.setup { capabilities = your_capabilities, on_attach = function(client, bufnr) -- rest of your on_attach process. require("ltex_extra").setup { your_opts } end, settings = { ltex = { your settings } } }
-
Use the handler which
ltex_extra
provide to call the server. Example of use withlazy.nvim
:return { "barreiroleo/ltex_extra.nvim", ft = { "markdown", "tex" }, dependencies = { "neovim/nvim-lspconfig" }, -- yes, you can use the opts field, just I'm showing the setup explicitly config = function() require("ltex_extra").setup { your_ltex_extra_opts, server_opts = { capabilities = your_capabilities, on_attach = function(client, bufnr) -- your on_attach process end, settings = { ltex = { your settings } } }, } end }
Here are the settings available on ltex_extra
. You don't need explicit define each
one, just modify what you need.
Notes: You can pass to setup
the arguments that you are interested in and omit the rest.
At the moment, if you have dictionary
, disabledRules
and
hiddenFalsePositives
defined in your ltex
settings, they aren't backed up.
require("ltex_extra").setup {
-- table <string> : languages for witch dictionaries will be loaded, e.g. { "es-AR", "en-US" }
-- https://valentjn.github.io/ltex/supported-languages.html#natural-languages
load_langs = { "en-US" } -- en-US as default
-- boolean : whether to load dictionaries on startup
init_check = true,
-- string : relative or absolute path to store dictionaries
-- e.g. subfolder in the project root or the current working directory: ".ltex"
-- e.g. shared files for all projects: vim.fn.expand("~") .. "/.local/share/ltex"
path = "", -- project root or current working directory
-- string : "none", "trace", "debug", "info", "warn", "error", "fatal"
log_level = "none",
-- table : configurations of the ltex language server.
-- Only if you are calling the server from ltex_extra
server_opts = nil
}
If you experience hangs with the server/plugin, you can force a reload of
the LTeX files by running require("ltex_extra").reload()
04-Update.mp4
Some users of lspsaga has reported issues with code actions. I don't use lspsaga, so PRs are welcome. Just make sure to test without that plugin enabled as well.
Screen.Recording.2022-11-13.at.12.49.54.mov
Thanks to @felipejoribeiro for the screen recording
Thanks to these people for your time, effort and ideas.