aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorMateusz Majewski <metiulekm@gmail.com>2024-01-31 07:10:51 +0100
committerGitHub <noreply@github.com>2024-01-31 14:10:51 +0800
commit4f34f6f48d14caf8ae58a4e83fa4f20e5ccd553b (patch)
treea242e2cc491eab0a87ef825897257ba0e919e38e /lua
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-4f34f6f48d14caf8ae58a4e83fa4f20e5ccd553b.tar
nvim-lspconfig-4f34f6f48d14caf8ae58a4e83fa4f20e5ccd553b.tar.gz
nvim-lspconfig-4f34f6f48d14caf8ae58a4e83fa4f20e5ccd553b.tar.bz2
nvim-lspconfig-4f34f6f48d14caf8ae58a4e83fa4f20e5ccd553b.tar.lz
nvim-lspconfig-4f34f6f48d14caf8ae58a4e83fa4f20e5ccd553b.tar.xz
nvim-lspconfig-4f34f6f48d14caf8ae58a4e83fa4f20e5ccd553b.tar.zst
nvim-lspconfig-4f34f6f48d14caf8ae58a4e83fa4f20e5ccd553b.zip
feat(ltex): imrove default settings(#2979)
* fix(ltex): fix rnoweb support Unfortunately language code `sweave` will not be understood by LTeX and `rsweave` must be used, as can be seen in the source code here: https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/parsing/CodeFragmentizer.kt#L61 and here: https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/settings/Settings.kt#L185 LTeX will fall back to plaintext, but this will emit a warning and provide slightly worse suggestions. * fix(ltex): disable unnecessary xhtml mapping This mapping does not do anything, the `get_language_id` function will just return `xhtml` by default. * feat(ltex): add plaintext mapping LTeX will only understand `plaintext`: https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/parsing/CodeFragmentizer.kt#L70 though it will fall back to plain text when provided `text` as mapping, but will output a warning when doing so. Note that we do not enable the `text` filetype by default, as LTeX itself does not do so. However, this filetype will not be useable without this mapping anyway, so doing this makes using enabling this manually slightly easier. * fix(ltex): set ltex.enabled LTeX is launched whenever the filetype is on the preset list, but will then verify the language ID against its list and will refuse to run if the language ID is not on the list. The default can be seen in https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/settings/Settings.kt#L175 and somewhat matches the supported markup languages list. The issue resolved by this commit comes from the fact that LTeX will accept several aliases for each language, for instance it will handle `gitcommit` and `git-commit` the same way. However, only `git-commit` appears on the default enabled list. Since there is no `gitcommit -> git-commit` mapping in `language_id_mapping`, LTeX will ignore `gitcommit`. This could also be solved by adding this mapping, however setting a default value of `ltex.enabled` has smaller change of breaking existing configuration. Same situation happens for `xhtml`. * feat(ltex): enable in context, html and xhtml filetypes ConTeXt was requested in #2663. LTeX is documented to enable it by default, but this is not consistent with the default in the code: https://github.com/valentjn/ltex-ls/blob/16.0.0/src/main/kotlin/org/bsplines/ltexls/settings/Settings.kt#L175 Regardless of this we will enable it by ourselves anyway. We also enable HTML and XHTML as there already has been an attempt to enable them previously, as there has been a mapping for `xhtml` in the `language_id_mapping` array. HTML support is enabled in LTeX by default anyway.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/server_configurations/ltex.lua57
1 files changed, 46 insertions, 11 deletions
diff --git a/lua/lspconfig/server_configurations/ltex.lua b/lua/lspconfig/server_configurations/ltex.lua
index b1291ede..fef23a64 100644
--- a/lua/lspconfig/server_configurations/ltex.lua
+++ b/lua/lspconfig/server_configurations/ltex.lua
@@ -3,11 +3,11 @@ local util = require 'lspconfig.util'
local language_id_mapping = {
bib = 'bibtex',
plaintex = 'tex',
- rnoweb = 'sweave',
+ rnoweb = 'rsweave',
rst = 'restructuredtext',
tex = 'latex',
- xhtml = 'xhtml',
pandoc = 'markdown',
+ text = 'plaintext',
}
local bin_name = 'ltex-ls'
@@ -15,20 +15,55 @@ if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.bat'
end
+local filetypes = {
+ 'bib',
+ 'gitcommit',
+ 'markdown',
+ 'org',
+ 'plaintex',
+ 'rst',
+ 'rnoweb',
+ 'tex',
+ 'pandoc',
+ 'quarto',
+ 'rmd',
+ 'context',
+ 'html',
+ 'xhtml',
+}
+
+local function get_language_id(_, filetype)
+ local language_id = language_id_mapping[filetype]
+ if language_id then
+ return language_id
+ else
+ return filetype
+ end
+end
+local enabled_ids = {}
+do
+ local enabled_keys = {}
+ for _, ft in ipairs(filetypes) do
+ local id = get_language_id({}, ft)
+ if not enabled_keys[id] then
+ enabled_keys[id] = true
+ table.insert(enabled_ids, id)
+ end
+ end
+end
+
return {
default_config = {
cmd = { bin_name },
- filetypes = { 'bib', 'gitcommit', 'markdown', 'org', 'plaintex', 'rst', 'rnoweb', 'tex', 'pandoc', 'quarto', 'rmd' },
+ filetypes = filetypes,
root_dir = util.find_git_ancestor,
single_file_support = true,
- get_language_id = function(_, filetype)
- local language_id = language_id_mapping[filetype]
- if language_id then
- return language_id
- else
- return filetype
- end
- end,
+ get_language_id = get_language_id,
+ settings = {
+ ltex = {
+ enabled = enabled_ids,
+ },
+ },
},
docs = {
description = [=[