diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore index abbe129..f995541 100644 --- a/.config/nvim/.gitignore +++ b/.config/nvim/.gitignore @@ -1,4 +1,8 @@ +lua/feline/feline-solarized.lua +lua/lspconfig/ltex.lua lua/plugins.lua lua/settings.lua lua/tangerine_vimrc.lua plugin/packer_compiled.lua + +**.spl diff --git a/.config/nvim/fnl/feline/feline-solarized.fnl b/.config/nvim/fnl/feline/feline-solarized.fnl new file mode 100644 index 0000000..77134e9 --- /dev/null +++ b/.config/nvim/fnl/feline/feline-solarized.fnl @@ -0,0 +1,15 @@ +(local colors (require :solarized.colors)) + +{:fg colors.fg + :bg colors.bg_alt + :black colors.black + :skyblue colors.paleblue + :cyan colors.cyan + :green colors.green + :oceanblue colors.blue + :magenta colors.magenta + :orange colors.orange + :red colors.red + :violet colors.purple + :white colors.white + :yellow colors.yellow} diff --git a/.config/nvim/fnl/lspconfig/ltex.fnl b/.config/nvim/fnl/lspconfig/ltex.fnl new file mode 100644 index 0000000..2f3d3dd --- /dev/null +++ b/.config/nvim/fnl/lspconfig/ltex.fnl @@ -0,0 +1,75 @@ +(import-macros {: exec : map!} :hibiscus.vim) + +(local M {}) + +(local files {:dictionary (.. (vim.fn.stdpath "config") "/spell/en.utf-8.add") + :disabledRules (.. (vim.fn.stdpath "config") "/spell/disable.txt") + :hiddenFalsePositives (.. (vim.fn.stdpath "config") "/spell/false.txt")}) + +(fn file_exists [file] (let [f (io.open file "rb")] + (match f nil (do (f.close f) false) + _ true))) + +(fn lines_from [file] (match (file_exists file) false [] + true (let [lines []] + (do (each [line (io.lines file)] + (table.insert lines line)) + lines)))) + +(fn get_client_by_name [name] (let [buf_clients (vim.lsp.buf_get_clients)] + (each [_ client (ipairs buf_clients)] + (match client.name name (lua "return client"))))) + +(fn update_config [lang configtype] (let [client (get_client_by_name "ltex")] + (if (not= client nil) + (if (not= (. client.config.settings.ltex configtype) nil) + (do (tset client.config.settings.ltex configtype {lang (lines_from (. files configtype))}) + (client.notify "workspace/didChangeConfiguration" client.config.settings)) + (vim.notify "Error when reading dictionary config, check it"))))) + +(fn add_to_file [configtype lang file value] (let [dict (lines_from file)] + (do (each [_ v (ipairs dict)] + (if (= v value) (lua "return nil"))) + (let [file (io.open file "a+")] + (if (not= file nil) + (do (file.write file (.. value "\n")) + (file.close file) + (update_config lang configtype)) + (vim.notify (string.format "Failed insert %s" value))))))) + +(fn do_command [arg configtype] (each [lang words (pairs arg)] + (each [_ word (ipairs words)] + (add_to_file configtype lang (. files configtype) word)))) + +(tset vim.lsp.commands "_ltex.addToDictionary" + (fn [command _] (do_command (. (. command.arguments 1) :words) "dictionary"))) +(tset vim.lsp.commands "_ltex.disableRules" + (fn [command _] (do_command (. (. command.arguments 1) :ruleIds) "disabledRules"))) +(tset vim.lsp.commands "_ltex.hideFalsePositives" + (fn [command _] (do_command (. (. command.arguments 1) :falsePositives) "hiddenFalsePositives"))) + +(fn post_attach [] (do (exec [[:setlocal "spell"] [:setlocal "nospell"]]) + (update_config "en-US" "dictionary") + (update_config "en-US" "disabledRules") + (update_config "en-US" "hiddenFalsePositives") + (map! [n :buffer :verbose] :zug (fn [] (do (exec [[:normal! "zug"]]) + (update_config "en-US" "dictionary") + nil)) + "Remove word from spellfile and update ltex") + (map! [n :buffer :verbose] :zg (fn [] (do (exec [[:normal! "zg"]]) + (update_config "en-US" "dictionary") + nil)) + "Add word to spellfile and update ltex") + nil)) + +(set M.setup (fn [opts] + ((. (. (require "lspconfig") "ltex") :setup) {:on_attach (fn [client] + (do (opts.on_attach client) (post_attach) nil)) + :capabilities opts.capabilities + :flags opts.flags + :settings {:ltex {:dictionary [] + :disabledRules [] + :hiddenFalsePositives []} + :additionalRules {:enablePickyRules true}}}))) + +M diff --git a/.config/nvim/lua/feline/feline-solarized.lua b/.config/nvim/lua/feline/feline-solarized.lua deleted file mode 100644 index a6c4263..0000000 --- a/.config/nvim/lua/feline/feline-solarized.lua +++ /dev/null @@ -1,19 +0,0 @@ -local colors = require('solarized.colors') - -local solarized = { - fg = colors.fg, - bg = colors.bg_alt, - black = colors.black, - skyblue = colors.paleblue, - cyan = colors.cyan, - green = colors.green, - oceanblue = colors.blue, - magenta = colors.magenta, - orange = colors.orange, - red = colors.red, - violet = colors.purple, - white = colors.white, - yellow = colors.yellow -} - -return solarized diff --git a/.config/nvim/lua/lspconfig/ltex.lua b/.config/nvim/lua/lspconfig/ltex.lua deleted file mode 100644 index 1128dcb..0000000 --- a/.config/nvim/lua/lspconfig/ltex.lua +++ /dev/null @@ -1,132 +0,0 @@ -local M = {} - -local files = { - dictionary = vim.fn.stdpath('config') .. '/spell/en.utf-8.add', - disabledRules = vim.fn.stdpath('config') .. '/spell/disable.txt', - hiddenFalsePositives = vim.fn.stdpath('config') .. '/spell/false.txt', -} - -local file_exists = function(file) - local f = io.open(file, 'rb') - if f then - f:close() - end - return f ~= nil -end - -local lines_from = function(file) - if not file_exists(file) then - return {} - end - local lines = {} - for line in io.lines(file) do - table.insert(lines, line) - end - return lines -end - -local get_client_by_name = function(name) - local buf_clients = vim.lsp.buf_get_clients() - for _, client in ipairs(buf_clients) do - if client.name == name then - return client - end - end - return nil -end - -local update_config = function(lang, configtype) - local client = get_client_by_name('ltex') - if client then - if client.config.settings.ltex[configtype] then - client.config.settings.ltex[configtype] = { - [lang] = lines_from(files[configtype]), - } - return client.notify('workspace/didChangeConfiguration', client.config.settings) - else - return vim.notify('Error when reading dictionary config, check it') - end - else - return nil - end -end - -local add_to_file = function(configtype, lang, file, value) - local dict = lines_from(file) - for _, v in ipairs(dict) do - if v == value then - return nil - end - end - file = io.open(file, 'a+') - if file then - file:write(value .. '\n') - file:close() - else - return vim.notify(string.format('Failed insert %s', value)) - end - return update_config(lang, configtype) -end - -local do_command = function(arg, configtype) - for lang, words in pairs(arg) do - for _, word in ipairs(words) do - add_to_file(configtype, lang, files[configtype], word) - end - end -end - -vim.lsp.commands['_ltex.addToDictionary'] = function(command, _) - do_command(command.arguments[1].words, 'dictionary') -end -vim.lsp.commands['_ltex.disableRules'] = function(command, _) - do_command(command.arguments[1].ruleIds, 'disabledRules') -end -vim.lsp.commands['_ltex.hideFalsePositives'] = function(command, _) - do_command(command.arguments[1].falsePositives, 'hiddenFalsePositives') -end - -local post_attach = function() - vim.cmd('setlocal spell') - vim.cmd('setlocal nospell') - update_config('en-US', 'dictionary') - update_config('en-US', 'disabledRules') - update_config('en-US', 'hiddenFalsePositives') - vim.keymap.set('n', 'zug', function() - vim.cmd('normal! zug') - update_config('en-US', 'dictionary') - end, { - buffer = true, - desc = 'Remove word from spellfile and update ltex', - }) - vim.keymap.set('n', 'zg', function() - vim.cmd('normal! zg') - update_config('en-US', 'dictionary') - end, { - buffer = true, - desc = 'Add word to spellfile and update ltex', - }) -end - -M.setup = function(opts) - require('lspconfig')['ltex'].setup { - on_attach = function(client) - opts.on_attach(client) - post_attach() - end, - capabilities = opts.capabilities, - flags = opts.flags, - settings = { - ltex = { - dictionary = {}, - disabledRules = {}, - hiddenFalsePositives = {}, - additionalRules = { - enablePickyRules = true, - }, - }, - }, - } -end - -return M diff --git a/.config/nvim/spell/en.utf-8.add b/.config/nvim/spell/en.utf-8.add index 2d6131f..fd50f5a 100644 --- a/.config/nvim/spell/en.utf-8.add +++ b/.config/nvim/spell/en.utf-8.add @@ -5,7 +5,6 @@ Interlisp JOHNNIAC REPLs Mathematica -DSLs GPLs Plasil Monto @@ -15,3 +14,6 @@ Asf Sdf ToolBus projectional +QL +DSLs +Coulon diff --git a/.config/nvim/spell/en.utf-8.add.spl b/.config/nvim/spell/en.utf-8.add.spl deleted file mode 100644 index 18e4ca7..0000000 Binary files a/.config/nvim/spell/en.utf-8.add.spl and /dev/null differ