diff options
Diffstat (limited to 'fnl/settings')
-rw-r--r-- | fnl/settings/autocmds.fnl | 38 | ||||
-rw-r--r-- | fnl/settings/init.fnl | 3 | ||||
-rw-r--r-- | fnl/settings/usercmds.fnl | 87 |
3 files changed, 5 insertions, 123 deletions
diff --git a/fnl/settings/autocmds.fnl b/fnl/settings/autocmds.fnl index a646130..5a2a145 100644 --- a/fnl/settings/autocmds.fnl +++ b/fnl/settings/autocmds.fnl @@ -2,48 +2,18 @@ (local cursorline (require :util.cursorline)) -(local autocmds - [[:FileType - {:pattern [:qf :help :man :lspinfo :spectre_panel] - :command "nnoremap <silent> <buffer> q :close<CR>"}] - [:TextYankPost +(local auto-cmds + [[:TextYankPost {:callback (lambda [] (vim.highlight.on_yank {:higroup :Visual :timeout 200}))}] - [:FileType - {:pattern :lir - :callback (fn [] - (tset vim.opt_local :number false) - (tset vim.opt_local :relativenumber false))}] [:BufWinEnter {:command "setlocal formatoptions-=cro"}] - [:FileType - {:pattern :org - :callback (fn [] - (tset vim.opt_local :conceallevel 2) - (tset vim.opt_local :concealcursor :nc))}] [:FileType {:pattern :qf :command "set nobuflisted"}] [:FileType {:pattern [:gitcommit :markdown] :command "setlocal wrap"}] - [:FileType - {:pattern [:NeogitStatus - :NeogitCommitMessage - :NeogitNotification - :NeogitCommitView - :spectre_panel] - :command "setlocal spell!"}] - [:TermOpen - {:pattern ["term://*toggleterm#*"] :command "setlocal spell!"}] [:VimResized {:command "tabdo wincmd ="}] [[:FocusGained :BufEnter :CursorHold :CursorHoldI] {:command :checktime}] - [:TermOpen - {:pattern "term://*toggleterm#*" - :callback (fn [] - (vim.keymap.set :t :<C-h> "<Cmd>wincmd h<CR>" {}) - (vim.keymap.set :t :<C-j> "<Cmd>wincmd j<CR>" {}) - (vim.keymap.set :t :<C-k> "<Cmd>wincmd k<CR>" {}) - (vim.keymap.set :t :<C-l> "<Cmd>wincmd l<CR>" {}))}] [[:InsertLeave :WinEnter] {:callback cursorline.show}] [[:InsertEnter :WinLeave] {:callback cursorline.hide}]]) -(each [_ autocmd (ipairs autocmds)] - (match autocmd - [event opts] (vim.api.nvim_create_autocmd event opts))) +(let [cmds (require :util.cmds)] + (cmds.create-auto-cmds auto-cmds)) diff --git a/fnl/settings/init.fnl b/fnl/settings/init.fnl index 3caa86b..dd392a8 100644 --- a/fnl/settings/init.fnl +++ b/fnl/settings/init.fnl @@ -8,5 +8,4 @@ :pattern :VeryLazy :callback (lambda [] (require :settings.autocmds) - (require :settings.keymaps) - (require :settings.usercmds))}) + (require :settings.keymaps))}) diff --git a/fnl/settings/usercmds.fnl b/fnl/settings/usercmds.fnl deleted file mode 100644 index 002e1b2..0000000 --- a/fnl/settings/usercmds.fnl +++ /dev/null @@ -1,87 +0,0 @@ -;; Commands for plugins. - -(fn telescope-builtin [builtin opts] - (let [telescope (require :telescope.builtin) - themes (require :telescope.themes) - theme (. opts :theme)] - ((. telescope builtin) ((. themes theme) opts)))) - -(local usercmds [[:OrgAgendaPrompt - (lambda [] - (let [orgmode (require :orgmode)] - (orgmode.action :agenda.prompt))) - {:nargs 0}] - [:OrgCapturePrompt - (lambda [] - (let [orgmode (require :orgmode)] - (orgmode.action :capture.prompt))) - {:nargs 0}] - [:CommentNormal - (lambda [] - (let [comment-api (require :Comment.api)] - (comment-api.toggle.linewise.current))) - {:nargs 0}] - [:CommentVisual - (lambda [] - (let [comment-api (require :Comment.api)] - (comment-api.toggle.linewise (vim.fn.visualmode)))) - {:nargs 0}] - [:HarpoonAdd - (lambda [] - (let [harpoon (require :harpoon.mark)] - (harpoon.add_file))) - {:nargs 0}] - [:HarpoonNext - (lambda [] - (let [harpoon (require :harpoon.ui)] - (harpoon.nav_next))) - {:nargs 0}] - [:HarpoonPrev - (lambda [] - (let [harpoon (require :harpoon.ui)] - (harpoon.nav_prev))) - {:nargs 0}] - [:HarpoonUI - (lambda [] - (let [harpoon (require :harpoon.ui)] - (harpoon.toggle_quick_menu))) - {:nargs 0}] - [:Replace - (lambda [] - (let [spectre (require :spectre)] - (spectre.open))) - {:nargs 0}] - [:ReplaceWord - (lambda [] - (let [spectre (require :spectre)] - (spectre.open_visual {:select_word true}))) - {:nargs 0}] - [:ReplaceInBuf - (lambda [] - (let [spectre (require :spectre)] - (spectre.open_file_search))) - {:nargs 0}] - [:RestoreSession - (lambda [] - (let [persistence (require :persistence)] - (persistence.load))) - {:nargs 0}] - [:RestoreLastSession - (lambda [] - (let [persistence (require :persistence)] - (persistence.load {:last true}))) - {:nargs 0}] - [:IgnoreSession - (lambda [] - (let [persistence (require :persistence)] - (persistence.stop))) - {:nargs 0}] - [:FindFiles - (lambda [] - (telescope-builtin :find_files - {:theme :get_dropdown :previewer false})) - {:nargs 0}]]) - -(each [_ usercmd (ipairs usercmds)] - (match usercmd - [event cmd opts] (vim.api.nvim_create_user_command event cmd opts))) |