Finish config port

This commit is contained in:
Alexander Rosenberg 2022-11-29 23:55:20 -08:00
parent 3317339d51
commit 777b73b061
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -1,5 +1,8 @@
;;; init.fnl - primary init file
;; Initialize global `zander' prefix
(set _G.zander {})
;; Helpful keymaping functions
(macro bind! [mode key cmd ?a1 ?a2]
(let [desc (or ?a2 ?a1)
@ -24,7 +27,7 @@
(each [_ hook (ipairs hook_table)]
(set group (.. group "-" hook)))
(each [_ pattern (ipairs pattern_table)]
(set group (.. group "-" patterns)))
(set group (.. group "-" pattern)))
`(vim.api.nvim_create_autocmd ,hook_table
{ :group
(vim.api.nvim_create_augroup ,group
@ -131,6 +134,16 @@
(bind! :n "]d" vim.diagnostic.goto_next)
(bind! :n :<leader>q vim.diagnostic.setloclist)
;; Some filetype settings
(vim.filetype.add { :filename {
".latexmkrc" :perl
"Jenkinsfile" :groovy }
:extensions {
"nasm" :nasm
"h" :c
"ui" :xml }})
;; Plugins (with packer.nvim)
(fn packer_init_callback [use]
;; Nicer macro for use
@ -313,11 +326,33 @@
;; nvim-find-other
(use! "https://git.zander.im/Zander671/nvim-find-other.git"
:config #(setup! :nvim-find-other
:c { "h" "H" }
:h { "c" "C" "cpp" "cxx" "c++" "cc" }
:cpp { "hpp" "hxx" "h++" "hh" "h" "H" }
:hpp { "cpp" "cxx" "c++" "cc" }))
:config (fn [] (setup! :nvim-find-other
:c [ "h" "H" ]
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
:hpp [ "cpp" "cxx" "c++" "cc" ])
(let [find_other (require :nvim-find-other)]
(vim.api.nvim_create_user_command
"FindOtherFile"
find_other.find_other_current_buffer
{})
(bind! :n :go find_other.find_other_current_buffer))))
(use! :RRethy/vim-illuminate
:config (fn []
((. (require :illuminate) :configure) { :providers [
"lsp"
"treesitter"
"ragex" ]
:modes_denylist [
:markdown
:text
:gitconfig
:gitignore ]
:delay 0 }
(hook! :FileType :lua #(vim.api.nvim_set_hl 0
:IlluminatedWordText
{})))))
;; Conjure (better lisp support)
(use! :Olical/conjure
@ -350,7 +385,7 @@
[ :i :c ])
:<C-space> (cmp.mapping (cmp.mapping.complete)
[ :i :c ])
:<C-e> (cmp.mapping (cmp.mapping.abort)
:<C-e> (cmp.mapping (cmp.mapping.abort)
[ :i :c ])
:<CR> (cmp.mapping
(cmp.mapping.confirm { :select false })
@ -411,14 +446,7 @@
;; lspconfig
(fn lsp_config_callback []
(fn get_data_dir [server root]
(let [resolved_path (vim.fn.resolve root)
joined_path (vim.fn.substitute resolved_path "\\/" "@" :g)]
(.. (vim.fn.fnamemodify (.. "~/.local/nvim/lsp-cache/"
server
"/"
:p)) joined_path)))
(fn on_attach [_ buf]
(fn _G.zander.lsp_on_attach [_ buf]
(bind! :n :gD vim.lsp.buf.declaration buf)
(bind! :n :gd vim.lsp.buf.definition buf)
(bind! :n :K vim.lsp.buf.hover buf)
@ -442,25 +470,25 @@
(bind! :n :<leader>fS builtin.lsp_workspace_symbols buf)
(bind! :n :<leader>d builtin.lsp_document_symbols buf)
(bind! :n :<leader>fd builtin.lsp_document_symbols buf)))
(fn _G.zander.lsp_get_data_dir [server root]
(let [resolved_path (vim.fn.resolve root)
joined_path (vim.fn.substitute resolved_path "\\/" "@" :g)]
(.. (vim.fn.fnamemodify (.. "~/.local/nvim/lsp-cache/"
server
"/")
":p") joined_path)))
(let [lsp (require :lspconfig)
lsp_cap ((. (require :cmp_nvim_lsp) :default_capabilities))
default_config { :on_attach on_attach
:capabilities lsp_cap }]
lsp_cap ((. (require :cmp_nvim_lsp) :default_capabilities))]
(macro setup_server! [name ...]
(if (not= (# [...]) 0)
(let [opts {}]
(let [opts { :on_attach `_G.zander.lsp_on_attach
:capabilities `lsp_cap }]
(var last_key nil)
(each [_ val (ipairs [...])]
(if last_key
(do (tset opts last_key val)
(set last_key nil))
(set last_key val)))
(if (not opts.on_attach)
(tset opts :on_attach `on_attach))
(if (not opts.capabilities)
(tset opts :capabilities `lsp_cap))
`((. (. lsp ,name) :setup) ,opts))
`((. (. lsp ,name) :setup) default_config)))
`((. (. lsp ,name) :setup) ,opts)))
(setup_server! :ccls)
(setup_server! :cmake)
(setup_server! :gopls)
@ -481,8 +509,22 @@
(use! :neovim/nvim-lspconfig
:after :cmp-nvim-lsp
:config lsp_config_callback)
(fn jdtls_config_callback []
(hook! :FileType :java
#(let [root_dir ((. (require :jdtls.setup) :find_root)
[ ".git" "mvnw" "gradlew" "build.gradle" ])
lsp_cap ((. (require :cmp_nvim_lsp) :default_capabilities))]
((. (require :jdtls) :start_or_attach)
{ :capabilities lsp_cap
:on_attach _G.zander.lsp_on_attach
:root_dir root_dir
:cmd [ "jdtls"
"-data"
(_G.zander.lsp_get_data_dir
:jdtls root_dir) ]}))))
(use! :mfussenegger/nvim-jdtls
:after :nvim-lspconfig))
:after :nvim-lspconfig
:config jdtls_config_callback))
(vim.cmd.packadd "packer.nvim")
(let [packer (require :packer)]