diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2023-01-11 00:41:17 +0100 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2023-01-11 00:41:17 +0100 |
commit | f318452070d42e51231f7880a5d0eaa93d978a1e (patch) | |
tree | c76f35889ebc7a4e52bbd06e07c8f33f9bf68f5d /fnl/settings | |
parent | 433952cf3efa8e2b5e23ff0e76a4afe6f95d44b5 (diff) |
Rip aniseed, hail hotpot
Diffstat (limited to 'fnl/settings')
-rw-r--r-- | fnl/settings/autocmds.fnl | 48 | ||||
-rw-r--r-- | fnl/settings/init.fnl | 12 | ||||
-rw-r--r-- | fnl/settings/keymaps.fnl | 7 | ||||
-rw-r--r-- | fnl/settings/options.fnl | 19 | ||||
-rw-r--r-- | fnl/settings/usercmds.fnl | 98 |
5 files changed, 167 insertions, 17 deletions
diff --git a/fnl/settings/autocmds.fnl b/fnl/settings/autocmds.fnl new file mode 100644 index 0000000..5ae8b8c --- /dev/null +++ b/fnl/settings/autocmds.fnl @@ -0,0 +1,48 @@ +;; Autocommands for nvim. + +(fn create-autocmd [event opts] + (vim.api.nvim_create_autocmd event opts)) + +(create-autocmd :FileType + {:pattern [:qf :help :man :lspinfo :spectre_panel] + :command "nnoremap <silent> <buffer> q :close<CR>"}) + +(create-autocmd :TextYankPost + {:callback (lambda [] + (vim.highlight.on_yank {:higroup :Visual + :timeout 200}))}) + +(create-autocmd :FileType {:pattern :lir + :callback (fn [] + (tset vim.opt_local :number false) + (tset vim.opt_local :relativenumber + false))}) + +(create-autocmd :BufWinEnter {:command "setlocal formatoptions-=cro"}) + +(create-autocmd :FileType {:pattern :qf :command "set nobuflisted"}) + +(create-autocmd :FileType {:pattern [:gitcommit :markdown] + :command "setlocal wrap"}) + +(create-autocmd :FileType + {:pattern [:NeogitStatus + :NeogitCommitMessage + :NeogitNotification + :NeogitCommitView] + :command "setlocal spell!"}) + +(create-autocmd :TermOpen + {:pattern ["term://*toggleterm#*"] :command "setlocal spell!"}) + +(create-autocmd :VimResized {:command "tabdo wincmd ="}) + +(create-autocmd :FocusGained {:command :checktime}) + +(create-autocmd :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>" {}))}) diff --git a/fnl/settings/init.fnl b/fnl/settings/init.fnl index a6f74fb..3caa86b 100644 --- a/fnl/settings/init.fnl +++ b/fnl/settings/init.fnl @@ -1,2 +1,12 @@ ;; Load nvim settings -(module settings {require [settings.options settings.keymaps]}) + +(require :settings.options) + +(vim.api.nvim_create_autocmd :User + {:group (vim.api.nvim_create_augroup :Lazy + {:clear true}) + :pattern :VeryLazy + :callback (lambda [] + (require :settings.autocmds) + (require :settings.keymaps) + (require :settings.usercmds))}) diff --git a/fnl/settings/keymaps.fnl b/fnl/settings/keymaps.fnl index 064084c..1af9a0d 100644 --- a/fnl/settings/keymaps.fnl +++ b/fnl/settings/keymaps.fnl @@ -1,13 +1,10 @@ ;; Custom keymappings. -(module settings.keymaps {autoload {nvim aniseed.nvim}}) -(def- opts {:noremap true :silent true}) -(defn- map [mode lhs rhs opt] (nvim.set_keymap mode lhs rhs opt)) +(local opts {:noremap true :silent true}) +(fn map [mode lhs rhs opt] (vim.api.nvim_set_keymap mode lhs rhs opt)) ;;Remap space as leader key (map "" :<Space> :<Nop> opts) -(set nvim.g.mapleader " ") -(set nvim.g.maplocalleader " ") ;; Normal ;; ;; Better window navigation diff --git a/fnl/settings/options.fnl b/fnl/settings/options.fnl index 9e190c2..1030f08 100644 --- a/fnl/settings/options.fnl +++ b/fnl/settings/options.fnl @@ -1,12 +1,11 @@ ;; Sets options in neovim -(module settings.options {autoload {nvim aniseed.nvim}}) -(def- spellfile (.. (os.getenv :XDG_CONFIG_HOME) :/nvim/spell/en.utf-8.add)) - -(defn- apply-opts [opts] (each [k v (pairs opts)] +(fn apply-opts [opts] (each [k v (pairs opts)] (tset vim.opt k v))) -(def- opts {;; creates a backup file +(local spellfile (.. (os.getenv :XDG_CONFIG_HOME) :/nvim/spell/en.utf-8.add)) + +(local opts {;; creates a backup file :backup false ;; allows neovim to access the system clipboard :clipboard :unnamedplus @@ -76,6 +75,8 @@ ;; is one of my fav :scrolloff 8 :sidescrolloff 8 + :colorcolumn :88 + :shortmess :filnxtToOFWIcC :spell true : spellfile :spelllang [:en_us] @@ -84,12 +85,8 @@ :splitkeep :screen}) (apply-opts opts) - -(nvim.ex.set "whichwrap+=<,>,[,],h,l") -(nvim.ex.set :iskeyword+=-) -(nvim.ex.set :formatoptions-=cro) -(nvim.ex.set :colorcolumn=88) -(nvim.ex.set :shortmess=filnxtToOFWIcC) +(set vim.g.mapleader " ") +(set vim.g.maplocalleader " ") ;; Netrw settings (set vim.g.netrw_banner 0) diff --git a/fnl/settings/usercmds.fnl b/fnl/settings/usercmds.fnl new file mode 100644 index 0000000..da842cc --- /dev/null +++ b/fnl/settings/usercmds.fnl @@ -0,0 +1,98 @@ +;; Commands for plugins. + +(vim.api.nvim_create_user_command :OrgAgendaPrompt + (lambda [] + (let [orgmode (require :orgmode)] + (orgmode.action :agenda.prompt))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :OrgCapturePrompt + (lambda [] + (let [orgmode (require :orgmode)] + (orgmode.action :capture.prompt))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :CommentNormal + (lambda [] + (let [comment-api (require :Comment.api)] + (comment-api.toggle.linewise.current))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :CommentVisual + (lambda [] + (let [comment-api (require :Comment.api)] + (comment-api.toggle.linewise (vim.fn.visualmode)))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :HarpoonAdd + (lambda [] + (let [harpoon (require :harpoon.mark)] + (harpoon.add_file))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :HarpoonNext + (lambda [] + (let [harpoon (require :harpoon.ui)] + (harpoon.nav_next))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :HarpoonPrev + (lambda [] + (let [harpoon (require :harpoon.ui)] + (harpoon.nav_prev))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :HarpoonUI + (lambda [] + (let [harpoon (require :harpoon.ui)] + (harpoon.toggle_quick_menu))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :Replace + (lambda [] + (let [spectre (require :spectre)] + (spectre.open))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :ReplaceWord + (lambda [] + (let [spectre (require :spectre)] + (spectre.open_visual {:select_word true}))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :ReplaceInBuf + (lambda [] + (let [spectre (require :spectre)] + (spectre.open_file_search))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :RestoreSession + (lambda [] + (let [persistence (require :persistence)] + (persistence.load))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :RestoreLastSession + (lambda [] + (let [persistence (require :persistence)] + (persistence.load {:last true}))) + {:nargs 0}) + +(vim.api.nvim_create_user_command :IgnoreSession + (lambda [] + (let [persistence (require :persistence)] + (persistence.stop))) + {:nargs 0}) + +(fn telescope-builtin [builtin opts] + (let [telescope (require :telescope.builtin) + themes (require :telescope.themes) + theme (. opts :theme)] + ((. telescope builtin) ((. themes theme) opts)))) + +(vim.api.nvim_create_user_command :FindFiles + (lambda [] + (telescope-builtin :find_files + {:theme :get_dropdown + :previewer false})) + {:nargs 0}) |