diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index e0aed57..4a3f5a1 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -16,6 +16,34 @@ for _, lsp in ipairs(servers) do } 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 -- lspconfig.ts_ls.setup { -- on_attach = nvlsp.on_attach, diff --git a/lua/custom/filetype.lua b/lua/custom/filetype.lua index 2ed4822..1a3d0df 100644 --- a/lua/custom/filetype.lua +++ b/lua/custom/filetype.lua @@ -1,10 +1,10 @@ vim.api.nvim_create_autocmd("FileType", { pattern = "markdown", 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.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 end, }) diff --git a/lua/mappings.lua b/lua/mappings.lua index 783b78f..3bde7cd 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -8,3 +8,40 @@ map("n", ";", ":", { desc = "CMD enter command mode" }) map("i", "jk", "") -- map({ "n", "i", "v" }, "", " w ") + +-- spell add word + + +local word_collection_file = vim.fn.getcwd() .. "/.ltexwords" +local function add_current_word_to_collection() + local word = vim.fn.expand("") -- 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 + + diff --git a/lua/options.lua b/lua/options.lua index c9d1e42..6ed87fa 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -1,18 +1,3 @@ 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! diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index f05d2c7..955af10 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -31,6 +31,7 @@ return { "tailwindcss-language-server", "prettierd", "eslint-lsp", + "ltex-ls", } } },