Add ltex and mapping to add a word to dictionnary

main
antoine.lenours 2025-06-06 16:12:32 +02:00
parent 128996be26
commit c534eaa294
5 changed files with 68 additions and 17 deletions

View File

@ -16,6 +16,34 @@ for _, lsp in ipairs(servers) do
} }
end end
local ltex_dict_path = vim.fn.getcwd() .. "/.ltexwords"
-- Vérifie si le fichier existe
local dictionary_words = {"gls", "clearpage", "ldap"}
if vim.fn.filereadable(ltex_dict_path) == 1 then
for line in io.lines(ltex_dict_path) do
table.insert(dictionary_words, line)
end
end
lspconfig.ltex.setup({
settings = {
ltex = {
language = "fr",
dictionary = {
["fr"] = dictionary_words,
},
},
},
filetypes = { "markdown", "tex", "text" },
})
-- lspconfig.harper_ls.setup({
-- on_attach = nvlsp.on_attach,
-- on_init = nvlsp.on_init,
-- capabilities = nvlsp.capabilities,
-- })
-- configuring single server, example: typescript -- configuring single server, example: typescript
-- lspconfig.ts_ls.setup { -- lspconfig.ts_ls.setup {
-- on_attach = nvlsp.on_attach, -- on_attach = nvlsp.on_attach,

View File

@ -1,10 +1,10 @@
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown", pattern = "markdown",
callback = function() callback = function()
vim.opt_local.textwidth = 60 -- soft wrap guide vim.opt_local.textwidth = 120 -- soft wrap guide
vim.opt_local.wrap = true -- enable visual wrapping vim.opt_local.wrap = true -- enable visual wrapping
vim.opt_local.linebreak = true -- wrap at word boundaries vim.opt_local.linebreak = true -- wrap at word boundaries
vim.opt_local.spell = true -- optional: spell check -- vim.opt_local.spell = true -- optional: spell check
vim.opt_local.spelllang = "fr" -- optional: French spell check vim.opt_local.spelllang = "fr" -- optional: French spell check
end, end,
}) })

View File

@ -8,3 +8,40 @@ map("n", ";", ":", { desc = "CMD enter command mode" })
map("i", "jk", "<ESC>") map("i", "jk", "<ESC>")
-- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>") -- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>")
-- spell add word
local word_collection_file = vim.fn.getcwd() .. "/.ltexwords"
local function add_current_word_to_collection()
local word = vim.fn.expand("<cword>") -- Get the word under the cursor
if word == "" or word == nil then
vim.notify("No word under cursor.", vim.log.levels.WARN)
return
end
local escaped_word = vim.fn.shellescape(word)
local escaped_filepath = vim.fn.shellescape(word_collection_file)
local cmd = string.format("echo %s >> %s", escaped_word, escaped_filepath)
vim.fn.system(cmd)
if vim.v.shell_error == 0 then
vim.notify(string.format("'%s' added to %s", word, word_collection_file), vim.log.levels.INFO)
else
vim.notify(
string.format("Error adding '%s' to %s. Shell error: %d", word, word_collection_file, vim.v.shell_error),
vim.log.levels.ERROR
)
end
end
-- Vérifie si le fichier existe
if vim.fn.filereadable(word_collection_file) == 1 then
map("n", "aw", add_current_word_to_collection)
end

View File

@ -1,18 +1,3 @@
require "nvchad.options" require "nvchad.options"
vim.opt.spelllang = {"fr"}
vim.opt.spell = true
vim.textwidth = 80
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
vim.opt_local.textwidth = 80 -- set line wrap at 60 characters
vim.opt_local.wrap = true -- enable visual line wrapping
vim.opt_local.linebreak = true -- wrap at word boundaries
end,
})
-- add yours here!
-- local o = vim.o
-- o.cursorlineopt ='both' -- to enable cursorline!

View File

@ -31,6 +31,7 @@ return {
"tailwindcss-language-server", "tailwindcss-language-server",
"prettierd", "prettierd",
"eslint-lsp", "eslint-lsp",
"ltex-ls",
} }
} }
}, },