summaryrefslogtreecommitdiff
path: root/mut/neovim
diff options
context:
space:
mode:
Diffstat (limited to 'mut/neovim')
-rw-r--r--mut/neovim/fnl/conf/events.fnl51
-rw-r--r--mut/neovim/fnl/conf/init.fnl49
-rw-r--r--mut/neovim/fnl/conf/lsp.fnl48
-rw-r--r--mut/neovim/fnl/conf/pkgs/lspconfig.fnl50
4 files changed, 110 insertions, 88 deletions
diff --git a/mut/neovim/fnl/conf/events.fnl b/mut/neovim/fnl/conf/events.fnl
index 4bc3729..69758dc 100644
--- a/mut/neovim/fnl/conf/events.fnl
+++ b/mut/neovim/fnl/conf/events.fnl
@@ -1,23 +1,36 @@
-(vim.api.nvim_create_augroup "conf#events" {:clear true})
+(local lspconfig (require :lspconfig))
+(local configs (require :lspconfig.configs))
+(local {: attach} (require :conf.lsp))
+
(local event vim.api.nvim_create_autocmd)
-(event [:BufReadPost] {:pattern ["*"]
- :callback (fn []
- (local pattern "'\\s\\+$'")
- (vim.cmd (.. "syn match TrailingWhitespace "
- pattern))
- (vim.cmd "hi link TrailingWhitespace IncSearch"))
- :group "conf#events"})
+(vim.api.nvim_create_augroup "conf#events" {:clear true})
+
+(event
+ :LspAttach
+ {:group "conf#events"
+ :pattern ["*"]
+ :callback attach})
-(local vimenter-cwd (vim.fn.getcwd))
-(event [:VimLeave] {:pattern ["*"]
- :callback (fn []
- (vim.cmd (.. "mksession! " vimenter-cwd
- :/.vimsession.vim)))
- :group "conf#events"})
+(event
+ :BufReadPost
+ {:pattern ["*"]
+ :callback (fn []
+ (local pattern "'\\s\\+$'")
+ (vim.cmd (.. "syn match TrailingWhitespace "
+ pattern))
+ (vim.cmd "hi link TrailingWhitespace IncSearch"))
+ :group "conf#events"})
-(event [:FileType] {:pattern [:dirvish]
- :callback (fn []
- (vim.cmd "silent! unmap <buffer> <C-p>")
- (vim.cmd "set buflisted"))
- :group "conf#events"})
+(local session-file (.. vim.env.HOME "/.vimsession.vim"))
+(event
+ :VimLeave
+ {:group "conf#events"
+ :pattern ["*"]
+ :callback #(vim.cmd (.. "mksession! " session-file))})
+(event
+ :VimEnter
+ {:group "conf#events"
+ :pattern ["*"]
+ :callback #(if (= 1 (vim.fn.filereadable session-file))
+ (vim.schedule #(vim.cmd (.. "source " session-file))))})
diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl
index 4ec8b76..e73568a 100644
--- a/mut/neovim/fnl/conf/init.fnl
+++ b/mut/neovim/fnl/conf/init.fnl
@@ -8,6 +8,7 @@
(require :conf.pkgs)
(require :conf.nix-develop)
(require :conf.diagnostic)
+(require :conf.events)
(tset _G :P (lambda [...]
(let [inspected (icollect [_ v (ipairs [...])]
@@ -15,17 +16,9 @@
(each [_ printer (ipairs inspected)]
(print printer)))))
-(local tel (require :telescope))
-(local themes (require :telescope.themes))
-(local builtin (require :telescope.builtin))
-(local actions (require :telescope.actions))
-(tel.setup
- {:defaults
- (vim.tbl_extend
- :force
- (themes.get_ivy)
- {:mappings
- {:i {"<C-a>" actions.select_all}}})})
+(local fzf (require :fzf-lua))
+(local action (require :fzf-lua.actions))
+(fzf.setup [:max-perf])
(local cope #(vim.cmd (.. ":copen " (math.floor (/ vim.o.lines 2.1)))))
(let [map vim.keymap.set]
@@ -38,16 +31,17 @@
(map :n :<M-space> ":cprev<cr>")
(map :n :<C-M-space> ":cprev<cr>")
(map :n :<C-space> ":cnext<cr>")
- (map :n :<C-x> #(do
- (vim.fn.setreg "/" "Compile")
- (vim.api.nvim_feedkeys
- (vim.api.nvim_replace_termcodes
- ":Compile<up><c-f>" true false true)
- :n false)
- (vim.schedule #(do
- (vim.cmd "let v:searchforward = 0")
- (map :n :/ "/Compile.* " {:buffer true})
- (map :n :? "?Compile.* " {:buffer true})))))
+ (map :n :<C-x>
+ #(do
+ (vim.fn.setreg "/" "Compile")
+ (vim.api.nvim_feedkeys
+ (vim.api.nvim_replace_termcodes
+ ":Compile<up><c-f>" true false true)
+ :n false)
+ (vim.schedule #(do
+ (vim.cmd "let v:searchforward = 0")
+ (map :n :/ "/Compile.* " {:buffer true})
+ (map :n :? "?Compile.* " {:buffer true})))))
(map :n :<C-e> ":Recompile<CR>")
(map :n "[q" ":cprevious<cr>")
(map :n "]q" ":cnext<cr>")
@@ -55,9 +49,20 @@
(map :n "]x" ":lnext<cr>")
(map :n :<c-p> ":Telescope find_files<cr>" {:noremap true})
(map :n "<leader>;" ":silent grep ")
- (map :n :<leader>xb #(builtin.buffers { :sort_mru true :ignore_current_buffer true})))
+ (map :n :<leader>xb #(fzf.buffers
+ {:keymap {:fzf {"ctrl-a" "select-all"
+ "alt-a" "deselect-all"}}
+ :actions {:default {:fn action.buf_edit_or_qf}}}))
+ (map :n :<leader>x<cr> #(vim.cmd "b #")))
+(vim.api.nvim_create_user_command
+ :NixEdit
+ (fn [{: args}]
+ (local f (io.popen (.. "nix eval --raw " vim.env.HOME "/flake#nixosConfigurations." (vim.fn.hostname) ".pkgs." args)))
+ (vim.cmd (.. "e " (f:read))))
+ {:nargs 1})
+
;; I like to use the qf to run a lot of stuff that prints junk
;; Here I just check if ansi control stuff is printed and reparse the lines with efm
(local qf
diff --git a/mut/neovim/fnl/conf/lsp.fnl b/mut/neovim/fnl/conf/lsp.fnl
index 35fa34f..b8d84d3 100644
--- a/mut/neovim/fnl/conf/lsp.fnl
+++ b/mut/neovim/fnl/conf/lsp.fnl
@@ -1,4 +1,4 @@
-(fn map-to-capabilities [{: client : buf} format]
+(fn map-to-capabilities [{: client : buf}]
(fn bo [name value]
(vim.api.nvim_buf_set_option buf name value))
@@ -19,21 +19,21 @@
:referencesProvider (bm :n :<leader>gg (lspdo :references))
:documentSymbolProvider (bm :n :<leader>gds (lspdo :workspace_symbol))
:codeActionProvider (bm :n :<leader>ga (lspdo :code_action))
- :codeLensProvider (bm :n :<leader>gl
- (lambda []
- (vim.lsp.codelens.run)))
+ :codeLensProvider (bm :n :<leader>gl #(vim.lsp.codelens.run))
:hoverProvider (bo :keywordprg ":LspHover")
- :documentFormattingProvider (if format
- ((fn []
- (bo :formatexpr
- "v:lua.vim.lsp.format()")
- (bm :n :<leader>gq
- #(vim.lsp.buf.format {:async true})))))))
+ :inlayHintProvider (do
+ (vim.lsp.inlay_hint.enable buf true)
+ (bm :n :<leader>gh #(vim.lsp.inlay_hint.enable 0 (not (vim.lsp.inlay_hint.is_enabled 0)))))
+ :documentFormattingProvider (do
+ (bo :formatexpr
+ "v:lua.vim.lsp.format()")
+ (bm :n :<leader>gq
+ #(vim.lsp.buf.format {:async true})))))
- (each [cpb enabled? (pairs client.server_capabilities)]
- (if enabled?
- (use cpb)))
- {: client : buf})
+ (each [cpb enabled? (pairs client.server_capabilities)]
+ (if enabled?
+ (use cpb)))
+ {: client : buf})
(fn register-handlers [{: client : buf}]
(tset (. client :handlers) :textDocument/publishDiagnostics
@@ -57,19 +57,19 @@
(fn events [{: client : buf}]
(match client.server_capabilities
{:documentFormattingProvider true}
- (let [format-events-group (vim.api.nvim_create_augroup :format-events
- {:clear true})]
- (vim.api.nvim_create_autocmd [:BufWritePre]
- {:group format-events-group
- :callback (lambda []
- (if format-on-save
- (vim.lsp.buf.format)))
- :buffer buf}))))
+ (vim.api.nvim_create_autocmd
+ :BufWritePre
+ {:group
+ (vim.api.nvim_create_augroup :format-events {:clear true})
+ :buffer buf
+ :callback #(if format-on-save (vim.lsp.buf.format))})))
-(fn attach [client buf format]
+(fn attach [ev]
+ (local client (vim.lsp.get_client_by_id ev.data.client_id))
+ (local buf ev.buf)
(-> {: client : buf}
(register-handlers)
- (map-to-capabilities format)
+ (map-to-capabilities)
(events)))
{: attach}
diff --git a/mut/neovim/fnl/conf/pkgs/lspconfig.fnl b/mut/neovim/fnl/conf/pkgs/lspconfig.fnl
index 82ca385..e324f5c 100644
--- a/mut/neovim/fnl/conf/pkgs/lspconfig.fnl
+++ b/mut/neovim/fnl/conf/pkgs/lspconfig.fnl
@@ -1,6 +1,5 @@
(local lspconfig (require :lspconfig))
(local configs (require :lspconfig.configs))
-(local {: attach} (require :conf.lsp))
(lspconfig.rust_analyzer.setup
{:settings
@@ -11,32 +10,37 @@
:root_dir
(lspconfig.util.root_pattern
:.git
- (vim.fn.getcwd))
- :on_attach attach})
+ (vim.fn.getcwd))})
-(lspconfig.pyright.setup {:root_dir (lspconfig.util.root_pattern :.git
- (vim.fn.getcwd))
- :on_attach attach
- :settings {:venvPath (.. (vim.fn.getcwd) :.venv)}})
+(lspconfig.pyright.setup
+ {:root_dir
+ (lspconfig.util.root_pattern
+ :.git
+ (vim.fn.getcwd))
+ :settings
+ {:venvPath (.. (vim.fn.getcwd) :.venv)}})
-(lspconfig.tsserver.setup {:root_dir (lspconfig.util.root_pattern :.git
- (vim.fn.getcwd))
- :on_attach attach})
+(lspconfig.tsserver.setup
+ {:root_dir
+ (lspconfig.util.root_pattern
+ :.git
+ (vim.fn.getcwd))})
-(lspconfig.gopls.setup {:root_dir (lspconfig.util.root_pattern :.git
- (vim.fn.getcwd))
- :on_attach attach
- :settings {:gopls {:codelenses {:test true :bench true}
- ;; Show a code lens toggling the display of gc's choices.}
- :buildFlags [:-tags=all]}}})
+(lspconfig.gopls.setup
+ {:root_dir (lspconfig.util.root_pattern :.git
+ (vim.fn.getcwd))
+ :settings {:gopls {:codelenses {:test true :bench true}
+ ;; Show a code lens toggling the display of gc's choices.}
+ :buildFlags [:-tags=all]}}})
-(lspconfig.ansiblels.setup {:ansible {:ansible {:path :ansible}
- :executionEnvironment {:enabled false}
- :python {:interpreterPath :python}
- :validation {:enabled true
- :lint {:enabled false
- :arguments " --profile=production --write=all "
- :path :ansible-lint}}}})
+(lspconfig.ansiblels.setup
+ {:ansible {:ansible {:path :ansible}
+ :executionEnvironment {:enabled false}
+ :python {:interpreterPath :python}
+ :validation {:enabled true
+ :lint {:enabled false
+ :arguments " --profile=production --write=all "
+ :path :ansible-lint}}}})
;; (tset configs :fennel_language_server
;; {:default_config {;; replace it with true path