Comments (9)
ltex_extra.nvim provide code actions for add to dictionary
, disable rules
and hidde false positives
under NeoVim.
from ltex-ls.
I use this workaround, you can add words to your normal Neovim spelling directory and ltex-ls will use them. Not perfect, but works!
-- add vim user dictionary for ltex-ls
local path = vim.fn.stdpath 'config' .. '/spell/en.utf-8.add'
local words = {}
for word in io.open(path, 'r'):lines() do
table.insert(words, word)
end
lspconfig.ltex.setup {
on_attach = on_attach,
settings = {
ltex = {
dictionary = {
['en-US'] = words,
['en-GB'] = words,
},
},
},
}
from ltex-ls.
Based on the work-around @David-Else provided in the comment above, I added a local dictionary capability. The VS Code extension version creates ltex.dictionary.en-US.txt
file under .vscode/
directory and adds the word to this text file, by default, when add-to-dictionary option is selected in VS Code. Based on this behavior, I come up with the following solution. The code snippet vim.fn.expand("%:p:h")
gets the absolute path of the Neovim buffer, so the provided solution looks for a .vscode/ltex.dictionary.en-US.txt
hierarchy in the same directory. Then, the lines in both global user dictionary and local dictionary are utilized if these paths are valid. You can change/add different paths as well. One of the caveats is that the provided solution is not dynamic as in the VS Code extension, i.e., if you update the dictionary .txt
file, you need to restart Neovim. This problem can be prevented by defining an autocmd
to revaluate the table of words.
local paths = {
vim.fn.stdpath("config") .. "/spell/ltex.dictionary.en-US.txt",
vim.fn.expand("%:p:h") .. "/.vscode/ltex.dictionary.en-US.txt",
}
local words = {}
for _, path in ipairs(paths) do
local f = io.open(path)
if f then
for word in f:lines() do
table.insert(words, word)
end
f:close()
end
end
lspconfig.ltex.setup {
on_attach = on_attach,
settings = {
ltex = {
dictionary = {
['en-US'] = words,
['en-GB'] = words,
},
},
},
}
from ltex-ls.
See #171
from ltex-ls.
At this point code actions need to be added into Neovim it seems: neovim/nvim-lspconfig#863 , I don't know if that can be addressed by ltex-ls
or not?
grammar-guard.nvim seems dead, it would be great if someone could continue the work and merge some functionality into https://github.com/neovim/nvim-lspconfig
from ltex-ls.
Thanks for the feedback. I tried to follow the different threads but must say that I'm not sure I understand the state of everything atm.
Good point. As it seems that the code actions making a change in the document itself work, but not the ones that try to make a change in the config file, could it be related to the fact that ltex-ls
doesn't seem to be able to dynamically update a local dictionary?
I am sorry if it actually can and I'm just talking nonsense...
from ltex-ls.
Well actually it's a pretty nice way of using built-in neovim capabilities, thanks!
Hopefully the other code actions will be available soon. Should I already close the issue then?
from ltex-ls.
Based on David-Else's work around, I added the following configuration to LunarVim and it works.
local dictionary_file_path = os.getenv "LUNARVIM_CONFIG_DIR" .. "/spell/en.utf-8.add"
local words = {}
for word in io.lines(dictionary_file_path) do
table.insert(words, word)
end
local ltex_opts = {
settings = {
ltex = {
dictionary = {
["en-US"] = words
},
}
}
}
require("lvim.lsp.manager").setup("ltex", ltex_opts)
I use the environment variable LUNARVIM_CONFIG_DIR
instead of vim.fn.stdpath 'config'
,
since the latter returns ~/.config/nvim
instead of ~/.config/lvim
under LunarVim.
from ltex-ls.
There is vigoux/ltex-ls.nvim as well, with similar features.
from ltex-ls.
Related Issues (20)
- Support additional LaTeX commands and environments in ltex-ls
- Can not add words to dictionary
- Some way to change buffer's language.
- Build for BSD HOT 1
- Can we read credentials from a file?
- Allow only linting comments matching a pattern, e.g. `//!` and `///` in rust instead of `//`
- Sending workspace/configuration requests to client without capability
- Checking "!}" or "?}" with LanguageTool premium server in French.
- Version 16.0.0 doesn't work with PASSIVE_VOICE
- What is the default value of `LTEX_GLOBAL_STORAGE_PATH`? HOT 3
- language selection via \documentclass[german]{article} and similar
- ltex with html: Within source tag no html check
- Markdown inline footnotes
- `JAVA_HOME is not defined correctly`
- Add text (.txt) files support
- Linux binary archive changes destination owner when extracted
- restructuredText ltex.hiddenFalsePositive HOT 1
- High memory usage
- StringIndexOutOfBoundsException
- How to set Ltex language in vim
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ltex-ls.