summaryrefslogtreecommitdiff
path: root/fnl
diff options
context:
space:
mode:
Diffstat (limited to 'fnl')
-rw-r--r--fnl/config.fnl3
-rw-r--r--fnl/macros.fnlm41
-rw-r--r--fnl/plugins/leap.fnl11
-rw-r--r--fnl/plugins/lsp.fnl12
-rw-r--r--fnl/plugins/nvim-lint.fnl6
-rw-r--r--fnl/plugins/octo.fnl15
-rw-r--r--fnl/plugins/snippets.fnl33
-rw-r--r--fnl/plugins/treesitter.fnl166
-rw-r--r--fnl/plugins/window-picker.fnl5
9 files changed, 125 insertions, 167 deletions
diff --git a/fnl/config.fnl b/fnl/config.fnl
index 657c954..4e0eb0a 100644
--- a/fnl/config.fnl
+++ b/fnl/config.fnl
@@ -1,4 +1,5 @@
;; Load plugins with lazy.
+(import-macros {: keymap} :macros)
(λ load-plugin [tbl name]
(table.insert tbl (require (.. :plugins. name))))
@@ -51,7 +52,7 @@
(each [fname type (vim.fs.dir (.. (vim.fn.stdpath :config) :/fnl/plugins))]
(when (= type :file)
(load-plugin plugins (fname:match "^(.*)%.fnl$"))))
- (vim.keymap.set :n :<leader>y "<cmd>Lazy home<cr>" {:desc :Home})
+ (keymap :n :<leader>y "<cmd>Lazy home<cr>" {:desc :Home})
(lazy.setup plugins opts)))
(init)
diff --git a/fnl/macros.fnlm b/fnl/macros.fnlm
index 8267518..edfca30 100644
--- a/fnl/macros.fnlm
+++ b/fnl/macros.fnlm
@@ -33,4 +33,43 @@
(table.insert out `(tset vim.opt ,k ,v)))
out))
-{: autocmd : autocmds : user-cmd : user-cmds : keymap : keymaps : set-opts}
+(fn ts-selects [...]
+ "Generate treesitter select keymaps. Each entry: [key query ?group].
+ Modes are always [:x :o]. Assumes `select` is in scope."
+ (let [out `(do)]
+ (each [_ entry (ipairs [...])]
+ (let [key (. entry 1)
+ query (. entry 2)
+ group (or (. entry 3) :textobjects)]
+ (table.insert out
+ `(vim.keymap.set [:x :o] ,key
+ (λ [] (select.select_textobject ,query ,group)) {}))))
+ out))
+
+(fn ts-swaps [...]
+ "Generate treesitter swap keymaps. Each entry: [key method query].
+ Mode is always :n. method is a symbol like swap.swap_next."
+ (let [out `(do)]
+ (each [_ entry (ipairs [...])]
+ (let [key (. entry 1)
+ method (. entry 2)
+ query (. entry 3)]
+ (table.insert out
+ `(vim.keymap.set :n ,key (λ [] (,method ,query)) {}))))
+ out))
+
+(fn ts-moves [...]
+ "Generate treesitter move keymaps. Each entry: [key method query ?group].
+ Modes are always [:n :x :o]. method is a symbol like move.goto_next_start."
+ (let [out `(do)]
+ (each [_ entry (ipairs [...])]
+ (let [key (. entry 1)
+ method (. entry 2)
+ query (. entry 3)
+ group (or (. entry 4) :textobjects)]
+ (table.insert out
+ `(vim.keymap.set [:n :x :o] ,key (λ [] (,method ,query ,group)) {}))))
+ out))
+
+{: autocmd : autocmds : user-cmd : user-cmds : keymap : keymaps : set-opts
+ : ts-selects : ts-swaps : ts-moves}
diff --git a/fnl/plugins/leap.fnl b/fnl/plugins/leap.fnl
index d6ec18e..8f49390 100644
--- a/fnl/plugins/leap.fnl
+++ b/fnl/plugins/leap.fnl
@@ -1,4 +1,5 @@
;; Leap through text.
+(import-macros {: keymaps} :macros)
(local dependencies [{1 :tpope/vim-repeat :event :VeryLazy}
{1 :aktersnurra/leap-spooky.nvim
@@ -27,11 +28,11 @@
(λ config []
(let [leap (require :leap)]
(tset leap.opts.vim_opts :go.ignorecase false)
- (vim.keymap.set [:n :x :o] :s "<Plug>(leap-forward)")
- (vim.keymap.set [:n :x :o] :S "<Plug>(leap-backward)")
- (vim.keymap.set [:x :o] :x "<Plug>(leap-forward-till)")
- (vim.keymap.set [:x :o] :X "<Plug>(leap-backward-till)")
- (vim.keymap.set [:n] :gs "<Plug>(leap-from-window)")))
+ (keymaps [[:n :x :o] :s "<Plug>(leap-forward)" {}]
+ [[:n :x :o] :S "<Plug>(leap-backward)" {}]
+ [[:x :o] :x "<Plug>(leap-forward-till)" {}]
+ [[:x :o] :X "<Plug>(leap-backward-till)" {}]
+ [[:n] :gs "<Plug>(leap-from-window)" {}])))
{:url "https://codeberg.org/andyg/leap.nvim"
: dependencies
diff --git a/fnl/plugins/lsp.fnl b/fnl/plugins/lsp.fnl
index 482916a..2ac3683 100644
--- a/fnl/plugins/lsp.fnl
+++ b/fnl/plugins/lsp.fnl
@@ -1,10 +1,12 @@
;; LSP configuration.
+(import-macros {: autocmd} :macros)
+
(λ config []
- (vim.api.nvim_create_autocmd :LspAttach
- {:callback (λ [args]
- (let [{: on-attach} (require :plugins.lsp.keymaps)]
- (on-attach args.buf)))})
+ (autocmd :LspAttach
+ {:callback (λ [args]
+ (let [{: on-attach} (require :plugins.lsp.keymaps)]
+ (on-attach args.buf)))})
(let [diagnostics (require :plugins.lsp.diagnostics)
mason-lspconfig (require :plugins.lsp.mason-lspconfig)]
(diagnostics.setup)
@@ -13,7 +15,7 @@
(local icons (require :settings.icons))
[{1 :neovim/nvim-lspconfig
- :event :BufNew
+ :event [:BufReadPre :BufNewFile]
:dependencies [:mason.nvim
:williamboman/mason-lspconfig.nvim
:b0o/schemastore.nvim
diff --git a/fnl/plugins/nvim-lint.fnl b/fnl/plugins/nvim-lint.fnl
index 040bcc4..604b8ab 100644
--- a/fnl/plugins/nvim-lint.fnl
+++ b/fnl/plugins/nvim-lint.fnl
@@ -7,9 +7,9 @@
(lint.try_lint)))
(λ init []
- (let [lint-augroup (vim.api.nvim_create_augroup :lint {:clear true})]
- (autocmd [:BufEnter :BufWritePost :InsertLeave :TextChangedI]
- {:group lint-augroup : callback})))
+ (autocmd [:BufEnter :BufWritePost :InsertLeave :TextChangedI]
+ {:group (vim.api.nvim_create_augroup :lint {:clear true})
+ : callback}))
(λ config []
(let [lint (require :lint)]
diff --git a/fnl/plugins/octo.fnl b/fnl/plugins/octo.fnl
new file mode 100644
index 0000000..b97afe6
--- /dev/null
+++ b/fnl/plugins/octo.fnl
@@ -0,0 +1,15 @@
+;; GitHub PR and issue management.
+
+{1 :pwntester/octo.nvim
+ :dependencies [:nvim-lua/plenary.nvim
+ :nvim-telescope/telescope.nvim
+ :nvim-tree/nvim-web-devicons]
+ :cmd :Octo
+ :keys [{1 :<leader>Ol 2 "<cmd>Octo pr list<cr>" :desc "List PRs"}
+ {1 :<leader>Os 2 "<cmd>Octo review start<cr>" :desc "Review Start"}
+ {1 :<leader>Or 2 "<cmd>Octo review resume<cr>" :desc "Review Resume"}
+ {1 :<leader>Od 2 "<cmd>Octo review discard<cr>" :desc "Review Discard"}
+ {1 :<leader>Om 2 "<cmd>Octo review submit<cr>" :desc "Review Submit"}
+ {1 :<leader>Oc 2 "<cmd>Octo review comments<cr>" :desc "Review Comments"}
+ {1 :<leader>Oi 2 "<cmd>Octo issue list<cr>" :desc "List Issues"}]
+ :opts {}}
diff --git a/fnl/plugins/snippets.fnl b/fnl/plugins/snippets.fnl
index 70917ba..6dd317e 100644
--- a/fnl/plugins/snippets.fnl
+++ b/fnl/plugins/snippets.fnl
@@ -1,4 +1,5 @@
;; Snippets functionality.
+(import-macros {: keymaps} :macros)
(local dependencies [:rafamadriz/friendly-snippets])
@@ -16,19 +17,23 @@
(add-snippets (fname:match "^(.*)%.fnl$"))))
(ls.config.set_config {:history true
:updateevents "TextChanged,TextChangedI"})
- (vim.keymap.set [:i :s] :<c-u>
- (λ []
- (when (ls.expand_or_jumpable)
- (ls.expand_or_jump))) {:silent true})
- (vim.keymap.set [:i :s] :<c-l>
- (λ []
- (when (ls.jumpable -1)
- (ls.jump -1))
- {:silent true}))
- (vim.keymap.set [:i] :<c-j>
- (λ []
- (when (ls.choice_active)
- (ls.change_choice 1)))
- {:silent true})))
+ (keymaps [[:i :s]
+ :<c-u>
+ (λ []
+ (when (ls.expand_or_jumpable)
+ (ls.expand_or_jump)))
+ {:silent true}]
+ [[:i :s]
+ :<c-l>
+ (λ []
+ (when (ls.jumpable -1)
+ (ls.jump -1)))
+ {:silent true}]
+ [[:i]
+ :<c-j>
+ (λ []
+ (when (ls.choice_active)
+ (ls.change_choice 1)))
+ {:silent true}])))
{1 :L3MON4D3/LuaSnip :event :InsertEnter : config : dependencies}
diff --git a/fnl/plugins/treesitter.fnl b/fnl/plugins/treesitter.fnl
index cc0b6cc..300bdfd 100644
--- a/fnl/plugins/treesitter.fnl
+++ b/fnl/plugins/treesitter.fnl
@@ -1,6 +1,6 @@
;; Treesitter parser installation and built-in feature configuration.
-(import-macros {: autocmd : keymaps} :macros)
+(import-macros {: autocmd : ts-selects : ts-swaps : ts-moves} :macros)
(local parsers [:bash
:c
@@ -32,151 +32,45 @@
:xml
:yaml])
+;; fnlfmt: skip
(λ 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
+ :selection_modes {"@parameter.outer" :v
"@function.outer" :V
"@class.outer" :<c-v>}
: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
- :<leader>a
- (λ []
- (swap.swap_next "@parameter.inner"))
- {}] [:n
- :<leader>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))
- {}])))
+ (ts-selects [: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 "@class.inner"]
+ [:as "@local.scope" :locals]
+ [:ar "@return.outer"]
+ [:ir "@return.inner"]
+ [:a= "@assignment.outer"]
+ [:i= "@assignment.inner"])
+ (ts-swaps [:<leader>a swap.swap_next "@parameter.inner"]
+ [:<leader>A swap.swap_previous "@parameter.inner"])
+ (ts-moves ["]m" move.goto_next_start "@function.outer"]
+ ["]]" move.goto_next_start "@class.outer"]
+ ["]o" move.goto_next_start ["@loop.inner" "@loop.outer"]]
+ ["]s" move.goto_next_start "@local.scope" :locals]
+ ["]z" move.goto_next_start "@fold" :folds]
+ ["]M" move.goto_next_end "@function.outer"]
+ ["][" move.goto_next_end "@class.outer"]
+ ["[m" move.goto_previous_start "@function.outer"]
+ ["[[" move.goto_previous_start "@class.outer"]
+ ["[M" move.goto_previous_end "@function.outer"]
+ ["[]" move.goto_previous_end "@class.outer"]
+ ["]i" move.goto_next "@conditional.outer"]
+ ["[i" move.goto_previous "@conditional.outer"]
+ ["]a" move.goto_next_start "@parameter.outer"]
+ ["[a" move.goto_previous_start "@parameter.outer"])))
(λ config []
(let [treesitter (require :nvim-treesitter)]
diff --git a/fnl/plugins/window-picker.fnl b/fnl/plugins/window-picker.fnl
index fa03722..7ddafa5 100644
--- a/fnl/plugins/window-picker.fnl
+++ b/fnl/plugins/window-picker.fnl
@@ -1,4 +1,5 @@
;; Select buffer
+(import-macros {: keymap} :macros)
(local opts {:other_win_hl_color "#171717"
:fg_color "#E1E1E1"
@@ -13,7 +14,7 @@
(λ config []
(let [window-picker (require :window-picker)]
(window-picker.setup opts)
- (vim.keymap.set :n :mw (λ []
- (pick-window)) {})))
+ (keymap :n :mw (λ []
+ (pick-window)) {})))
{1 :s1n7ax/nvim-window-picker :event :VeryLazy :version :2.0.0 : config}