diff options
author | Gustaf Rydholm <gustaf@nexure.io> | 2022-10-18 11:35:46 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf@nexure.io> | 2022-10-18 11:35:46 +0200 |
commit | c84be23430181db27200d0ec6def0e23817ea88d (patch) | |
tree | 2e13945842f7286d91c63035f7e73f91653d675f /fnl | |
parent | f9c022399a35558fe7f997dbeab3c26d7f955992 (diff) | |
parent | e16303d85286e5661093e2029d54593e3a3481ec (diff) |
Merge branch 'master' of github.com:aktersnurra/nvim
Diffstat (limited to 'fnl')
-rw-r--r-- | fnl/config/cmd.fnl | 68 | ||||
-rw-r--r-- | fnl/config/orgmode.fnl | 6 | ||||
-rw-r--r-- | fnl/config/which-key.fnl | 35 | ||||
-rw-r--r-- | fnl/init.fnl | 4 | ||||
-rw-r--r-- | fnl/plugins.fnl | 9 |
5 files changed, 90 insertions, 32 deletions
diff --git a/fnl/config/cmd.fnl b/fnl/config/cmd.fnl new file mode 100644 index 0000000..20ef377 --- /dev/null +++ b/fnl/config/cmd.fnl @@ -0,0 +1,68 @@ +;; Commands for plugins. +(module config.cmd {autoload {nvim aniseed.nvim util config.util}}) + +(nvim.create_user_command :OrgAgendaPrompt + (lambda [] + (let [orgmode (util.prequire :orgmode)] + (orgmode.action :agenda.prompt))) + {:nargs 0}) + +(nvim.create_user_command :OrgCapturePrompt + (lambda [] + (let [orgmode (util.prequire :orgmode)] + (orgmode.action :capture.prompt))) + {:nargs 0}) + +(nvim.create_user_command :CommentNormal + (lambda [] + (let [comment-api (util.prequire :Comment.api)] + (comment-api.toggle.linewise.current))) + {:nargs 0}) + +(nvim.create_user_command :CommentVisual + (lambda [] + (let [comment-api (util.prequire :Comment.api)] + (comment-api.toggle.linewise (vim.fn.visualmode)))) + {:nargs 0}) + +(nvim.create_user_command :HarpoonAdd + (lambda [] + (let [harpoon (util.prequire :harpoon.mark)] + (harpoon.add_file))) + {:nargs 0}) + +(nvim.create_user_command :HarpoonNext + (lambda [] + (let [harpoon (util.prequire :harpoon.ui)] + (harpoon.nav_next))) + {:nargs 0}) + +(nvim.create_user_command :HarpoonPrev + (lambda [] + (let [harpoon (util.prequire :harpoon.ui)] + (harpoon.nav_prev))) + {:nargs 0}) + +(nvim.create_user_command :HarpoonUI + (lambda [] + (let [harpoon (util.prequire :harpoon.ui)] + (harpoon.toggle_quick_menu))) + {:nargs 0}) + +(nvim.create_user_command :Replace + (lambda [] + (let [spectre (util.prequire :spectre)] + (spectre.open))) + {:nargs 0}) + +(nvim.create_user_command :ReplaceWord + (lambda [] + (let [spectre (util.prequire :spectre)] + (spectre.open.open_visual {:select_word true}))) + {:nargs 0}) + +(nvim.create_user_command :ReplaceInBuf + (lambda [] + (let [spectre (util.prequire :spectre)] + (spectre.open_file_search))) + {:nargs 0}) diff --git a/fnl/config/orgmode.fnl b/fnl/config/orgmode.fnl index a21eaa0..216fe4c 100644 --- a/fnl/config/orgmode.fnl +++ b/fnl/config/orgmode.fnl @@ -5,10 +5,8 @@ (nvim.ex.set :concealcursor=nc) (def- templates - {:t {:description :Task - :template "* TODO %?\n %u\n DEADLINE: %T\n"} - :m {:description :Meeting - :template "* Meeting %?"} + {:t {:description :Task :template "* TODO %?\n %u\n DEADLINE: %T\n"} + :m {:description :Meeting :template "* Meeting %?"} :n {:description :Note :template "* NOTE %? :NOTE:\n %u\n"}}) (defn- create-title [task] diff --git a/fnl/config/which-key.fnl b/fnl/config/which-key.fnl index 1412c1a..11a6dce 100644 --- a/fnl/config/which-key.fnl +++ b/fnl/config/which-key.fnl @@ -35,8 +35,7 @@ :noremap true :nowait true}) -(def- mmappings {:a ["<cmd>lua require('harpoon.mark').add_file()<cr>" - :Harpoon] +(def- mmappings {:a [:<cmd>HarpoonAdd<cr> :Harpoon] :b ["<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{sort_lastused = true, initial_mode = 'normal', previewer = false})<cr>" "Switch buffers"] :c [:<cmd>DiffviewClose<cr> :DiffviewClose] @@ -46,16 +45,11 @@ :f ["<cmd>lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})<cr>" "Find files"] :g ["<cmd>Telescope live_grep theme=ivy<cr>" "Find text"] - :l ["<cmd>lua require('harpoon.ui').nav_next()<cr>" - "Harpoon Next"] - :h ["<cmd>lua require('harpoon.ui').nav_prev()<cr>" - "Harpoon Prev"] - :t ["<cmd>Telescope harpoon marks theme=dropdown<cr>" - "Search Harpoon"] + :l [:<cmd>HarpoonNext<cr> "Harpoon Next"] + :h [:<cmd>HarpoonPrev<cr> "Harpoon Prev"] :v ["<cmd>lua vim.lsp.buf.rename()<cr>" :Rename] :p [:<cmd>SaveSession<cr> "Save Session"] - :r ["<cmd>lua require('harpoon.ui').toggle_quick_menu()<cr>" - "Harpoon UI"] + :r [:<cmd>HarpoonUI<cr> "Harpoon UI"] :n [:<cmd>Neogit<cr> :Neogit]}) (def- nopts {:mode :n @@ -124,11 +118,9 @@ :u [:<cmd>PackerUpdate<cr> :Update]}) (def- replace {:name :Replace - :r ["<cmd>lua require('spectre').open()<cr>" :Replace] - :w ["<cmd>lua require('spectre').open_visual({select_word=true})<cr>" - "Replace Word"] - :f ["<cmd>lua require('spectre').open_file_search()<cr>" - "Replace Buffer"]}) + :r [:<cmd>Replace<cr> :Replace] + :w [:<cmd>ReplaceWord<cr> "Replace Word"] + :f [:<cmd>ReplaceInBuf<cr> "Replace Buffer"]}) (def- treesitter {:name :Treesitter :p [:<cmd>TSPlaygroundToggle<cr> :Playground]}) @@ -147,8 +139,7 @@ :g git :h [:<cmd>ColorizerToggle<cr> :Colorizer] :l lsp - :n ["<cmd>lua require('Comment.api').toggle.linewise.current()<CR>" - :Comment] + :n [:<cmd>CommentNormal<CR> :Comment] :p packer :r replace :u [:<cmd>UndotreeToggle<cr> :Undotree] @@ -164,8 +155,7 @@ :noremap true :nowait true}) -(def- vmappings {:n ["<ESC><CMD>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>" - :Comment]}) +(def- vmappings {:n [:<esc><cmd>CommentVisual<cr> :Comment]}) (def- gopts {:mode :n :prefix :g @@ -174,10 +164,9 @@ :noremap true :nowait true}) -(def- gmappings {:a ["<cmd>lua require('orgmode').action('agenda.prompt')<cr>" - "Open agenda prompt"] - :c ["<cmd>lua require('orgmode').action('capture.prompt')<cr>" - "Open capture prompt"]}) +(def- gmappings + {:a [:<cmd>OrgAgendaPrompt<cr> "Open agenda prompt"] + :c [:<cmd>OrgCapturePrompt<cr> "Open capture prompt"]}) (let [which-key (util.prequire :which-key)] (which-key.setup setup) diff --git a/fnl/init.fnl b/fnl/init.fnl index 2e25da9..a28d2b6 100644 --- a/fnl/init.fnl +++ b/fnl/init.fnl @@ -1,5 +1,7 @@ ;; Load plugins with packer. -(module init {autoload {: plugins : packer} require [settings config.packer config.autocmd]}) +(module init + {autoload {: plugins : packer} + require [settings config.packer config.autocmd config.cmd]}) (packer.startup (fn [use] (each [_ plugin (pairs plugins.all)] diff --git a/fnl/plugins.fnl b/fnl/plugins.fnl index 13da672..c0195bd 100644 --- a/fnl/plugins.fnl +++ b/fnl/plugins.fnl @@ -76,7 +76,7 @@ (require :config.trouble))}]) (def misc [{1 :nvim-orgmode/orgmode - :event :BufReadPre + :event :BufRead :config (fn [] (require :config.orgmode))} {1 :moll/vim-bbye :event :BufRead} @@ -106,11 +106,12 @@ :config (fn [] (require :config.flit))} {1 :ahmedkhalf/project.nvim + :event :VimEnter :requires :nvim-telescope/telescope.nvim :config (fn [] (require :config.project))} {1 :windwp/nvim-spectre - :event :InsertEnter + :cmd [:Replace :ReplaceWord :ReplaceInBuf] :config (fn [] (require :config.spectre))} {1 :junegunn/vim-slash @@ -118,7 +119,7 @@ :config (fn [] (require :config.vim-slash))} {1 :ThePrimeagen/harpoon - :event :InsertEnter + :cmd [:HapoonAdd :HapoonNext :HapoonPrev :HarpoonUI] :requires :nvim-telescope/telescope.nvim :config (fn [] (require :config.harpoon))}]) @@ -133,7 +134,7 @@ (def snippets [:rafamadriz/friendly-snippets]) (def text [{1 :numToStr/Comment.nvim - :event :InsertEnter + :cmd [:CommentNormal :CommentVisual] :config (fn [] (require :config.comment))} {1 :JoosepAlviste/nvim-ts-context-commentstring :event :BufReadPost} |