diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 233d80b..ef5acd4 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -118,6 +118,9 @@ vim.g.mapleader = "," -- load general mapped keys require('style') +-- load dictionaries and helper functions +require('dictionaries') + -- load plugins (autoload all files in plugin folder) require('loadplugins') diff --git a/.config/nvim/lua/dictionaries.lua b/.config/nvim/lua/dictionaries.lua new file mode 100644 index 0000000..c40013c --- /dev/null +++ b/.config/nvim/lua/dictionaries.lua @@ -0,0 +1,47 @@ +-- local dictionary_base = vim.fn.getenv("XDG_CONFIG_HOME") .. "/nvim/lua/dictionaries/" +local dictionary_base = "/home/user/.config/nvim/lua/dictionaries/" + +local Dictionary_files = { + ["de-DE"] = {"dictionary_de-de.txt", "dictionary_names.txt"}, + ["en-US"] = {"dictionary_en-us.txt", "dictionary_names.txt"}, +} + +function GetDictFiles(lang) + local files = Dictionary_files[lang] + if files then + return files + else + return nil + end +end + +function ReadFiles(lang) + local files = GetDictFiles(lang) + local dict = {} + if files then + for _, file in ipairs(files) do + local f = assert(io.open(file, "r")) + if f then + for l in f:lines() do + table.insert(dict, l) + end + else + print("Can not read dict file %q", file) + end + end + else + print("Lang %q has no files", lang) + end + return dict +end + +for k,v in pairs(Dictionary_files) do + for a,b in pairs(v) do + Dictionary_files[k][a] = dictionary_base .. b + end +end + +Dictionaries = { + ["de-DE"] = ReadFiles("de-DE"), + ["en-US"] = ReadFiles("en-US"), +} diff --git a/.config/nvim/lua/dictionaries/dictionary_de-de.txt b/.config/nvim/lua/dictionaries/dictionary_de-de.txt new file mode 100644 index 0000000..64bb329 --- /dev/null +++ b/.config/nvim/lua/dictionaries/dictionary_de-de.txt @@ -0,0 +1,4 @@ +Bonitur +Königinnensubstanz +Magazinbeute +Pollenhose diff --git a/.config/nvim/lua/dictionaries/dictionary_en-us.txt b/.config/nvim/lua/dictionaries/dictionary_en-us.txt new file mode 100644 index 0000000..e69de29 diff --git a/.config/nvim/lua/dictionaries/dictionary_names.txt b/.config/nvim/lua/dictionaries/dictionary_names.txt new file mode 100644 index 0000000..f0188b6 --- /dev/null +++ b/.config/nvim/lua/dictionaries/dictionary_names.txt @@ -0,0 +1,3 @@ +Akallabêth +Edain +Númenor diff --git a/.config/nvim/lua/plugins/nvim-lspconfig.lua b/.config/nvim/lua/plugins/nvim-lspconfig.lua index 410deac..d98317d 100644 --- a/.config/nvim/lua/plugins/nvim-lspconfig.lua +++ b/.config/nvim/lua/plugins/nvim-lspconfig.lua @@ -38,6 +38,7 @@ return { "yamlls", } }) + local servers = { lua_ls = { Lua = { @@ -46,6 +47,13 @@ return { }, telemetry = { enable = false }, }, + }, + ltex = { + ltex = { + -- language = "de-DE", + enabled = { "latex" }, + dictionary = Dictionaries, + } } } local default = { __index = function() return {} end }