From ac8edfb0db52efe65e01f73ef44133a86571ba02 Mon Sep 17 00:00:00 2001 From: aktersnurra Date: Fri, 17 Apr 2026 23:34:22 +0200 Subject: More based fixes --- fnl/plugins/cmp.fnl | 4 +- fnl/plugins/conform.fnl | 16 ++- fnl/plugins/fff.fnl | 45 +++--- fnl/plugins/grug-far.fnl | 9 +- fnl/plugins/harpoon.fnl | 21 ++- fnl/plugins/leap.fnl | 2 +- fnl/plugins/lsp/keymaps.fnl | 68 +++++++-- fnl/plugins/lsp/servers.fnl | 2 +- fnl/plugins/lualine.fnl | 21 +-- fnl/plugins/markdown.fnl | 6 +- fnl/plugins/neogit.fnl | 13 +- fnl/plugins/nvim-lint.fnl | 11 +- fnl/plugins/orgmode.fnl | 38 +++-- fnl/plugins/persistence.fnl | 31 ++--- fnl/plugins/snippets.fnl | 3 +- fnl/plugins/telescope.fnl | 40 +----- fnl/plugins/treesitter-context.fnl | 4 +- fnl/plugins/treesitter.fnl | 278 +++++++++++++++++++++++++------------ fnl/plugins/which-key.fnl | 25 ++-- fnl/plugins/window-picker.fnl | 2 +- fnl/settings/autocmds.fnl | 50 ++++--- fnl/settings/init.fnl | 14 +- fnl/settings/keymaps.fnl | 46 +++--- fnl/settings/terminal.fnl | 6 +- 24 files changed, 416 insertions(+), 339 deletions(-) (limited to 'fnl') diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl index 46efbc5..78f7522 100644 --- a/fnl/plugins/cmp.fnl +++ b/fnl/plugins/cmp.fnl @@ -15,8 +15,8 @@ :buffer] :score_offset 3} :snippets {:name :Snippets - :module :blink.cmp.sources.snippets - :score_offset 4} + :module :blink.cmp.sources.snippets + :score_offset 4} :dadbod {:name :Dadbod :module :vim_dadbod_completion.blink :score_offset 2}}} diff --git a/fnl/plugins/conform.fnl b/fnl/plugins/conform.fnl index b84627d..5995635 100644 --- a/fnl/plugins/conform.fnl +++ b/fnl/plugins/conform.fnl @@ -1,11 +1,13 @@ ;; Formatting +(import-macros {: keymap} :macros) + (λ init [] - (vim.keymap.set [:n :v] :e - (λ [] - (let [conform (require :conform)] - (conform.format {:lsp_fallback true :async true}))) - {:desc :Format})) + (keymap [:n :v] :e + (λ [] + (let [conform (require :conform)] + (conform.format {:lsp_fallback true :async true}))) + {:desc :Format})) (local opts {:formatters {:fnlfmt {:command :fnlfmt :args [:--fix :$FILENAME] @@ -22,7 +24,9 @@ :lua [:stylua] :markdown [:prettierd] :ocaml [:ocamlformat] - :python [:ruff_format :ruff_fix :ruff_organize_imports] + :python [:ruff_format + :ruff_fix + :ruff_organize_imports] :rust [:rustfmt] :sh [:shfmt :shellharden] :sql [:pg_format :sqlfmt] diff --git a/fnl/plugins/fff.fnl b/fnl/plugins/fff.fnl index 3939408..e92e358 100644 --- a/fnl/plugins/fff.fnl +++ b/fnl/plugins/fff.fnl @@ -3,30 +3,37 @@ (import-macros {: autocmd} :macros) (λ init [] - (autocmd :VimEnter - {:callback (λ [] - (when (= (. (vim.fn.argv) 1) nil) - (vim.schedule - (λ [] ((. (require :fff) :find_files)))))) - :once true})) + (autocmd :VimEnter {:callback (λ [] + (when (= (. (vim.fn.argv) 1) nil) + (vim.schedule (λ [] + ((. (require :fff) + :find_files)))))) + :once true})) (local opts {:layout {:height 0.8 - :width 0.7 - :prompt_position :bottom - :preview_position :top - :preview_size 0.8 - :flex {:size 130 :wrap :top} - :show_scrollbar false - :path_shorten_strategy :middle_number}}) + :width 0.7 + :prompt_position :top + :preview_position :bottom + :preview_size 0.8 + :flex {:size 130 :wrap :top} + :show_scrollbar false + :path_shorten_strategy :middle_number}}) {1 :dmtrKovalenko/fff.nvim :build (λ [] - ((. (require :fff.download) :build_binary) - (λ [ok err] - (vim.schedule - (λ [] (vim.notify (if ok "fff.nvim built!" err))))))) + ((. (require :fff.download) :build_binary) (λ [ok err] + (vim.schedule (λ [] + (vim.notify (if ok + "fff.nvim built!" + err))))))) : opts :lazy false : init - :keys [{1 :mf 2 (λ [] ((. (require :fff) :find_files))) :desc "Find Files"} - {1 :mg 2 (λ [] ((. (require :fff) :live_grep))) :desc "Live Grep"}]} + :keys [{1 :mf + 2 (λ [] + ((. (require :fff) :find_files))) + :desc "Find Files"} + {1 :mg + 2 (λ [] + ((. (require :fff) :live_grep))) + :desc "Live Grep"}]} diff --git a/fnl/plugins/grug-far.fnl b/fnl/plugins/grug-far.fnl index ebd1835..342d266 100644 --- a/fnl/plugins/grug-far.fnl +++ b/fnl/plugins/grug-far.fnl @@ -17,11 +17,10 @@ (λ config [] (let [grug (require :grug-far)] - (autocmds - [:FileType - {:pattern [:grug-far] - :command "nnoremap q :close"}] - [:FileType {:pattern [:grug-far] :command "setlocal spell!"}]) + (autocmds [:FileType + {:pattern [:grug-far] + :command "nnoremap q :close"}] + [:FileType {:pattern [:grug-far] :command "setlocal spell!"}]) (grug.setup))) (local keys [{1 : 2 :GrugFar :desc "Find and Replace"} diff --git a/fnl/plugins/harpoon.fnl b/fnl/plugins/harpoon.fnl index 29f41d0..c4c7975 100644 --- a/fnl/plugins/harpoon.fnl +++ b/fnl/plugins/harpoon.fnl @@ -12,17 +12,16 @@ (: (harpoon:list) :select nr))) (λ init [] - (user-cmds - [:HarpoonAdd - (λ [] - (let [harpoon (require :harpoon)] - (: (harpoon:list) :add))) - {:nargs 0}] - [:HarpoonUI - (λ [] - (let [harpoon (require :harpoon)] - (harpoon.ui:toggle_quick_menu (harpoon:list) opts))) - {:nargs 0}])) + (user-cmds [:HarpoonAdd + (λ [] + (let [harpoon (require :harpoon)] + (: (harpoon:list) :add))) + {:nargs 0}] + [:HarpoonUI + (λ [] + (let [harpoon (require :harpoon)] + (harpoon.ui:toggle_quick_menu (harpoon:list) opts))) + {:nargs 0}])) (local keys [{1 :ma 2 :HarpoonAdd :desc :Harpoon} {1 :mr 2 :HarpoonUI :desc "Harpoon UI"} diff --git a/fnl/plugins/leap.fnl b/fnl/plugins/leap.fnl index 0526109..d6ec18e 100644 --- a/fnl/plugins/leap.fnl +++ b/fnl/plugins/leap.fnl @@ -26,7 +26,7 @@ (λ config [] (let [leap (require :leap)] - (tset leap.opts.vim_opts "go.ignorecase" false) + (tset leap.opts.vim_opts :go.ignorecase false) (vim.keymap.set [:n :x :o] :s "(leap-forward)") (vim.keymap.set [:n :x :o] :S "(leap-backward)") (vim.keymap.set [:x :o] :x "(leap-forward-till)") diff --git a/fnl/plugins/lsp/keymaps.fnl b/fnl/plugins/lsp/keymaps.fnl index 3477f0a..1b97668 100644 --- a/fnl/plugins/lsp/keymaps.fnl +++ b/fnl/plugins/lsp/keymaps.fnl @@ -3,20 +3,58 @@ (import-macros {: keymaps} :macros) (λ on-attach [buffer] - (keymaps - [:n :gD "lua vim.lsp.buf.declaration()" {:desc :Declaration :buffer buffer}] - [:n :gd "Telescope lsp_definitions theme=get_dropdown" {:desc :Definition :buffer buffer}] - [:n :gI "Telescope lsp_implementations theme=get_dropdown" {:desc :Implementation :buffer buffer}] - [:n :gr "Telescope lsp_references theme=get_dropdown" {:desc :References :buffer buffer}] - [:n :gl "lua vim.diagnostic.open_float()" {:desc :Diagnostics :buffer buffer}] - [:n :gj "Telescope diagnostics theme=get_dropdown" {:desc "Telescope Diagnostics" :buffer buffer}] - [:n :gw "Telescope lsp_dynamic_workspace_symbols theme=get_dropdown" {:desc "Workspace Symbols" :buffer buffer}] - [:n :gE "Telescope lsp_type_definitions theme=get_dropdown" {:desc "Type Definitions" :buffer buffer}] - [:n :gm "lua vim.lsp.buf.signature_help()" {:desc :Signature :buffer buffer}] - [:n :gM "Telescope lsp_document_symbols theme=get_dropdown" {:desc "Document Symbols" :buffer buffer}] - [:n :gh "lua vim.lsp.buf.code_action()" {:desc "Code Action" :buffer buffer}] - [:n :gb "lua vim.lsp.codelens.run()" {:desc "Code Lens" :buffer buffer}] - [:n :K "lua vim.lsp.buf.hover()" {:desc "Hover documentation" :buffer buffer}] - [:n :li :LspInfo {:desc "Lsp Info" :buffer buffer}])) + (keymaps [:n + :gD + "lua vim.lsp.buf.declaration()" + {:desc :Declaration : buffer}] + [:n + :gd + "Telescope lsp_definitions theme=get_dropdown" + {:desc :Definition : buffer}] + [:n + :gI + "Telescope lsp_implementations theme=get_dropdown" + {:desc :Implementation : buffer}] + [:n + :gr + "Telescope lsp_references theme=get_dropdown" + {:desc :References : buffer}] + [:n + :gl + "lua vim.diagnostic.open_float()" + {:desc :Diagnostics : buffer}] + [:n + :gj + "Telescope diagnostics theme=get_dropdown" + {:desc "Telescope Diagnostics" : buffer}] + [:n + :gw + "Telescope lsp_dynamic_workspace_symbols theme=get_dropdown" + {:desc "Workspace Symbols" : buffer}] + [:n + :gE + "Telescope lsp_type_definitions theme=get_dropdown" + {:desc "Type Definitions" : buffer}] + [:n + :gm + "lua vim.lsp.buf.signature_help()" + {:desc :Signature : buffer}] + [:n + :gM + "Telescope lsp_document_symbols theme=get_dropdown" + {:desc "Document Symbols" : buffer}] + [:n + :gh + "lua vim.lsp.buf.code_action()" + {:desc "Code Action" : buffer}] + [:n + :gb + "lua vim.lsp.codelens.run()" + {:desc "Code Lens" : buffer}] + [:n + :K + "lua vim.lsp.buf.hover()" + {:desc "Hover documentation" : buffer}] + [:n :li :LspInfo {:desc "Lsp Info" : buffer}])) {: on-attach} diff --git a/fnl/plugins/lsp/servers.fnl b/fnl/plugins/lsp/servers.fnl index 13c6c9e..bd7c3e4 100644 --- a/fnl/plugins/lsp/servers.fnl +++ b/fnl/plugins/lsp/servers.fnl @@ -20,8 +20,8 @@ :path (vim.split package.path ";")}}}} :taplo {} :texlab {} + :basedpyright {:settings {:basedpyright {:analysis {:typeCheckingMode :standard}}}} :ty {} - :vale_ls {:filetypes [:markdown :text :org]} :sqls {} :yamlls {:settings {:yaml {:schemastore {:enable false :url ""} :schemas (let [schemastore (require :schemastore)] diff --git a/fnl/plugins/lualine.fnl b/fnl/plugins/lualine.fnl index b331e79..93a2f94 100644 --- a/fnl/plugins/lualine.fnl +++ b/fnl/plugins/lualine.fnl @@ -42,18 +42,8 @@ (local branch {1 "b:gitsigns_head" :icon (. icons :git) :cond hide-in-width}) -(local filetype {1 :filetype - :icon_only true - :colored false - :cond hide-in-width}) - (local language-server {1 active-clients :cond hide-in-width}) -(local lsp-progress - {1 :lsp_progress - :display_components [[:title :percentage :message]] - :timer {:progress_enddelay 500 :lsp_client_name_enddelay 500}}) - (local opts {:options {:icons_enabled true :theme :no-clown-fiesta :component_separators "" @@ -65,8 +55,8 @@ :sections {:lualine_a [:mode] :lualine_b [:filename branch diff] :lualine_c {} - :lualine_x [lsp-progress language-server diagnostics] - :lualine_y [filetype] + :lualine_x [language-server diagnostics] + :lualine_y {} :lualine_z [:location :progress]} :inactive_sections {:lualine_a [:mode] :lualine_b {} @@ -76,9 +66,4 @@ :lualine_z [:location :progress]} :extensions [:oil :mason]}) -(local dependencies [:arkav/lualine-lsp-progress]) - -{1 :nvim-lualine/lualine.nvim - :event :VeryLazy - : opts - : dependencies} +{1 :nvim-lualine/lualine.nvim :event :VeryLazy : opts} diff --git a/fnl/plugins/markdown.fnl b/fnl/plugins/markdown.fnl index 1d6a2c7..03a6e24 100644 --- a/fnl/plugins/markdown.fnl +++ b/fnl/plugins/markdown.fnl @@ -1,7 +1,5 @@ ;; Markdown renderer plugin. -{1 :MeanderingProgrammer/markdown.nvim - :main :render-markdown +{1 :MeanderingProgrammer/render-markdown.nvim :opts {} - :name :render-markdown - :dependencies [ :nvim-treesitter/nvim-treesitter :nvim-tree/nvim-web-devicons ]} + :dependencies [:nvim-treesitter/nvim-treesitter :nvim-tree/nvim-web-devicons]} diff --git a/fnl/plugins/neogit.fnl b/fnl/plugins/neogit.fnl index 143699d..b8ee757 100644 --- a/fnl/plugins/neogit.fnl +++ b/fnl/plugins/neogit.fnl @@ -7,13 +7,12 @@ (local keys [{1 :gm 2 :Neogit :desc :Neogit}]) (λ init [] - (autocmds - [:FileType - {:pattern [:NeogitStatus - :NeogitCommitMessage - :NeogitNotification - :NeogitCommitView] - :command "setlocal spell!"}])) + (autocmds [:FileType + {:pattern [:NeogitStatus + :NeogitCommitMessage + :NeogitNotification + :NeogitCommitView] + :command "setlocal spell!"}])) (local opts {:integrations {:diffview true :telescope true}}) diff --git a/fnl/plugins/nvim-lint.fnl b/fnl/plugins/nvim-lint.fnl index 2d1887d..040bcc4 100644 --- a/fnl/plugins/nvim-lint.fnl +++ b/fnl/plugins/nvim-lint.fnl @@ -1,20 +1,19 @@ ;; Linting +(import-macros {: autocmd} :macros) + (λ callback [] (let [lint (require :lint)] (lint.try_lint))) (λ init [] (let [lint-augroup (vim.api.nvim_create_augroup :lint {:clear true})] - (vim.api.nvim_create_autocmd [:BufEnter - :BufWritePost - :InsertLeave - :TextChangedI] - {:group lint-augroup : callback}))) + (autocmd [:BufEnter :BufWritePost :InsertLeave :TextChangedI] + {:group lint-augroup : callback}))) (λ config [] (let [lint (require :lint)] - (set lint.linters_by_ft {:* [:codespell :write_good] + (set lint.linters_by_ft {:* [:codespell] :dockerfile [:hadolint] :fennel [:fennel] :gitcommit [:gitlint :codespell] diff --git a/fnl/plugins/orgmode.fnl b/fnl/plugins/orgmode.fnl index 60bc15c..e945ae9 100644 --- a/fnl/plugins/orgmode.fnl +++ b/fnl/plugins/orgmode.fnl @@ -18,26 +18,24 @@ :desc "Search headings"}]) (λ init [] - (user-cmds - [:OrgAgendaPrompt - (λ [] - (let [orgmode (require :orgmode)] - (orgmode.action :agenda.prompt))) - {:nargs 0}] - [:OrgCapturePrompt - (λ [] - (let [orgmode (require :orgmode)] - (orgmode.action :capture.prompt))) - {:nargs 0}]) - (autocmds - [:FileType - {:pattern :org - :callback (λ [] - (tset vim.opt_local :foldenable false) - (tset vim.opt_local :foldlevelstart 0) - (tset vim.opt_local :foldlevel 0) - (tset vim.opt_local :concealcursor :nc) - (tset vim.opt_local :conceallevel 2))}])) + (user-cmds [:OrgAgendaPrompt + (λ [] + (let [orgmode (require :orgmode)] + (orgmode.action :agenda.prompt))) + {:nargs 0}] + [:OrgCapturePrompt + (λ [] + (let [orgmode (require :orgmode)] + (orgmode.action :capture.prompt))) + {:nargs 0}]) + (autocmds [:FileType + {:pattern :org + :callback (λ [] + (tset vim.opt_local :foldenable false) + (tset vim.opt_local :foldlevelstart 0) + (tset vim.opt_local :foldlevel 0) + (tset vim.opt_local :concealcursor :nc) + (tset vim.opt_local :conceallevel 2))}])) (local templates {:t {:description :Todo :template "* TODO %?\n %u\n DEADLINE: %T\n"} diff --git a/fnl/plugins/persistence.fnl b/fnl/plugins/persistence.fnl index 2e81e78..8c2ff55 100644 --- a/fnl/plugins/persistence.fnl +++ b/fnl/plugins/persistence.fnl @@ -11,22 +11,21 @@ :desc "Ignore current session"}]) (λ init [] - (user-cmds - [:RestoreSession - (λ [] - (let [persistence (require :persistence)] - (persistence.load))) - {:nargs 0}] - [:RestoreLastSession - (λ [] - (let [persistence (require :persistence)] - (persistence.load {:last true}))) - {:nargs 0}] - [:IgnoreSession - (λ [] - (let [persistence (require :persistence)] - (persistence.stop))) - {:nargs 0}])) + (user-cmds [:RestoreSession + (λ [] + (let [persistence (require :persistence)] + (persistence.load))) + {:nargs 0}] + [:RestoreLastSession + (λ [] + (let [persistence (require :persistence)] + (persistence.load {:last true}))) + {:nargs 0}] + [:IgnoreSession + (λ [] + (let [persistence (require :persistence)] + (persistence.stop))) + {:nargs 0}])) (local opts {:options [:buffers :curdir :tabpages :winsize :help]}) diff --git a/fnl/plugins/snippets.fnl b/fnl/plugins/snippets.fnl index c45d220..70917ba 100644 --- a/fnl/plugins/snippets.fnl +++ b/fnl/plugins/snippets.fnl @@ -10,7 +10,8 @@ (let [ls (require :luasnip) luasnip-vscode (require :luasnip.loaders.from_vscode)] (luasnip-vscode.lazy_load) - (each [fname type (vim.fs.dir (.. (vim.fn.stdpath :config) :/fnl/plugins/snippets))] + (each [fname type (vim.fs.dir (.. (vim.fn.stdpath :config) + :/fnl/plugins/snippets))] (when (= type :file) (add-snippets (fname:match "^(.*)%.fnl$")))) (ls.config.set_config {:history true diff --git a/fnl/plugins/telescope.fnl b/fnl/plugins/telescope.fnl index 3932d84..dedaaea 100644 --- a/fnl/plugins/telescope.fnl +++ b/fnl/plugins/telescope.fnl @@ -1,30 +1,9 @@ ;; Telescope a highly extendable fuzzy finder over lists. (local dependencies - [{1 :ahmedkhalf/project.nvim - :event :VeryLazy - :opts {:active true - :on_config_done nil - :manual_mode false - :detection_methods [:patterns] - :patterns [:git - :_darcs - :.hg - :.bzr - :.svn - :Makefile - :package.json] - :show_hidden false - :silent_chdir true - :ignore_lsp {} - :datapath (vim.fn.stdpath :data)} - :config (λ [_ opts] - (let [project (require :project_nvim)] - (project.setup opts)))} - :nvim-lua/plenary.nvim - {1 :nvim-orgmode/telescope-orgmode.nvim}]) + [:nvim-lua/plenary.nvim {1 :nvim-orgmode/telescope-orgmode.nvim}]) -(local extensions [:orgmode :projects :git_worktree :harpoon]) +(local extensions [:orgmode :git_worktree :harpoon]) (λ load-extensions [telescope] (each [_ extension (ipairs extensions)] @@ -42,15 +21,9 @@ {1 :fR 2 "Telescope registers theme=dropdown" :desc :Registers} - {1 :fS - 2 "Telescope grep_string theme=dropdown" - :desc "Find String"} {1 :gb 2 "Telescope git_branches theme=dropdown" :desc "Checkout Branch"} - {1 :ff - 2 "Telescope find_files theme=dropdown" - :desc "Find files"} {1 :fh 2 "Telescope help_tags theme=dropdown" :desc :Help} @@ -60,15 +33,6 @@ {1 :fl 2 "Telescope resume theme=dropdown" :desc "Last Search"} - {1 :fp - 2 "Telescope projects theme=dropdown" - :desc "Find Project"} - {1 :fr - 2 "Telescope oldfiles theme=dropdown previewer=false" - :desc "Recent File"} - {1 :ft - 2 "Telescope live_grep theme=dropdown" - :desc "Find Text"} {1 :gc 2 "Telescope git_commits theme=dropdown" :desc "Checkout Commit"}]) diff --git a/fnl/plugins/treesitter-context.fnl b/fnl/plugins/treesitter-context.fnl index f7730bd..900889a 100644 --- a/fnl/plugins/treesitter-context.fnl +++ b/fnl/plugins/treesitter-context.fnl @@ -10,4 +10,6 @@ :separator nil :zindex 20}) -{1 :nvim-treesitter/nvim-treesitter-context :event [:BufReadPre :BufNewFile] : opts} +{1 :nvim-treesitter/nvim-treesitter-context + :event [:BufReadPre :BufNewFile] + : opts} diff --git a/fnl/plugins/treesitter.fnl b/fnl/plugins/treesitter.fnl index b75eba3..cc0b6cc 100644 --- a/fnl/plugins/treesitter.fnl +++ b/fnl/plugins/treesitter.fnl @@ -1,98 +1,196 @@ -;; Treesitter is a tool for building syntax trees for source files. -;; In the neovim context it helps with better coloring. +;; Treesitter parser installation and built-in feature configuration. -(local opts - {:ensure_installed [:bash - :c - :comment - :dockerfile - :elixir - :erlang - :fennel - :graphql - :haskell - :hcl - :html - :http - :json - :latex - :lua - :make - :markdown - :ocaml - :ocaml_interface - :python - :rust - :sql - :toml - :unison - :vim - :vimdoc - :xml - :yaml] - :sync_install false - :ignore_install [""] - :autopairs {:enable true} - :highlight {:enable true :additional_vim_regex_highlighting [:org]} - :context_commentstring {:enable true :enable_autocmd false} - :indent {:enable true :disable [:yaml :python :css]} - :playground {:enable true} - :textobjects {:select {:enable true - :lookahead true - :keymaps {:aa "@parameter.outer" - :ia "@parameter.inner" - :af "@function.outer" - :if "@function.inner" - :ii "@conditional.outer" - :ai "@conditional.inner" - :il "@loop.outer" - :al "@loop.inner" - :ac "@class.outer" - :at "@comment.outer" - :ic {:query "@class.inner" - :desc "Select inner part of a class region"} - :as {:query "@scope" - :query_group :locals - :desc "Select language scope"}} - :selection_modes {"@parameter.outer" :v - "@function.outer" :V - "@class.outer" :} - :include_surrounding_whitespace true} - :swap {:enable true - :swap_next {:a "@parameter.inner"} - :swap_previous {:A "@parameter.inner"}} - :move {:enable true - :set_jumps true - :goto_next_start {"]m" "@function.outer" - "]]" {:query "@class.outer" - :desc "Next class start"} - "]o" "@loop.*" - "]s" {:query "@scope" - :query_group :locals - :desc "Next scope"} - "]z" {:query "@fold" - :query_group :folds - :desc "Next fold"}} - :goto_next_end {"]M" "@function.outer" - "][" "@class.outer"} - :goto_previous_start {"[m" "@function.outer" - "[[" "@class.outer"} - :goto_previous_end {"[M" "@function.outer" - "[]" "@class.outer"} - :goto_next {"]i" "@conditional.outer"} - :goto_previous {"[i" "@conditional.outer"}} - :lsp_interop {:enable true - :border :single - :floating_preview_opts {} - :peek_definition_code {:md "@function.outer" - :mD "@class.outer"}}}}) +(import-macros {: autocmd : keymaps} :macros) + +(local parsers [:bash + :c + :comment + :dockerfile + :elixir + :erlang + :fennel + :graphql + :haskell + :hcl + :html + :http + :json + :latex + :lua + :make + :markdown + :markdown_inline + :ocaml + :ocaml_interface + :python + :rust + :sql + :toml + :unison + :vim + :vimdoc + :xml + :yaml]) + +(λ setup-textobjects [] + (let [textobjects (require :nvim-treesitter-textobjects) + select (require :nvim-treesitter-textobjects.select) + swap (require :nvim-treesitter-textobjects.swap) + move (require :nvim-treesitter-textobjects.move)] + (textobjects.setup {:select {:lookahead true + :selection_modes {"@parameter.outer" :v + "@function.outer" :V + "@class.outer" :} + :include_surrounding_whitespace true} + :move {:set_jumps true}}) + (keymaps [[:x :o] + :aa + (λ [] + (select.select_textobject "@parameter.outer" :textobjects)) + {}] [[:x :o] + :ia + (λ [] + (select.select_textobject "@parameter.inner" + :textobjects)) + {}] + [[:x :o] + :af + (λ [] + (select.select_textobject "@function.outer" :textobjects)) + {}] [[:x :o] + :if + (λ [] + (select.select_textobject "@function.inner" + :textobjects)) + {}] + [[:x :o] + :ii + (λ [] + (select.select_textobject "@conditional.outer" :textobjects)) + {}] [[:x :o] + :ai + (λ [] + (select.select_textobject "@conditional.inner" + :textobjects)) + {}] + [[:x :o] + :il + (λ [] + (select.select_textobject "@loop.outer" :textobjects)) + {}] [[:x :o] + :al + (λ [] + (select.select_textobject "@loop.inner" + :textobjects)) + {}] + [[:x :o] + :ac + (λ [] + (select.select_textobject "@class.outer" :textobjects)) + {}] [[:x :o] + :at + (λ [] + (select.select_textobject "@comment.outer" + :textobjects)) + {}] + [[:x :o] + :ic + (λ [] + (select.select_textobject "@class.inner" :textobjects)) + {}] [[:x :o] + :as + (λ [] + (select.select_textobject "@local.scope" + :locals)) + {}] ;; Swap + [:n + :a + (λ [] + (swap.swap_next "@parameter.inner")) + {}] [:n + :A + (λ [] + (swap.swap_previous "@parameter.inner")) + {}] ;; Move + [[:n :x :o] + "]m" + (λ [] + (move.goto_next_start "@function.outer" :textobjects)) + {}] [[:n :x :o] + "]]" + (λ [] + (move.goto_next_start "@class.outer" + :textobjects)) + {}] + [[:n :x :o] + "]o" + (λ [] + (move.goto_next_start ["@loop.inner" "@loop.outer"] + :textobjects)) + {}] [[:n :x :o] + "]s" + (λ [] + (move.goto_next_start "@local.scope" :locals)) + {}] + [[:n :x :o] + "]z" + (λ [] + (move.goto_next_start "@fold" :folds)) + {}] [[:n :x :o] + "]M" + (λ [] + (move.goto_next_end "@function.outer" + :textobjects)) + {}] + [[:n :x :o] + "][" + (λ [] + (move.goto_next_end "@class.outer" :textobjects)) + {}] [[:n :x :o] + "[m" + (λ [] + (move.goto_previous_start "@function.outer" + :textobjects)) + {}] + [[:n :x :o] + "[[" + (λ [] + (move.goto_previous_start "@class.outer" :textobjects)) + {}] [[:n :x :o] + "[M" + (λ [] + (move.goto_previous_end "@function.outer" + :textobjects)) + {}] + [[:n :x :o] + "[]" + (λ [] + (move.goto_previous_end "@class.outer" :textobjects)) + {}] [[:n :x :o] + "]i" + (λ [] + (move.goto_next "@conditional.outer" + :textobjects)) + {}] + [[:n :x :o] + "[i" + (λ [] + (move.goto_previous "@conditional.outer" :textobjects)) + {}]))) (λ config [] - (let [treesitter (require :nvim-treesitter.configs)] - (treesitter.setup opts))) + (let [treesitter (require :nvim-treesitter)] + (treesitter.install parsers)) + (autocmd :FileType + {:callback (λ [args] + (pcall vim.treesitter.start args.buf) + (tset vim.bo args.buf :indentexpr + "v:lua.require'nvim-treesitter'.indentexpr()"))}) + (setup-textobjects)) {1 :nvim-treesitter/nvim-treesitter - :dependencies [{1 :nvim-treesitter/nvim-treesitter-textobjects :lazy true}] + :branch :main + :dependencies [{1 :nvim-treesitter/nvim-treesitter-textobjects :branch :main}] :build ":TSUpdate" :event [:VeryLazy] : config} diff --git a/fnl/plugins/which-key.fnl b/fnl/plugins/which-key.fnl index 189a4a4..8b66834 100644 --- a/fnl/plugins/which-key.fnl +++ b/fnl/plugins/which-key.fnl @@ -37,18 +37,19 @@ :show_help true :disable {:filetypes [:netrw]}}) -(local groups [{:mode [:n :v] - 1 {1 :d :group :+diff} - 2 {1 :f :group :+find} - 3 {1 :g :group :+git} - 4 {1 :i :group :+db} - 5 {1 :j :group :+diagnostics} - 6 {1 :l :group :+lsp} - 7 {1 :o :group :+orgmode} - 8 {1 :r :group :+replace} - 9 {1 :s :group :+session} - 10 {1 :w :group :+worktree}} - {1 : 2 "bdelete" :desc "Close Buffer"}]) +(local groups + [{:mode [:n :v] + 1 {1 :d :group :+diff} + 2 {1 :f :group :+find} + 3 {1 :g :group :+git} + 4 {1 :i :group :+db} + 5 {1 :j :group :+diagnostics} + 6 {1 :l :group :+lsp} + 7 {1 :o :group :+orgmode} + 8 {1 :r :group :+replace} + 9 {1 :s :group :+session} + 10 {1 :w :group :+worktree}} + {1 : 2 :bdelete :desc "Close Buffer"}]) (λ config [] (let [which-key (require :which-key)] diff --git a/fnl/plugins/window-picker.fnl b/fnl/plugins/window-picker.fnl index 68b7786..fa03722 100644 --- a/fnl/plugins/window-picker.fnl +++ b/fnl/plugins/window-picker.fnl @@ -14,6 +14,6 @@ (let [window-picker (require :window-picker)] (window-picker.setup opts) (vim.keymap.set :n :mw (λ [] - (pick-window)) {}))) + (pick-window)) {}))) {1 :s1n7ax/nvim-window-picker :event :VeryLazy :version :2.0.0 : config} diff --git a/fnl/settings/autocmds.fnl b/fnl/settings/autocmds.fnl index 2f0a3cd..2dd0c71 100644 --- a/fnl/settings/autocmds.fnl +++ b/fnl/settings/autocmds.fnl @@ -2,29 +2,27 @@ (import-macros {: autocmds} :macros) -(autocmds - [:FileType - {:pattern [:qf :help :man :lspinfo] - :command "nnoremap q :close"}] - [:TextYankPost - {:callback (λ [] - (vim.highlight.on_yank {:higroup :Visual - :timeout 200}))}] - [:BufWinEnter {:command "setlocal formatoptions-=cro"}] - [:FileType {:pattern :qf :command "set nobuflisted"}] - [:FileType - {:pattern [:gitcommit :markdown] :command "setlocal wrap"}] - [:VimResized {:command "tabdo wincmd ="}] - [[:FocusGained :BufEnter :CursorHold :CursorHoldI] - {:pattern "*" - :callback (fn [] - (when (= (vim.fn.mode) :n) - (vim.cmd :checktime)))}] - [[:InsertLeave :WinEnter] - {:callback (λ [] - (let [cursorline (require :settings.cursorline)] - cursorline.show))}] - [[:InsertEnter :WinLeave] - {:callback (λ [] - (let [cursorline (require :settings.cursorline)] - cursorline.hide))}]) +(autocmds [:FileType + {:pattern [:qf :help :man :lspinfo] + :command "nnoremap q :close"}] + [:TextYankPost + {:callback (λ [] + (vim.highlight.on_yank {:higroup :Visual :timeout 200}))}] + [:BufWinEnter {:command "setlocal formatoptions-=cro"}] + [:FileType {:pattern :qf :command "set nobuflisted"}] + [:FileType + {:pattern [:gitcommit :markdown] :command "setlocal wrap"}] + [:VimResized {:command "tabdo wincmd ="}] + [[:FocusGained :BufEnter :CursorHold :CursorHoldI] + {:pattern "*" + :callback (fn [] + (when (= (vim.fn.mode) :n) + (vim.cmd :checktime)))}] + [[:InsertLeave :WinEnter] + {:callback (λ [] + (let [cursorline (require :settings.cursorline)] + cursorline.show))}] + [[:InsertEnter :WinLeave] + {:callback (λ [] + (let [cursorline (require :settings.cursorline)] + cursorline.hide))}]) diff --git a/fnl/settings/init.fnl b/fnl/settings/init.fnl index d01d848..4bb0e4c 100644 --- a/fnl/settings/init.fnl +++ b/fnl/settings/init.fnl @@ -1,12 +1,12 @@ ;; Load nvim settings +(import-macros {: autocmd} :macros) + (require :settings.options) (require :settings.terminal) -(vim.api.nvim_create_autocmd :User - {:group (vim.api.nvim_create_augroup :Lazy - {:clear true}) - :pattern :VeryLazy - :callback (λ [] - (require :settings.autocmds) - (require :settings.keymaps))}) +(autocmd :User {:group (vim.api.nvim_create_augroup :Lazy {:clear true}) + :pattern :VeryLazy + :callback (λ [] + (require :settings.autocmds) + (require :settings.keymaps))}) diff --git a/fnl/settings/keymaps.fnl b/fnl/settings/keymaps.fnl index fcc7511..d10b34e 100644 --- a/fnl/settings/keymaps.fnl +++ b/fnl/settings/keymaps.fnl @@ -2,33 +2,19 @@ (import-macros {: keymaps} :macros) -(keymaps - ;; Resize with arrows - [:n : :+ {}] - [:n : :- {}] - [:n "" :5< {}] - [:n : :5> {}] - ;; Stay in indent mode - [:v "<" :" :>gv {}] - ;; Move text up and down - [:x :J ":move '>+1gv-gv" {}] - [:x :K ":move '<-2gv-gv" {}] - [:v : ":m .+1==" {}] - [:v : ":m .-2==" {}] - [:v :p "\"_dP" {}] - ;; Splits - [:n : :split {}] - [:n : :vsplit {}] - ;; Buf navigation - [:n : :bprev {}] - [:n : :bnext {}] - ;; Jump half a page and centralize the view - [:n : :zz {}] - [:n : :zz {}] - ;; Remove highlighted search - [:n : :nohlsearch {}] - ;; Jump to eol in insert mode - [:i : :$ {}] - ;; Force refresh - [:n :mj ":e" {:desc :Refresh}]) +(keymaps ;; Resize with arrows + [:n : :+ {}] [:n : :- {}] [:n "" :5< {}] + [:n : :5> {}] ;; Stay in indent mode + [:v "<" :" :>gv {}] ;; Move text up and down + [:x :J ":move '>+1gv-gv" {}] [:x :K ":move '<-2gv-gv" {}] + [:v : ":m .+1==" {}] [:v : ":m .-2==" {}] + [:v :p "\"_dP" {}] ;; Splits + [:n : :split {}] [:n : :vsplit {}] + ;; Buf navigation + [:n : :bprev {}] [:n : :bnext {}] + ;; Jump half a page and centralize the view + [:n : :zz {}] [:n : :zz {}] + ;; Remove highlighted search + [:n : :nohlsearch {}] ;; Jump to eol in insert mode + [:i : :$ {}] ;; Force refresh + [:n :mj ":e" {:desc :Refresh}]) diff --git a/fnl/settings/terminal.fnl b/fnl/settings/terminal.fnl index 16464ee..ca18327 100644 --- a/fnl/settings/terminal.fnl +++ b/fnl/settings/terminal.fnl @@ -1,3 +1,5 @@ +(import-macros {: keymap} :macros) + (local state {:buf -1 :win -1}) (fn hide-term [] @@ -10,7 +12,7 @@ (if (not (vim.api.nvim_buf_is_valid state.buf)) (do (set state.buf (vim.api.nvim_get_current_buf)) - (vim.fn.termopen vim.o.shell) + (vim.cmd.terminal) (set vim.opt_local.number false) (set vim.opt_local.relativenumber false) (set vim.opt_local.signcolumn :no)) @@ -22,4 +24,4 @@ (hide-term) (open-term))) -(vim.keymap.set [:n :t] : toggle-term {:desc "Toggle terminal"}) +(keymap [:n :t] : toggle-term {:desc "Toggle terminal"}) -- cgit v1.2.3-70-g09d2