port more nvim stuff to fennel

This commit is contained in:
LordMZTE 2023-02-19 21:23:55 +01:00
parent bf4a37cfdb
commit ce299b3660
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
25 changed files with 173 additions and 313 deletions

View file

@ -0,0 +1,47 @@
(local lspc (require :lspconfig))
(macro setup [conf args]
(var args args)
(when (not args)
(set args {}))
(tset args :capabilities `caps)
`((. lspc ,conf :setup) ,args))
(var caps
((. (require :cmp_nvim_lsp) :default_capabilities) (vim.lsp.protocol.make_client_capabilities)))
(tset caps :textDocument :foldingRange
{:dynamicRegistration false :lineFoldingOnly true})
(fn disable-formatter [client _]
(tset client :server_capabilities :documentFormattingRangeProvider false))
(setup :clangd {:on_attach disable-formatter})
(setup :cssls)
(setup :elixirls {:cmd [:elixir-ls]})
(setup :eslint)
(setup :haxe_language_server)
(setup :html)
(setup :jsonls)
(setup :lua_ls {:settings {:Lua {:runtime {:version :LuaJIT
:path (do
(var p
(vim.split package.path
";"))
(table.insert p :lua/?.lua)
(table.insert p
:lua/?/init.lua))}
:diagnostics {:globals [:vim]}
:workspace [(vim.api.nvim_get_runtime_file ""
true)]
:telemetry {:enable false}}}})
(setup :ocamllsp)
(setup :prosemd_lsp)
(setup :racket_langserver)
(setup :rust_analyzer
{:settings {:rust-analyzer {:checkOnSave {:command :clippy}}}})
(setup :taplo)
(setup :yamlls)
(setup :zls)

View file

@ -1,65 +0,0 @@
local lspc = require "lspconfig"
local caps = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
caps.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
local function disableFormatter(client, _)
client.server_capabilities.documentFormattingProvider = false
end
local lua_runtime_path = vim.split(package.path, ";")
table.insert(lua_runtime_path, "lua/?.lua")
table.insert(lua_runtime_path, "lua/?/init.lua")
lspc.clangd.setup {
capabilities = caps,
on_attach = disableFormatter,
}
lspc.cssls.setup { capabilities = caps }
lspc.elixirls.setup {
capabilities = caps,
cmd = { "elixir-ls" },
}
lspc.eslint.setup { capabilities = caps }
lspc.haxe_language_server.setup { capabilities = caps }
lspc.html.setup { capabilities = caps }
lspc.jsonls.setup { capabilities = caps }
lspc.lua_ls.setup {
capabilities = caps,
settings = {
Lua = {
runtime = {
version = "LuaJIT",
path = lua_runtime_path,
},
diagnostics = {
globals = { "vim" },
},
workspace = {
vim.api.nvim_get_runtime_file("", true),
},
telemetry = {
enable = false,
},
},
},
}
lspc.ocamllsp.setup { capabilities = caps }
lspc.prosemd_lsp.setup { capabilities = caps }
lspc.racket_langserver.setup { capabilities = caps }
lspc.rust_analyzer.setup {
capabilities = caps,
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
},
},
}
lspc.taplo.setup { capabilities = caps }
lspc.yamlls.setup { capabilities = caps }
lspc.zls.setup { capabilities = caps }

View file

@ -0,0 +1,34 @@
(local (cmp luasnip mztenv)
(values (require :cmp) (require :luasnip) (require :mzte_nv)))
(local sources {:buffer " ﬘"
:crates " "
:luasnip " "
:nvim_lsp " "
:path " "
:treesitter " "})
(cmp.setup {:snippet {:expand #(luasnip.lsp_expand (. $1 :body))}
:mapping {:<C-b> (cmp.mapping (cmp.mapping.scroll_docs -4) [:i :c])
:<C-f> (cmp.mapping (cmp.mapping.scroll_docs 4) [:i :c])
:<C-Space> (cmp.mapping (cmp.mapping.complete) [:i :c])
:<Tab> (cmp.mapping mztenv.cmp.onTab [:i :s])
:<S-Tab> (cmp.mapping (cmp.mapping.select_prev_item))
:<CR> (cmp.mapping.confirm {:select true})}
:sources (cmp.config.sources (icollect [n _ (pairs sources)]
{:name n}))
:formatting {:format (fn [entry vim-item]
(tset vim-item :menu
(. sources entry.source.name))
vim-item)}})
(cmp.setup.cmdline "/" {:sources {:name :buffer}})
(cmp.setup.cmdline ":"
{:sources (cmp.config.sources [{:name :path}]
[{:name :cmdline}])})
(local signs {:Error " " :Warn " " :Hint " " :Info " "})
(each [k v (pairs signs)]
(let [hl (.. :DiagnosticSign k)]
(vim.fn.sign_define hl {:text v :texthl hl :numhl hl})))

View file

@ -1,72 +0,0 @@
local cmp = require "cmp"
local luasnip = require "luasnip"
local mztenv = require "mzte_nv"
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = {
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<Tab>"] = cmp.mapping(mztenv.cmp.onTab, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item()),
["<CR>"] = cmp.mapping.confirm { select = true },
},
sources = cmp.config.sources {
{ name = "buffer" },
{ name = "crates" },
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "treesitter" },
},
formatting = {
format = function(entry, vim_item)
vim_item.menu = ({
buffer = "",
crates = "",
luasnip = "",
nvim_lsp = "",
path = "",
rg = "",
treesitter = "",
})[entry.source.name]
return vim_item
end,
},
}
cmp.setup.cmdline("/", {
sources = {
{ name = "buffer" },
},
})
cmp.setup.cmdline(":", {
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
})
-- define signs
local signs = {
Error = "",
Warn = "",
Hint = "",
Info = "",
}
for k, v in pairs(signs) do
local hl = "DiagnosticSign" .. k
vim.fn.sign_define(hl, { text = v, texthl = hl, numhl = hl })
end

View file

@ -0,0 +1,5 @@
(local ngit (require :neogit))
(ngit.setup {})
(vim.api.nvim_create_user_command :Neogit ngit.open {:nargs 0})

View file

@ -1,5 +0,0 @@
local ngit = require "neogit"
ngit.setup {}
vim.api.nvim_create_user_command("Neogit", ngit.open, { nargs = 0 })

View file

@ -0,0 +1,8 @@
(local noice (require :noice))
(local overrides [:vim.lsp.util.convert_input_to_markdown_lines
:vim.lsp.util.stylize_markdown
:cmp.entry.get_documentation])
(noice.setup {:message {:view :mini}
:override (collect [_ o (ipairs overrides)] (values o true))})

View file

@ -1,12 +0,0 @@
local noice = require "noice"
noice.setup {
messages = {
view = "mini",
},
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
}

View file

@ -0,0 +1,4 @@
((. (require :recorder) :setup) {:mapping {;; this would conflict with search keybind (default is #)
:addBreakPoint nil}
;; clear all existing macros on startup
:clear true})

View file

@ -1,8 +0,0 @@
require("recorder").setup {
mapping = {
-- this would conflict with search keybind (default is #)
addBreakPoint = nil,
},
-- clear all existing macros on startup
clear = true,
}

View file

@ -0,0 +1,22 @@
(local nvtree (require :nvim-tree))
(nvtree.setup {:actions {:change_dir {:global true}}
:view {:adaptive_size true}
:diagnostics {:enable true}
:git {;; don't hide .gitignored files
:ignore false}
:renderer {:indent_markers {:enable true} :group_empty true}})
;; open on startup
(fn on-enter [data]
(local is-no-name (and (= data.file "") (= (. vim :bo data.buf :buftype) "")))
(local is-dir (= (vim.fn.isdirectory data.file) 1))
(when is-dir
(vim.cmd.cd data.file))
(when (or is-no-name is-dir)
((. (require :nvim-tree.api) :tree :open))))
(vim.api.nvim_create_autocmd [:VimEnter] {:callback on-enter})
(vim.keymap.set :n :TT #((. (require :nvim-tree.api) :tree :toggle))
{:noremap true :silent true})

View file

@ -1,39 +0,0 @@
local map = vim.api.nvim_set_keymap
require("nvim-tree").setup {
actions = {
change_dir = {
global = true,
},
},
view = {
adaptive_size = true,
},
diagnostics = {
enable = true,
},
git = {
ignore = false,
},
renderer = {
indent_markers = { enable = true },
group_empty = true,
},
}
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function(data)
local is_no_name = data.file == "" and vim.bo[data.buf].buftype == ""
local is_dir = vim.fn.isdirectory(data.file) == 1
if is_dir then
vim.cmd.cd(data.file)
end
if is_no_name or is_dir then
require("nvim-tree.api").tree.open()
end
end,
})
map("n", "TT", [[<cmd>NvimTreeToggle<CR>]], { noremap = true, silent = true })

View file

@ -0,0 +1,4 @@
(local rust-tools (require :rust-tools))
(rust-tools.setup {})
(rust-tools.inlay_hints.enable)

View file

@ -1,4 +0,0 @@
local rust_tools = require "rust-tools"
rust_tools.setup {}
rust_tools.inlay_hints.enable();

View file

@ -0,0 +1,16 @@
(local (configs parsers)
(values (require :nvim-treesitter.configs)
(require :nvim-treesitter.parsers)))
(var parser-config (parsers.get_parser_configs))
(tset parser-config :haxe {:install_info {:url "https://github.com/vantreeseba/tree-sitter-haxe"
:files [:src/parser.c]
:branch :main}
:filetype :haxe})
(configs.setup {:highlight {:enable true}
:autotag {:enable true}
:indent {:enable true}
:rainbow {:enable true
:hlgroups (fcollect [i 1 6] (.. :TSRainbow i))}})

View file

@ -1,41 +0,0 @@
local configs = require "nvim-treesitter.configs"
local parsers = require "nvim-treesitter.parsers"
local parser_config = parsers.get_parser_configs()
parser_config.haxe = {
install_info = {
url = "https://github.com/vantreeseba/tree-sitter-haxe",
files = { "src/parser.c" },
branch = "main",
},
filetype = "haxe",
}
configs.setup {
ensure_installed = { "haxe" },
highlight = {
enable = true,
},
autotag = {
enable = true,
},
indent = {
enable = true,
},
rainbow = {
enable = true,
hlgroups = {
"TSRainbow1",
"TSRainbow2",
"TSRainbow3",
"TSRainbow4",
"TSRainbow5",
"TSRainbow6",
},
},
}

View file

@ -0,0 +1,15 @@
(local tsc (require :treesitter-context))
(tsc.setup {:patterns {:zig [:block
:FnProto
:function
:TopLevelDecl
:Statement
:IfStatement
:WhileStatement
:WhileExpr
:ForStatement
:ForExpr
:WhileStatement
:WhileExpr]
:html [:element]}})

View file

@ -1,23 +0,0 @@
local tsc = require "treesitter-context"
tsc.setup {
patterns = {
zig = {
"block",
"FnProto",
"function",
"TopLevelDecl",
"Statement",
"IfStatement",
"WhileStatement",
"WhileExpr",
"ForStatement",
"ForExpr",
"WhileStatement",
"WhileExpr",
},
html = {
"element",
}
},
}

View file

@ -0,0 +1,4 @@
(local colors ["#ff00be" "#ff7e00" "#64d200" "#00e6b6" "#00e1ff" "#9598ff"])
(each [i c (ipairs colors)]
(vim.api.nvim_set_hl 0 (.. :TSRainbow i) {:fg c}))

View file

@ -1,12 +0,0 @@
local colors = {
"#ff00be",
"#ff7e00",
"#64d200",
"#00e6b6",
"#00e1ff",
"#9598ff",
}
for i, c in ipairs(colors) do
vim.api.nvim_set_hl(0, "TSRainbow" .. i, { fg = c })
end

View file

@ -0,0 +1,3 @@
(local tterm (require :toggleterm))
(tterm.setup {:size 64 :open_mapping :<C-t> :direction :vertical})

View file

@ -1,7 +0,0 @@
local tterm = require "toggleterm"
tterm.setup {
size = 64,
open_mapping = [[<C-t>]],
direction = "vertical",
}

View file

@ -0,0 +1,11 @@
(local wdi (require :nvim-web-devicons))
(local racket-icon {:icon "λ" :color "#9f1d20" :cterm_color 88 :name :Racket})
(wdi.setup {:override {:rkt racket-icon
:rktl racket-icon
:rktd racket-icon
:scm {:icon "λ"
:color "#3e5ba9"
:cterm_color 61
:name :Scheme}}})

View file

@ -1,22 +0,0 @@
local wdi = require "nvim-web-devicons"
local racket_icon = {
icon = "λ",
color = "#9f1d20",
cterm_color = 88,
name = "Racket",
}
wdi.setup {
override = {
rkt = racket_icon,
rktl = racket_icon,
rktd = racket_icon,
scm = {
icon = "λ",
color = "#3e5ba9",
cterm_color = 61,
name = "Scheme",
},
},
}

View file

@ -1,3 +0,0 @@
local zigtools = require "zig-tools"
zigtools.setup()