From 3890f9ff3352f60d1ba4792dbf693a5363cfd97e Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Fri, 6 Nov 2026 16:19:45 -0600 Subject: [PATCH] nvim: fix a bunch of bugs --- .config/nvim/after/ftplugin/c.fnl | 11 +++-- .config/nvim/after/ftplugin/qf.vim | 2 +- .config/nvim/after/ftplugin/zig.fnl | 2 +- .config/nvim/after/plugin/fugitive.vim | 2 +- .config/nvim/colors/nord.lua | 31 +++++++------- .config/nvim/filetype.lua | 37 +++++++++-------- .config/nvim/fnl/ft/c.fnl | 7 ++-- .config/nvim/fnl/macros.fnl | 30 ++++++-------- .config/nvim/fnl/statusline.fnl | 14 +++---- .config/nvim/init.vim | 9 +---- .config/nvim/lsp/hls.fnl | 4 +- .config/nvim/lsp/ocamllsp.fnl | 4 +- .config/nvim/lsp/rust-analyzer.fnl | 12 +++--- .config/nvim/lsp/yaml-language-server.fnl | 3 +- .config/nvim/lua/moonwalk.lua | 9 +++-- .config/nvim/plugin/grep.fnl | 2 +- .config/nvim/plugin/lsp.fnl | 9 +++-- .config/nvim/plugin/make.fnl | 49 ++++++++++++++--------- .config/nvim/plugin/mini.fnl | 4 +- .config/nvim/plugin/moonwalk.lua | 14 +++++-- .config/nvim/plugin/mouse.fnl | 4 +- .config/nvim/plugin/treesitter.fnl | 6 +-- .config/nvim/plugin/treesitter/swap.fnl | 8 ++-- 23 files changed, 147 insertions(+), 126 deletions(-) diff --git a/.config/nvim/after/ftplugin/c.fnl b/.config/nvim/after/ftplugin/c.fnl index 43cc68b7..7053ec00 100644 --- a/.config/nvim/after/ftplugin/c.fnl +++ b/.config/nvim/after/ftplugin/c.fnl @@ -3,9 +3,8 @@ (set-path (vim.api.nvim_get_current_buf)) (autocmd ft/c :LspAttach {:buffer 0} - #(do - (let [bufnr (vim.api.nvim_get_current_buf) - uri (vim.uri_from_bufnr bufnr) + (fn [{:buf bufnr}] + (let [uri (vim.uri_from_bufnr bufnr) [client] (vim.lsp.get_clients {: bufnr :name :clangd})] (when client (fn switch-source-header [] @@ -14,13 +13,13 @@ {: uri} (fn [err res] (when err - (error err)) + (error err.message)) (if res - (exec (.. "edit " (vim.uri_to_fname res))) + (vim.cmd.edit (vim.uri_to_fname res)) (echo "Alternate file not found"))) bufnr)) - (keymap :n "gh" switch-source-header {:buffer true}) + (keymap :n "gh" switch-source-header {:buffer bufnr}) (let [name (vim.api.nvim_buf_get_name bufnr)] (case (vim.fs.find ".clang-format" {:path (vim.fs.dirname name) diff --git a/.config/nvim/after/ftplugin/qf.vim b/.config/nvim/after/ftplugin/qf.vim index ecdc6256..c4c17f9e 100644 --- a/.config/nvim/after/ftplugin/qf.vim +++ b/.config/nvim/after/ftplugin/qf.vim @@ -3,7 +3,7 @@ setlocal nowrap winfixbuf cursorlineopt=both nnoremap q :q augroup qf - autocmd! + autocmd! * autocmd BufEnter ++nested if winnr('$') < 2 | q | endif augroup END diff --git a/.config/nvim/after/ftplugin/zig.fnl b/.config/nvim/after/ftplugin/zig.fnl index 055d8c25..85e6bf8b 100644 --- a/.config/nvim/after/ftplugin/zig.fnl +++ b/.config/nvim/after/ftplugin/zig.fnl @@ -2,7 +2,7 @@ ; Use 80 for textwidth to wrap comments, but set colorcolumn to 100 for code (set vim.bo.textwidth 80) -(set vim.wo.colorcolumn "100") +(tset vim.wo 0 0 :colorcolumn "100") (match vim.g.zig_tags_file tags (when (= 1 (vim.fn.filereadable tags)) diff --git a/.config/nvim/after/plugin/fugitive.vim b/.config/nvim/after/plugin/fugitive.vim index 31cb9a06..73816bb4 100644 --- a/.config/nvim/after/plugin/fugitive.vim +++ b/.config/nvim/after/plugin/fugitive.vim @@ -5,7 +5,7 @@ endif augroup fugitive# autocmd! autocmd BufRead fugitive://* setlocal bufhidden=delete - autocmd BufRead * if $PWD ==# $HOME | call FugitiveDetect($HOME .. '/.dotfiles') | endif + autocmd BufRead * if getcwd() ==# $HOME | call FugitiveDetect($HOME .. '/.dotfiles') | endif autocmd VimEnter,DirChanged,BufRead,BufNewFile * if !empty(FugitiveGitDir()) | let &l:tags = split(FugitiveGitDir() .. '/tags,' .. &tags, ',')->uniq()->join(',') | endif autocmd FileType fugitive,git setlocal nolist augroup END diff --git a/.config/nvim/colors/nord.lua b/.config/nvim/colors/nord.lua index 6d2d852a..0e9ce91f 100644 --- a/.config/nvim/colors/nord.lua +++ b/.config/nvim/colors/nord.lua @@ -1,5 +1,8 @@ local nvim_set_hl = vim.api.nvim_set_hl +vim.o.background = "dark" +vim.cmd.highlight("clear") + local background = "#2e3440" local foreground = "#eceff4" @@ -287,7 +290,7 @@ local highlights = { asciidocQuotedMonospaced2 = { link = "asciidocQuotedMonospaced" }, asciidocQuotedUnconstrainedBold = { link = "asciidocQuotedBold" }, asciidocQuotedUnconstrainedEmphasized = { link = "asciidocQuotedEmphasized" }, - asciidocURL = { link = "markdownLinkText" }, + asciidocURL = { link = "@markup.link.url" }, awkCharClass = { fg = brightcyan }, awkPatterns = { fg = blue, bold = true }, @@ -373,12 +376,12 @@ local highlights = { htmlBold = { link = "Bold" }, htmlEndTag = { link = "htmlTag" }, htmlItalic = { link = "Italic" }, - htmlH1 = { link = "markdownH1" }, - htmlH2 = { link = "markdownH1" }, - htmlH3 = { link = "markdownH1" }, - htmlH4 = { link = "markdownH1" }, - htmlH5 = { link = "markdownH1" }, - htmlH6 = { link = "markdownH1" }, + htmlH1 = { link = "Title" }, + htmlH2 = { link = "Title" }, + htmlH3 = { link = "Title" }, + htmlH4 = { link = "Title" }, + htmlH5 = { link = "Title" }, + htmlH6 = { link = "Title" }, htmlSpecialChar = { link = "SpecialChar" }, htmlTag = { link = "Keyword" }, htmlTagN = { link = "htmlTag" }, @@ -421,24 +424,24 @@ local highlights = { pandocDefinitionBlockTerm = { fg = brightcyan }, pandocTableDelims = { fg = brighterblack }, - pandocAtxHeader = { link = "markdownH1" }, - pandocBlockQuote = { link = "markdownBlockquote" }, + pandocAtxHeader = { link = "Title" }, + pandocBlockQuote = { link = "@markup.quote" }, pandocCiteAnchor = { link = "Operator" }, pandocCiteKey = { link = "pandocReferenceLabel" }, pandocDefinitionBlockMark = { link = "Operator" }, - pandocEmphasis = { link = "markdownItalic" }, + pandocEmphasis = { link = "@markup.italic" }, pandocFootnoteID = { link = "pandocReferenceLabel" }, - pandocFootnoteIDHead = { link = "markdownLinkDelimiter" }, + pandocFootnoteIDHead = { link = "Delimiter" }, pandocFootnoteIDTail = { link = "pandocFootnoteIDHead" }, pandocGridTableDelims = { link = "pandocTableDelims" }, pandocGridTableHeader = { link = "pandocTableDelims" }, pandocOperator = { link = "Operator" }, pandocPipeTableDelims = { link = "pandocTableDelims" }, pandocReferenceDefinition = { link = "pandocReferenceLabel" }, - pandocReferenceLabel = { link = "markdownLinkText" }, - pandocReferenceURL = { link = "markdownUrl" }, + pandocReferenceLabel = { link = "@markup.link.label" }, + pandocReferenceURL = { link = "@markup.link.url" }, pandocSimpleTableHeader = { link = "pandocAtxHeader" }, - pandocStrong = { link = "markdownBold" }, + pandocStrong = { link = "@markup.strong" }, pandocTableHeaderWord = { link = "pandocAtxHeader" }, pandocUListItemBullet = { link = "Operator" }, diff --git a/.config/nvim/filetype.lua b/.config/nvim/filetype.lua index 84c74fa0..2311c75b 100644 --- a/.config/nvim/filetype.lua +++ b/.config/nvim/filetype.lua @@ -1,6 +1,6 @@ vim.filetype.add({ extension = { - h = function(path) + h = function(path, bufnr) -- Try to be a little intelligent when determining if a .h file is C++ or C -- If a .cc or .cpp file with the same basename exists next to this @@ -16,22 +16,25 @@ vim.filetype.add({ -- If the header file contains C++ specific keywords, assume it is -- C++ if - vim.fn.search( - string.format( - [[\C\%%(%s\)]], - table.concat({ - [[^#include <[^>.]\+>$]], - [[\]], - [[\]], - [[\]], - [[^class\> [A-Z]], - [[^\s*using\>]], - [[\\s*<]], - [[\.]\+>$]], + [[\]], + [[\]], + [[\]], + [[^class\> [A-Z]], + [[^\s*using\>]], + [[\\s*<]], + [[\ (vim.fn.getcwd -1 i) (vim.fn.fnamemodify ":~") - (vim.fn.pathshorten))] + (vim.fn.pathshorten) + (: :gsub "%%" "%%%%"))] (table.insert items (: "%%#%s#%%%dT %d %s " :format hi i i cwd)))) (table.insert items "%#TabLineFill#%T") (table.concat items))) @@ -55,7 +53,7 @@ "") "%=" "%-10.S" - (if (< 0 vim.o.busy) "◐ " "") + (if (< 0 vim.bo.busy) "◐ " "") (diagnostics) (if fancy "%4*" "") (if (and vim.bo.modifiable (not vim.bo.readonly)) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index a487acd0..2fe62283 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -71,7 +71,7 @@ nnoremap gq? set formatprg? formatexpr? nnoremap [e '.move --' . v:count1 . '' nnoremap ]e '.move +' . v:count1 . '' xnoremap [e ':move --' . v:count1 . 'gv' -xnoremap ]e ':move +' . (v:count1 + line('''>') - line('''<')) . 'gv' +xnoremap ]e ":move '>+" . v:count1 . 'gv' function! Sort(type, ...) abort '[,']sort @@ -125,7 +125,7 @@ augroup init " Disable listchars and fix in prompt buffers autocmd OptionSet buftype if &buftype ==# 'prompt' | \ setlocal nolist | - \ inoremap | + \ inoremap | \ endif " Don't show trailing spaces in insert mode @@ -138,11 +138,6 @@ augroup init " Automatically enter terminal mode when a :terminal opens autocmd TermOpen term://* startinsert autocmd TermClose term://* stopinsert - - " Set the 'busy' indicator in the statusline when quickfix commands are - " running - autocmd QuickFixCmdPre * set busy+=1 - autocmd QuickFixCmdPost * set busy-=1 augroup END packadd! nvim.undotree diff --git a/.config/nvim/lsp/hls.fnl b/.config/nvim/lsp/hls.fnl index 2c88a38c..025e0b77 100644 --- a/.config/nvim/lsp/hls.fnl +++ b/.config/nvim/lsp/hls.fnl @@ -1,4 +1,6 @@ {:filetypes ["haskell"] :cmd ["haskell-language-server-wrapper" "--lsp"] - :root_markers [["*.cabal" "stack.yaml" "cabal.project" "package.yaml" "hie.yaml"]] + :root_dir (fn [buf cb] + (cb (vim.fs.root buf #(or (vim.endswith $1 ".cabal") + (vim.list_contains ["stack.yaml" "cabal.project" "package.yaml" "hie.yaml"] $1))))) :settings {:haskell {:formattingProvider "ormolu"}}} diff --git a/.config/nvim/lsp/ocamllsp.fnl b/.config/nvim/lsp/ocamllsp.fnl index 00cd3962..adbafb4c 100644 --- a/.config/nvim/lsp/ocamllsp.fnl +++ b/.config/nvim/lsp/ocamllsp.fnl @@ -1,3 +1,5 @@ {:filetypes ["ocaml"] :cmd ["ocamllsp"] - :root_markers [["*.opam" "dune-project" "dune-workspace"]]} + :root_dir (fn [buf cb] + (cb (vim.fs.root buf #(or (vim.endswith $1 ".opam") + (vim.list_contains ["dune-project" "dune-workspace"] $1)))))} diff --git a/.config/nvim/lsp/rust-analyzer.fnl b/.config/nvim/lsp/rust-analyzer.fnl index bbec548d..32e104fe 100644 --- a/.config/nvim/lsp/rust-analyzer.fnl +++ b/.config/nvim/lsp/rust-analyzer.fnl @@ -2,11 +2,11 @@ :cmd ["rust-analyzer"] :root_dir (fn [buf cb] (let [cwd (vim.fs.dirname (vim.api.nvim_buf_get_name buf))] - (vim.system ["cargo" "metadata" "--no-deps" "--format-version" "1"] - {: cwd} - (fn [out] - (when (= 0 out.code) - (case (pcall vim.json.decode out.stdout) - (true {: workspace_root}) (cb workspace_root))))))) + (pcall vim.system ["cargo" "metadata" "--no-deps" "--format-version" "1"] + {: cwd} + (fn [out] + (when (= 0 out.code) + (case (pcall vim.json.decode out.stdout) + (true {: workspace_root}) (cb workspace_root))))))) :settings {:autoformat true :rust-analyzer {:check {:command "clippy"}}}} diff --git a/.config/nvim/lsp/yaml-language-server.fnl b/.config/nvim/lsp/yaml-language-server.fnl index 180988ce..ead4a322 100644 --- a/.config/nvim/lsp/yaml-language-server.fnl +++ b/.config/nvim/lsp/yaml-language-server.fnl @@ -1,2 +1,3 @@ {:filetypes ["yaml"] - :cmd ["yaml-language-server" "--stdio"]} + :cmd ["yaml-language-server" "--stdio"] + :workspace_required false} diff --git a/.config/nvim/lua/moonwalk.lua b/.config/nvim/lua/moonwalk.lua index be8f90e7..c3e66dfe 100644 --- a/.config/nvim/lua/moonwalk.lua +++ b/.config/nvim/lua/moonwalk.lua @@ -7,18 +7,18 @@ local fennel_path = vim.fn.stdpath("data") .. "/site/lua/fennel.lua" local fennel_url = string.format("https://fennel-lang.org/downloads/fennel-%s.lua", fennel_version) local function compile(path) - local base = path:gsub(vim.fn.stdpath("config") .. "/", "") - if ignored[base] then + local base = vim.fs.relpath(vim.fn.stdpath("config"), path) + if not base or ignored[base] then return end local ok, fennel = pcall(require, "fennel") if not ok or fennel.version ~= fennel_version then - print(string.format("Downloading Fennel %s...", fennel_version, tmpdir)) + print(string.format("Downloading Fennel %s...", fennel_version)) vim.fn.mkdir(vim.fn.fnamemodify(fennel_path, ":h"), "p") do - local job = vim.system({ "curl", "-sS", "-o", fennel_path, fennel_url }):wait(10000) + local job = vim.system({ "curl", "-fsSL", "-o", fennel_path, fennel_url }):wait(10000) assert(job.code == 0, job.stderr) end @@ -47,6 +47,7 @@ local function compile(path) local macro_path = fennel["macro-path"] fennel["macro-path"] = macro_path .. ";" .. vim.fn.stdpath("config") .. "/fnl/?.fnl" + fennel["macro-loaded"].macros = nil local preamble = [[(require-macros :macros)]] local compiled = fennel.compileString(preamble .. src, { filename = path }) fennel["macro-path"] = macro_path diff --git a/.config/nvim/plugin/grep.fnl b/.config/nvim/plugin/grep.fnl index 945942db..ad6d4f55 100644 --- a/.config/nvim/plugin/grep.fnl +++ b/.config/nvim/plugin/grep.fnl @@ -1,5 +1,5 @@ (fn grep [{: args}] - (let [grepcmd (case (vim.o.grepprg:gsub "%$%*" args) + (let [grepcmd (case (vim.o.grepprg:gsub "%$%*" #args) (s 0) (.. s " " args) (s n) s)] (vim.api.nvim_exec_autocmds :QuickFixCmdPre {:pattern "grep" :modeline false}) diff --git a/.config/nvim/plugin/lsp.fnl b/.config/nvim/plugin/lsp.fnl index 8df0514b..2a3e290c 100644 --- a/.config/nvim/plugin/lsp.fnl +++ b/.config/nvim/plugin/lsp.fnl @@ -25,8 +25,9 @@ (vim.lsp.codelens.enable true {: client_id})) (when (client:supports_method :textDocument/foldingRange) - (tset vim.wo 0 0 :foldmethod :expr) - (tset vim.wo 0 0 :foldexpr "v:lua.vim.lsp.foldexpr()")) + (vim.api.nvim_buf_call buf #(do + (tset vim.wo 0 0 :foldmethod :expr) + (tset vim.wo 0 0 :foldexpr "v:lua.vim.lsp.foldexpr()")))) (autocmd :BufWritePre {:buffer buf} #(when (and (vim.nonnil client.settings.autoformat vim.b.lsp_autoformat vim.g.lsp_autoformat false) @@ -40,7 +41,7 @@ (vim.lsp.completion.enable true client_id buf {:autotrigger true})) (when (client:supports_method :textDocument/documentColor) - (vim.lsp.document_color.enable true buf {:style :virtual}))))) + (vim.lsp.document_color.enable true {:bufnr buf} {:style :virtual}))))) (autocmd :LspDetach (fn [{: buf :data {: client_id}}] (vim.api.nvim_clear_autocmds {:group (.. "lsp#" client_id) :buffer buf}) @@ -61,4 +62,4 @@ (vim.lsp.config "*" {:on_init on-init :workspace_required true}) (let [configs (collect [_ c (ipairs (vim.api.nvim_get_runtime_file "lsp/*.lua" true))] (values (vim.fn.fnamemodify c ":t:r") true))] - (vim.lsp.enable (icollect [c (pairs configs)] c) (or vim.g.lsp_autostart true))) + (vim.lsp.enable (icollect [c (pairs configs)] c) (vim.nonnil vim.g.lsp_autostart true))) diff --git a/.config/nvim/plugin/make.fnl b/.config/nvim/plugin/make.fnl index fefba861..ea6c6c83 100644 --- a/.config/nvim/plugin/make.fnl +++ b/.config/nvim/plugin/make.fnl @@ -4,14 +4,16 @@ (vim.api.nvim_ui_send (: "\027]777;notify;%s;%s\027\\" :format title msg))) (fn make [{: args}] - (let [makeprg (case (vim.o.makeprg:gsub "%$%*" args) + (let [makeprg (case (vim.o.makeprg:gsub "%$%*" #args) (s 0) (.. s " " args) (s n) s) makeprg (vim.fn.expandcmd (vim.trim makeprg)) state {}] (fn on-exit [{: code}] (vim.schedule (fn [] - (vim.fn.setqflist [] :a {:id state.qf :context {: code}}) + (if state.qf + (vim.fn.setqflist [] :a {:id state.qf :context {: code}}) + (vim.fn.setqflist [] " " {:title makeprg :nr "$" :context {: code}})) (vim.api.nvim_exec_autocmds :QuickFixCmdPost {:pattern "make" :modeline false}) (let [now (vim.uv.hrtime) elapsed (/ (- now state.start) 1e9) @@ -22,23 +24,31 @@ (notify "Neovim" message) (not= code 0) (print message)))))) - (fn on-data [err data] - (assert (not err) err) - (when data - (vim.schedule #(let [lines (vim.split data "\n" {:trimempty true})] - (when (not state.qf) - (vim.fn.setqflist [] " " {:title makeprg :nr "$"}) - (exec "botright copen|wincmd p") - (let [{: id : qfbufnr} (vim.fn.getqflist {:id 0 :qfbufnr true})] - (set state.qf id) - (keymap :n "" #(let [result (state.handle:wait 0)] - (when (not= 0 result.signal) - (let [title (: "%s (Interrupted)" :format makeprg)] - (vim.fn.setqflist [] :a {: title}))) {}) {:buffer qfbufnr}))) - (vim.fn.setqflist [] :a {:id state.qf : lines}) - (exec :cbottom))))) + (fn append [lines] + (when (not state.qf) + (vim.fn.setqflist [] " " {:title makeprg :nr "$"}) + (exec "botright copen|wincmd p") + (let [{: id : qfbufnr} (vim.fn.getqflist {:id 0 :qfbufnr true})] + (set state.qf id) + (keymap :n "" #(let [result (state.handle:wait 0)] + (when (not= 0 result.signal) + (let [title (: "%s (Interrupted)" :format makeprg)] + (vim.fn.setqflist [] :a {: title}))) {}) {:buffer qfbufnr}))) + (vim.fn.setqflist [] :a {:id state.qf : lines}) + (exec :cbottom)) + (fn reader [] + (var pending "") + (fn [err data] + (assert (not err) err) + (let [lines (if data + (let [lines (vim.split (.. pending data) "\n")] + (set pending (table.remove lines)) + lines) + (if (= pending "") [] [pending]))] + (when (< 0 (length lines)) + (vim.schedule #(append lines)))))) (vim.api.nvim_exec_autocmds :QuickFixCmdPre {:pattern "make" :modeline false}) - (set state.handle (vim.system (vim.split makeprg " ") {:stdout on-data :stderr on-data} on-exit)) + (set state.handle (vim.system [vim.o.shell vim.o.shellcmdflag makeprg] {:stdout (reader) :stderr (reader)} on-exit)) (set state.start (vim.uv.hrtime)))) (command :Make {:nargs :*} make) @@ -51,7 +61,8 @@ (each [i item (ipairs items) &until found?] (when (= 1 item.valid) (set found? true) - (vim.api.nvim_win_set_cursor winid [i 0]))) + (when (not= winid 0) + (vim.api.nvim_win_set_cursor winid [i 0])))) (when (and (= 0 code) (not found?)) (exec :cclose)))) diff --git a/.config/nvim/plugin/mini.fnl b/.config/nvim/plugin/mini.fnl index 2fe4ced2..1bbf45ec 100644 --- a/.config/nvim/plugin/mini.fnl +++ b/.config/nvim/plugin/mini.fnl @@ -14,8 +14,8 @@ :replace "cs" :update_n_lines "" :suffix_last "" - :suffix_next "" - :search_method "cover_or_next"}} + :suffix_next ""} + :search_method "cover_or_next"} (vim.keymap.del :x "ys") (keymap :x "S" ":lua MiniSurround.add('visual')") (keymap :n "yss" "ys_" {:noremap false})) diff --git a/.config/nvim/plugin/moonwalk.lua b/.config/nvim/plugin/moonwalk.lua index 823ad678..9432efdd 100644 --- a/.config/nvim/plugin/moonwalk.lua +++ b/.config/nvim/plugin/moonwalk.lua @@ -3,20 +3,26 @@ vim.api.nvim_create_autocmd("BufWritePost", { pattern = vim.fn.stdpath("config") .. "/*.fnl", group = "moonwalk", callback = function(args) - require("moonwalk").compile(args.file) + require("moonwalk").compile(args.match) end, }) vim.api.nvim_create_autocmd("SourceCmd", { pattern = "*.fnl", group = "moonwalk", callback = function(args) - vim.api.nvim_cmd({ cmd = "source", args = { require("moonwalk").compile(args.file) } }, {}) + local out = require("moonwalk").compile(vim.fs.abspath(args.file)) + if out then + vim.api.nvim_cmd({ cmd = "source", args = { out } }, {}) + else + vim.notify("moonwalk: not compiled: " .. args.file, vim.log.levels.WARN) + end end, }) local marker = vim.fn.stdpath("state") .. "/moonwalk" local function moonwalk() + local loader_enabled = vim.loader.enabled vim.loader.enable(false) local walk = require("moonwalk").walk @@ -37,7 +43,9 @@ local function moonwalk() -- Reset runtimepath cache so new Lua files are discovered vim.o.runtimepath = vim.o.runtimepath - vim.schedule(vim.loader.enable) + if loader_enabled then + vim.schedule(vim.loader.enable) + end end vim.api.nvim_create_user_command("Moonwalk", moonwalk, { desc = "Compile all Fennel runtime files to Lua" }) diff --git a/.config/nvim/plugin/mouse.fnl b/.config/nvim/plugin/mouse.fnl index 056b563f..309f5461 100644 --- a/.config/nvim/plugin/mouse.fnl +++ b/.config/nvim/plugin/mouse.fnl @@ -5,14 +5,14 @@ [line] (vim.api.nvim_buf_get_lines buf row (+ row 1) true)] (when (and line (<= col (length line))) (let [uri (vim.uri_from_bufnr buf) - character (vim.str_utfindex line client.offset_encoding col) + character (vim.str_utfindex line client.offset_encoding (- col 1)) params {:textDocument {: uri} :position {:line row : character}} hover "textDocument/hover" document-highlight "textDocument/documentHighlight"] (when (client:supports_method hover {:bufnr buf}) (let [handler (or (. client.handlers hover) vim.lsp.handlers.hover) - handler (vim.lsp.with handler {:relative :mouse :silent true :border rounded})] + handler #(handler $1 $2 $3 {:relative :mouse :silent true :border :rounded})] (client:request hover params handler buf))) (when (client:supports_method document-highlight {:bufnr buf}) (let [handler (or (. client.handlers document-highlight) diff --git a/.config/nvim/plugin/treesitter.fnl b/.config/nvim/plugin/treesitter.fnl index a65f96dc..a5d5c7ce 100644 --- a/.config/nvim/plugin/treesitter.fnl +++ b/.config/nvim/plugin/treesitter.fnl @@ -15,6 +15,6 @@ parser (do (when (not (. vim.treesitter.highlighter.active buf)) (vim.treesitter.highlighter.new parser)) - (when (vim.treesitter.query.get ft :folds) - (set vim.wo.foldmethod :expr) - (set vim.wo.foldexpr "v:lua.vim.treesitter.foldexpr()"))))))))) + (when (vim.treesitter.query.get (parser:lang) :folds) + (tset vim.wo 0 0 :foldmethod :expr) + (tset vim.wo 0 0 :foldexpr "v:lua.vim.treesitter.foldexpr()"))))))))) diff --git a/.config/nvim/plugin/treesitter/swap.fnl b/.config/nvim/plugin/treesitter/swap.fnl index 023b7f44..d04c93ac 100644 --- a/.config/nvim/plugin/treesitter/swap.fnl +++ b/.config/nvim/plugin/treesitter/swap.fnl @@ -19,7 +19,7 @@ row (- row 1)] (var parent nil) (each [_ matches (query:iter_matches (tree:root) buf) &until parent] - (match (. matches capture-map.parent) + (match (. matches capture-map.parent 1) node (when (vim.treesitter.is_in_node_range node row col) (set parent node)))) (when parent @@ -46,10 +46,10 @@ lang (or (vim.treesitter.language.get_lang ft) ft) query (vim.treesitter.query.get lang :swap)] (if query - (case (vim.treesitter.get_parser bufnr lang {:error false}) + (case (vim.treesitter.get_parser buf lang {:error false}) parser (*swap buf parser query forward vim.v.count1) - nil (vim.api.nvim_err_writeln (: "No parser found for language %s" :format lang))) - (vim.api.nvim_err_writeln (: "No 'swap' query found for language %s" :format lang)))) + nil (vim.notify (: "No parser found for language %s" :format lang) vim.log.levels.ERROR)) + (vim.notify (: "No 'swap' query found for language %s" :format lang) vim.log.levels.ERROR))) (pcall vim.fn.repeat#set (if forward ">a" "a" #(swap true)) -- knotmirror 0.0.1