Skip to content

barreiroleo/ltex_extra.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚧 This plugin will be rewritten, I'll do my best to maintain the specs but expect some changes

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

On start load

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 in a proper place.

We suggest to you two ways:

  • Call the setup from on_attach function of your server. Example with lspconfig, minor changes are required for mason handler:

    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 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 set up only the arguments that you are interested in. At the moment, if you define stuff in dictionary, disabledRules and hiddenFalsePositives in your ltex settings, they haven't backup.

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 experiment some 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 not use lspsaga, so PRs are very 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 screenrecording

Contributors

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