PaysanCorrezien / ltex_extra.nvim

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LTeX_extra.nvim

Provides external LTeX file handling (off-spec lsp) and other functions.
🚧 This plugin is on development, expect some changes
Developed on Nvim v0.9, tested on v0.10

Lua Work In Progress Neovim

LTeX_extra is a plugin for Neovim that provide the functions that are called on LSP code actions by ltex-ls: addToDictionary, disableRule, hideFalsePositive. Also, LTeX_extra provide extra features.

Table of Contents

Features

Cover your eyes. In the next demos there are many orthographic horrors. Screencast recorded using my macros tool.

Code Actions

Provide functions for add to dictionary, disable rules and hidde false positives.
Maybe you want mapping the LPS Code Action method. Check the docs: neovim suggested configuration

01-CodeAction.mp4

Custom export path

Config you path, give you compatibility with official vscode extension.

02-CustomPath.mp4

Autoload exported data

Autoload exported data for required languages.

03-Autoload.mp4

Update on demand

Reload exported data on demand: require("ltex_extra").reload()

04-Update.mp4

Installation

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 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
}

Contributors

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

Issues

  • Lspsaga:

    Some users reported an issue with code actions when called from lspsaga. I'm not using lspsaga, so PR are very welcome.

    Screen.Recording.2022-11-13.at.12.49.54.mov

    Thanks to @felipejoribeiro for the screenrecording

About

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

License:GNU General Public License v3.0


Languages

Language:Lua 96.1%Language:TeX 3.9%