Skip to content

Provides external LTeX file handling (off-spec lsp) and other functions.

License

Notifications You must be signed in to change notification settings

barreiroleo/ltex_extra.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚧 Dev branch will be merged soon. Please take a look at the Deprecations notes in dev branch.

LTeX_extra.nvim

Provides implementations for non-LSP LTeX commands.
Developed and tested in Nightly. It's not required for you

Lua Work In Progress Neovim

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.

Features

Warning

The following demos may contain orthographic horrors.

Code Actions

Add word to dictionary, Hide false positive, and Disable rule

01-CodeAction.mp4

Custom Export Path

Give you compatibility with official vscode extension, and flexibility to do things like global dictionaries.

02-CustomPath.mp4

Load on Start

Load ltex files on server start.

03-Autoload.mp4

Installation

🚧 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:

  1. Call the setup from on_attach function of your server. Example with lspconfig, minor changes are required for mason 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 } } }

  2. Use the handler which ltex_extra provide to call the server. Example of use with lazy.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
    }

Configuration

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
}

FAQ

Force reload

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

Lspsaga:

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

Contributors

Thanks to these people for your time, effort and ideas.