[NeoVim] The world is now Fennel
This commit is contained in:
6
.config/nvim/.gitignore
vendored
6
.config/nvim/.gitignore
vendored
@@ -1,8 +1,4 @@
|
|||||||
lua/feline/feline-solarized.lua
|
lua/**
|
||||||
lua/lspconfig/ltex.lua
|
|
||||||
lua/plugins.lua
|
|
||||||
lua/settings.lua
|
|
||||||
lua/tangerine_vimrc.lua
|
|
||||||
plugin/packer_compiled.lua
|
plugin/packer_compiled.lua
|
||||||
|
|
||||||
**.spl
|
**.spl
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
(match client.name name (lua "return client")))))
|
(match client.name name (lua "return client")))))
|
||||||
|
|
||||||
(fn update_config [lang configtype] (let [client (get_client_by_name "ltex")]
|
(fn update_config [lang configtype] (let [client (get_client_by_name "ltex")]
|
||||||
(if (not= client nil)
|
(if client
|
||||||
(if (not= (. client.config.settings.ltex configtype) nil)
|
(if (. client.config.settings.ltex configtype)
|
||||||
(do (tset client.config.settings.ltex configtype {lang (lines_from (. files configtype))})
|
(do (tset client.config.settings.ltex configtype {lang (lines_from (. files configtype))})
|
||||||
(client.notify "workspace/didChangeConfiguration" client.config.settings))
|
(client.notify "workspace/didChangeConfiguration" client.config.settings))
|
||||||
(vim.notify "Error when reading dictionary config, check it")))))
|
(vim.notify "Error when reading dictionary config, check it")))))
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
(do (each [_ v (ipairs dict)]
|
(do (each [_ v (ipairs dict)]
|
||||||
(if (= v value) (lua "return nil")))
|
(if (= v value) (lua "return nil")))
|
||||||
(let [file (io.open file "a+")]
|
(let [file (io.open file "a+")]
|
||||||
(if (not= file nil)
|
(if file
|
||||||
(do (file.write file (.. value "\n"))
|
(do (file.write file (.. value "\n"))
|
||||||
(file.close file)
|
(file.close file)
|
||||||
(update_config lang configtype))
|
(update_config lang configtype))
|
||||||
|
|||||||
71
.config/nvim/fnl/lspconfig/settings.fnl
Normal file
71
.config/nvim/fnl/lspconfig/settings.fnl
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
(import-macros {: map!} :hibiscus.vim)
|
||||||
|
(import-macros {: setup} :macros)
|
||||||
|
|
||||||
|
(local servers [:pyright :sumneko_lua :eslint :tsserver :ltex])
|
||||||
|
|
||||||
|
; Mappings.
|
||||||
|
(map! [n :noremap] "<space>e" vim.diagnostic.open_float)
|
||||||
|
(map! [n :noremap] "[d" vim.diagnostic.goto_prev)
|
||||||
|
(map! [n :noremap] "]d" vim.diagnostic.goto_next)
|
||||||
|
(map! [n :noremap] "<space>q" vim.diagnostic.setloclist)
|
||||||
|
|
||||||
|
(fn on_attach [_ bufnr]
|
||||||
|
(do (map! [n :noremap :buffer] :gD vim.lsp.buf.declaration)
|
||||||
|
(map! [n :noremap :buffer] :gd vim.lsp.buf.definition)
|
||||||
|
(map! [n :noremap :buffer] :K vim.lsp.buf.hover)
|
||||||
|
(map! [n :noremap :buffer] :gi vim.lsp.buf.implementation)
|
||||||
|
(map! [n :noremap :buffer] :<C-k> vim.lsp.buf.signature_help)
|
||||||
|
(map! [n :noremap :buffer] :<space>wa vim.lsp.buf.add_workspace_folder)
|
||||||
|
(map! [n :noremap :buffer] :<space>wr vim.lsp.buf.remove_workspace_folder)
|
||||||
|
(map! [n :noremap :buffer] :<space>wl (fn [] (print (vim.inspect (vim.lsp.buf.list_workspace_folders)))))
|
||||||
|
(map! [n :noremap :buffer] :<space>D vim.lsp.buf.type_definition)
|
||||||
|
(map! [n :noremap :buffer] :<space>rn vim.lsp.buf.rename)
|
||||||
|
(map! [n :noremap :buffer] :<space>ca vim.lsp.buf.code_action)
|
||||||
|
(map! [n :noremap :buffer] :gr vim.lsp.buf.references)
|
||||||
|
(map! [n :noremap :buffer] :<space>f vim.lsp.buf.formatting)))
|
||||||
|
|
||||||
|
(local capabilities ((. (require :cmp_nvim_lsp) :update_capabilities) (vim.lsp.protocol.make_client_capabilities)))
|
||||||
|
|
||||||
|
(setup :mason)
|
||||||
|
(setup :mason-lspconfig {:ensure_installed servers})
|
||||||
|
|
||||||
|
(each [_ lsp (pairs servers)]
|
||||||
|
(do (local lsp_opts {:on_attach on_attach
|
||||||
|
:capabilities capabilities
|
||||||
|
:flags {:debounce_text_changes 150}})
|
||||||
|
(local (status config) (pcall require (.. "lspconfig." lsp)))
|
||||||
|
(if status
|
||||||
|
(config.setup lsp_opts)
|
||||||
|
((. (. (require :lspconfig) lsp) :setup) lsp_opts))))
|
||||||
|
|
||||||
|
; LuaSnip setup
|
||||||
|
(local luasnip (require :luasnip))
|
||||||
|
((. (require :luasnip.loaders.from_vscode) :lazy_load))
|
||||||
|
|
||||||
|
; nvim-cmp setup
|
||||||
|
(local lspkind (require :lspkind))
|
||||||
|
(local cmp (require :cmp))
|
||||||
|
(cmp.setup {:snippet {:expand (fn [args] (luasnip.lsp_expand args.body))}
|
||||||
|
:mapping (cmp.mapping.preset.insert {:<C-d> (cmp.mapping.scroll_docs -4)
|
||||||
|
:<C-f> (cmp.mapping.scroll_docs 4)
|
||||||
|
:<C-Space> (cmp.mapping.complete)
|
||||||
|
:<CR> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace
|
||||||
|
:select true})
|
||||||
|
:<Tab> (cmp.mapping (fn [fallback]
|
||||||
|
(if (cmp.visible)
|
||||||
|
(cmp.select_next_item)
|
||||||
|
(if (luasnip.expand_or_jumpable)
|
||||||
|
(luasnip.expand_or_jump)
|
||||||
|
(fallback))))
|
||||||
|
[:i :s])
|
||||||
|
:<S-Tab> (cmp.mapping (fn [fallback]
|
||||||
|
(if (cmp.visible)
|
||||||
|
(cmp.select_prev_item)
|
||||||
|
(if (luasnip.jumpable -1)
|
||||||
|
(luasnip.jump -1)
|
||||||
|
(fallback))))
|
||||||
|
[:i :s])})
|
||||||
|
:sources [{:name "luasnip"}
|
||||||
|
{:name "nvim_lsp"}
|
||||||
|
{:name "omni"}]
|
||||||
|
:formatting {:format (lspkind.cmp_format {:mode "symbol_text"})}})
|
||||||
21
.config/nvim/fnl/map_utils.fnl
Normal file
21
.config/nvim/fnl/map_utils.fnl
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
(local M {})
|
||||||
|
(local module_name "map_utils")
|
||||||
|
(local fn_store [])
|
||||||
|
|
||||||
|
(fn register_fn [new_fn]
|
||||||
|
(do (table.insert fn_store new_fn)
|
||||||
|
(length fn_store)))
|
||||||
|
|
||||||
|
(fn M.apply_function [id]
|
||||||
|
((. fn_store id)))
|
||||||
|
|
||||||
|
(fn M.apply_expr [id]
|
||||||
|
(vim.api.nvim_replace_termcodes ((. fn_store id)) true true true))
|
||||||
|
|
||||||
|
(fn M.lua_fn [lfn]
|
||||||
|
(string.format "<cmd>lua require('%s').apply_function(%s)<CR>" module_name (register_fn lfn)))
|
||||||
|
|
||||||
|
(fn M.lua_expr [lfn]
|
||||||
|
(string.format "v:lua.require'%s'.apply_expr(%s)" module_name (register_fn lfn)))
|
||||||
|
|
||||||
|
M
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
local servers = { 'pyright', 'sumneko_lua', 'eslint', 'tsserver', 'ltex' }
|
|
||||||
|
|
||||||
-- Mappings.
|
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
|
||||||
local opts = { noremap=true, silent=true }
|
|
||||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
|
||||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
|
||||||
-- after the language server attaches to the current buffer
|
|
||||||
local on_attach = function(_, bufnr)
|
|
||||||
-- Mappings.
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
||||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
|
||||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>wl', function()
|
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
|
||||||
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
|
|
||||||
end
|
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
|
||||||
|
|
||||||
require("mason").setup()
|
|
||||||
require("mason-lspconfig").setup({
|
|
||||||
ensure_installed = servers
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, lsp in pairs(servers) do
|
|
||||||
local lsp_opts = {
|
|
||||||
on_attach = on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
flags = {
|
|
||||||
-- This will be the default in neovim 0.7+
|
|
||||||
debounce_text_changes = 150,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
local status, config = pcall(require, 'lspconfig.' .. lsp)
|
|
||||||
if status then
|
|
||||||
config.setup(lsp_opts)
|
|
||||||
else
|
|
||||||
require('lspconfig')[lsp].setup(lsp_opts)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- luasnip setup
|
|
||||||
local luasnip = require 'luasnip'
|
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
|
||||||
|
|
||||||
-- nvim-cmp setup
|
|
||||||
local lspkind = require('lspkind')
|
|
||||||
local cmp = require 'cmp'
|
|
||||||
cmp.setup {
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
luasnip.lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = true,
|
|
||||||
},
|
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
}),
|
|
||||||
sources = {
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'omni' }
|
|
||||||
},
|
|
||||||
formatting = {
|
|
||||||
format = lspkind.cmp_format({
|
|
||||||
mode = "symbol_text",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
local module_name = 'map_utils'
|
|
||||||
local fn_store = {}
|
|
||||||
|
|
||||||
local function register_fn(fn)
|
|
||||||
table.insert(fn_store, fn)
|
|
||||||
return #fn_store
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.apply_function(id)
|
|
||||||
fn_store[id]()
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.apply_expr(id)
|
|
||||||
return vim.api.nvim_replace_termcodes(fn_store[id](), true, true, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.lua_fn(fn)
|
|
||||||
return string.format(
|
|
||||||
"<cmd>lua require('%s').apply_function(%s)<CR>",
|
|
||||||
module_name,
|
|
||||||
register_fn(fn)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.lua_expr(fn)
|
|
||||||
return string.format(
|
|
||||||
"v:lua.require'%s'.apply_expr(%s)",
|
|
||||||
module_name,
|
|
||||||
register_fn(fn)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
Reference in New Issue
Block a user