Coder Social home page Coder Social logo

ltex-ls.nvim's Introduction

ltex-ls.nvim

Enhanced integration of ltex-ls for neovim.

Features:

  • Integration with nvim options:
    • spellfile
  • Working code-actions for:
    • Add to dictionnary
    • Disable rule
    • Hide false positive
  • External files support
  • See TODO section for the planned work

Installation

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.

Usage

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 buffer
  • LtexClearCache: 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 debugging

For 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)(),
    },
  },
}

TODOs

  • Integrate spelllang into ltex.language
  • Integrate spellfile into ltex.dictionnary
  • Support custom commands
    • _ltex.addToDictionary
    • _ltex.disableRules
    • _ltex.hideFalsePositives
    • _ltex.checkDocument
      • Expose with :LtexCheckDocument
    • _ltex.getServerStatus
      • Expose :LtexServerStatus
  • Workspace configuration with ltex/workspaceSpecificConfiguration
  • Allow to clear the cache

ltex-ls.nvim's People

Contributors

vigoux avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.