[NeoVim] Fennel More
This commit is contained in:
4
.config/nvim/.gitignore
vendored
4
.config/nvim/.gitignore
vendored
@@ -1,4 +1,8 @@
|
|||||||
|
lua/feline/feline-solarized.lua
|
||||||
|
lua/lspconfig/ltex.lua
|
||||||
lua/plugins.lua
|
lua/plugins.lua
|
||||||
lua/settings.lua
|
lua/settings.lua
|
||||||
lua/tangerine_vimrc.lua
|
lua/tangerine_vimrc.lua
|
||||||
plugin/packer_compiled.lua
|
plugin/packer_compiled.lua
|
||||||
|
|
||||||
|
**.spl
|
||||||
|
|||||||
15
.config/nvim/fnl/feline/feline-solarized.fnl
Normal file
15
.config/nvim/fnl/feline/feline-solarized.fnl
Normal file
@@ -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}
|
||||||
75
.config/nvim/fnl/lspconfig/ltex.fnl
Normal file
75
.config/nvim/fnl/lspconfig/ltex.fnl
Normal file
@@ -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
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -5,7 +5,6 @@ Interlisp
|
|||||||
JOHNNIAC
|
JOHNNIAC
|
||||||
REPLs
|
REPLs
|
||||||
Mathematica
|
Mathematica
|
||||||
DSLs
|
|
||||||
GPLs
|
GPLs
|
||||||
Plasil
|
Plasil
|
||||||
Monto
|
Monto
|
||||||
@@ -15,3 +14,6 @@ Asf
|
|||||||
Sdf
|
Sdf
|
||||||
ToolBus
|
ToolBus
|
||||||
projectional
|
projectional
|
||||||
|
QL
|
||||||
|
DSLs
|
||||||
|
Coulon
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user