summaryrefslogtreecommitdiff
path: root/fnl/plugins/editor
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2023-01-15 22:47:30 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2023-01-15 22:47:30 +0100
commit10b175f252104458d7478d8a2822818850cfdf92 (patch)
treeee926d33bee6b4acfe45fce0dd8aa9e94f03f06a /fnl/plugins/editor
parent9d4f654187869f96e27ab54a88708aba5959f1ba (diff)
Refactor file structure
Diffstat (limited to 'fnl/plugins/editor')
-rw-r--r--fnl/plugins/editor/autopairs.fnl20
-rw-r--r--fnl/plugins/editor/better-escape.fnl8
-rw-r--r--fnl/plugins/editor/bufdel.fnl3
-rw-r--r--fnl/plugins/editor/cmp.fnl65
-rw-r--r--fnl/plugins/editor/colorizer.fnl3
-rw-r--r--fnl/plugins/editor/colorscheme.fnl8
-rw-r--r--fnl/plugins/editor/comment.fnl20
-rw-r--r--fnl/plugins/editor/gitsigns.fnl48
-rw-r--r--fnl/plugins/editor/harpoon.fnl25
-rw-r--r--fnl/plugins/editor/leap.fnl17
-rw-r--r--fnl/plugins/editor/lir.fnl52
-rw-r--r--fnl/plugins/editor/persistence.fnl5
-rw-r--r--fnl/plugins/editor/spectre.fnl54
-rw-r--r--fnl/plugins/editor/stay-in-place.fnl3
-rw-r--r--fnl/plugins/editor/surround.fnl3
-rw-r--r--fnl/plugins/editor/symbols-outline.fnl3
-rw-r--r--fnl/plugins/editor/telescope.fnl113
-rw-r--r--fnl/plugins/editor/toggleterm.fnl5
-rw-r--r--fnl/plugins/editor/treesitter.fnl39
-rw-r--r--fnl/plugins/editor/trim.fnl3
-rw-r--r--fnl/plugins/editor/trouble.fnl81
-rw-r--r--fnl/plugins/editor/undotree.fnl3
-rw-r--r--fnl/plugins/editor/vim-slash.fnl6
-rw-r--r--fnl/plugins/editor/which-key.fnl168
-rw-r--r--fnl/plugins/editor/window-picker.fnl19
-rw-r--r--fnl/plugins/editor/zen.fnl11
26 files changed, 785 insertions, 0 deletions
diff --git a/fnl/plugins/editor/autopairs.fnl b/fnl/plugins/editor/autopairs.fnl
new file mode 100644
index 0000000..d1aabf6
--- /dev/null
+++ b/fnl/plugins/editor/autopairs.fnl
@@ -0,0 +1,20 @@
+;; Autopairs for brackets and quote symbols.
+
+{1 :windwp/nvim-autopairs
+ :event :InsertEnter
+ :opts {:check_ts true
+ :ts_config {:lua [:string :source]
+ :javascript [:string :template_string]
+ :java false}
+ :disable_filetype [:TelescopePrompt :spectre_panel]
+ :fast_warp {:map :<M-e>
+ :chars ["{" "[" "(" "\"" "'"]
+ :pattern (string.gsub "[%'%\"%)%>%]%)%}%,]" "%s+" "")
+ :check_comma true
+ :highlight :PmenuSel
+ :highlight_grey :LineNr
+ :offset 0
+ :end_key "$"
+ :keys :qwertyuiopzxcvbnmasdfghjkl
+ :highlight :PmenuSel
+ :highlight_grey :LineNr}}}
diff --git a/fnl/plugins/editor/better-escape.fnl b/fnl/plugins/editor/better-escape.fnl
new file mode 100644
index 0000000..cde61bc
--- /dev/null
+++ b/fnl/plugins/editor/better-escape.fnl
@@ -0,0 +1,8 @@
+;; Better escape without nasty delay.
+
+{1 :max397574/better-escape.nvim
+ :event :BufReadPost
+ :opts {:mapping [:kk :jj]
+ :timeout vim.o.timeoutlen
+ :clear_empty_lines false
+ :keys :<Esc>}}
diff --git a/fnl/plugins/editor/bufdel.fnl b/fnl/plugins/editor/bufdel.fnl
new file mode 100644
index 0000000..4719a53
--- /dev/null
+++ b/fnl/plugins/editor/bufdel.fnl
@@ -0,0 +1,3 @@
+;; Delete buffers.
+
+{1 :ojroques/nvim-bufdel :cmd :BufDel}
diff --git a/fnl/plugins/editor/cmp.fnl b/fnl/plugins/editor/cmp.fnl
new file mode 100644
index 0000000..a062d92
--- /dev/null
+++ b/fnl/plugins/editor/cmp.fnl
@@ -0,0 +1,65 @@
+;; Configuration for completion plugin.
+
+(fn setup []
+ (let [cmp (require :cmp)
+ lspkind (require :lspkind)
+ luasnip (require :luasnip)
+ luasnip-vscode (require :luasnip.loaders.from_vscode)]
+ (luasnip-vscode.lazy_load)
+ (lspkind.init)
+ (cmp.setup {:snippet {:expand (fn [args]
+ (luasnip.lsp_expand args.body))}
+ :completion {:completopt "menu,menuone,noinsert"}
+ :mapping (cmp.mapping.preset.insert {:<C-k> (cmp.mapping.select_prev_item)
+ :<C-j> (cmp.mapping.select_next_item)
+ :<C-b> (cmp.mapping (cmp.mapping.scroll_docs -1)
+ [:i
+ :c])
+ :<C-f> (cmp.mapping (cmp.mapping.scroll_docs 1)
+ [:i
+ :c])
+ :<C-space> (cmp.mapping (cmp.mapping.complete)
+ [:i
+ :c])
+ :<C-e> (cmp.mapping {:i (cmp.mapping.abort)
+ :c (cmp.mapping.close)})
+ :<CR> (cmp.mapping.confirm {:select true})
+ :<CR> (cmp.mapping.confirm {:select true})})
+ :sources [{:name :nvim_lsp}
+ {:name :nvim_lua}
+ {:name :luasnip}
+ {:name :spell}
+ {:name :orgmode}
+ {:name :buffer :keyword_length 4}
+ {:name :path :keyword_length 6}]
+ :formatting {:format (lspkind.cmp_format {:with_text true
+ :menu {:buffer ""
+ :nvim_lsp ""
+ :nvim_lua ""
+ :path ""
+ :luasnip ""}})}
+ :window {:documentation {:border ["╭"
+ "─"
+ "╮"
+ "│"
+ "╯"
+ "─"
+ "╰"
+ "│"]}}
+ :confirm_opts {:behavior cmp.ConfirmBehavior.Replace
+ :select false}
+ :experimental {:ghost_text false :native_menu false}})))
+
+{1 :hrsh7th/nvim-cmp
+ :dependencies [:hrsh7th/cmp-buffer
+ :onsails/lspkind-nvim
+ :hrsh7th/cmp-nvim-lsp
+ :hrsh7th/cmp-cmdline
+ :L3MON4D3/LuaSnip
+ :rafamadriz/friendly-snippets
+ :hrsh7th/cmp-path
+ :saadparwaiz1/cmp_luasnip
+ :f3fora/cmp-spell]
+ :event :InsertEnter
+ :config (fn []
+ (setup))}
diff --git a/fnl/plugins/editor/colorizer.fnl b/fnl/plugins/editor/colorizer.fnl
new file mode 100644
index 0000000..553024b
--- /dev/null
+++ b/fnl/plugins/editor/colorizer.fnl
@@ -0,0 +1,3 @@
+;; Display colors of hex numbers.
+
+{1 :norcalli/nvim-colorizer.lua :cmd :ColorizerToggle :config true}
diff --git a/fnl/plugins/editor/colorscheme.fnl b/fnl/plugins/editor/colorscheme.fnl
new file mode 100644
index 0000000..40802a6
--- /dev/null
+++ b/fnl/plugins/editor/colorscheme.fnl
@@ -0,0 +1,8 @@
+;; Load neovim colorscheme.
+
+{1 :aktersnurra/no-clown-fiesta.nvim
+ :opts {:styles {:type {:bold true}}}
+ :config (lambda [_ opts]
+ (let [plugin (require :no-clown-fiesta)]
+ (plugin.setup opts)
+ (plugin.load)))}
diff --git a/fnl/plugins/editor/comment.fnl b/fnl/plugins/editor/comment.fnl
new file mode 100644
index 0000000..63401a0
--- /dev/null
+++ b/fnl/plugins/editor/comment.fnl
@@ -0,0 +1,20 @@
+;; Language aware commenting.
+
+{1 :numToStr/Comment.nvim
+ :event :BufReadPost
+ :opts {:toggler {;; Line-comment toggle keymap
+ :line :mcc
+ ;; Block-comment toggle keymap
+ :block :mbc}
+ ;; LHS of operator-pending mappings in NORMAL and VISUAL mode
+ :opleader {;; Line-comment keymap
+ :line :mc
+ ;; Block-comment keymap
+ :block :mb}
+ ;; LHS of extra mappings
+ :extra {;; Add comment on the line above
+ :above :mcO
+ ;; Add comment on the line below
+ :below :mco
+ ;; Add comment at the end of line
+ :eol :mcA}}}
diff --git a/fnl/plugins/editor/gitsigns.fnl b/fnl/plugins/editor/gitsigns.fnl
new file mode 100644
index 0000000..1ef8cbc
--- /dev/null
+++ b/fnl/plugins/editor/gitsigns.fnl
@@ -0,0 +1,48 @@
+;; Add git signs to source files.
+
+(local signs {:add {:hl :GitSignsAdd
+ :text "|"
+ :numhl :GitSignsAddNr
+ :linehl :GitSignsAddLn}
+ :change {:hl :GitSignsChange
+ :text "|"
+ :numhl :GitSignsChangeNr
+ :linehl :GitSignsChangeLn}
+ :delete {:hl :GitSignsDelete
+ :text "_"
+ :numhl :GitSignsDeleteNr
+ :linehl :GitSignsDeleteLn}
+ :topdelete {:hl :GitSignsDelete
+ :text "‾"
+ :numhl :GitSignsDeleteNr
+ :linehl :GitSignsDeleteLn}
+ :changedelete {:hl :GitSignsChange
+ :text "~"
+ :numhl :GitSignsChangeNr
+ :linehl :GitSignsChangeLn}})
+
+(local opts {: signs
+ :signcolumn true
+ :numhl false
+ :linehl false
+ :word_diff false
+ :watch_gitdir {:interval 1000 :follow_files true}
+ :attach_to_untracked true
+ :current_line_blame false
+ :current_line_blame_opts {:virt_text true
+ :virt_text_pos :eol
+ :delay 1000
+ :ignore_whitespace false}
+ :current_line_blame_formatter_opts {:relative_time false}
+ :sign_priority 6
+ :update_debounce 100
+ :status_formatter nil
+ :max_file_length 40000
+ :preview_config {:border :single
+ :style :minimal
+ :relative :cursor
+ :row 0
+ :col 1}
+ :yadm {:enable false}})
+
+{1 :lewis6991/gitsigns.nvim :event :BufReadPost : opts}
diff --git a/fnl/plugins/editor/harpoon.fnl b/fnl/plugins/editor/harpoon.fnl
new file mode 100644
index 0000000..7674f0b
--- /dev/null
+++ b/fnl/plugins/editor/harpoon.fnl
@@ -0,0 +1,25 @@
+;; Harpoon files for navigation.
+
+(fn telescope-ext [ext fun opts]
+ (let [telescope (require :telescope)
+ themes (require :telescope.themes)
+ theme (. opts :theme)]
+ ((. (. (. telescope :extensions) ext) fun) ((. themes theme) opts))))
+
+(fn setup []
+ (vim.keymap.set :n :<tab>
+ (fn []
+ (telescope-ext :harpoon :marks
+ {:theme :get_dropdown
+ :previewer false
+ :initial_mode :normal
+ :prompt_title :Harpoon}))
+ {})
+ (vim.keymap.set :n :<s-tab>
+ "<cmd>Telescope buffers theme=dropdown previewer=false initial_mode=normal<cr>"
+ {}))
+
+{1 :ThePrimeagen/harpoon
+ :event :BufReadPost
+ :config (fn []
+ (setup))}
diff --git a/fnl/plugins/editor/leap.fnl b/fnl/plugins/editor/leap.fnl
new file mode 100644
index 0000000..6c2eb53
--- /dev/null
+++ b/fnl/plugins/editor/leap.fnl
@@ -0,0 +1,17 @@
+;; Leap through text.
+
+(fn setup []
+ (let [leap (require :leap)]
+ (leap.setup {})
+ (leap.set_default_keymaps)))
+
+{1 :ggandor/leap.nvim
+ :dependencies {1 :ggandor/flit.nvim
+ :event :BufReadPost
+ :opts {:keys {:f :f :F :F :t :t :T :T}
+ :labeled_modes :v
+ :multiline true
+ :opts {}}}
+ :event :BufReadPost
+ :config (fn []
+ (setup))}
diff --git a/fnl/plugins/editor/lir.fnl b/fnl/plugins/editor/lir.fnl
new file mode 100644
index 0000000..8caa8e4
--- /dev/null
+++ b/fnl/plugins/editor/lir.fnl
@@ -0,0 +1,52 @@
+;; Simple file manager.
+
+(fn opts [actions mark-actions clipboard-actions]
+ {:show_hidden_files false
+ :devicons {:enable true :highlight_dirname false}
+ :mappings {:l actions.edit
+ :<C-s> actions.split
+ :v actions.vsplit
+ :<C-t> actions.tabedit
+ :h actions.up
+ :q actions.quit
+ :A actions.mkdir
+ :a actions.newfile
+ :r actions.rename
+ "@" actions.cd
+ :Y actions.yank_path
+ :i actions.toggle_show_hidden
+ :d actions.delete
+ :J (fn []
+ (mark-actions.toggle_mark)
+ (vim.cmd "normal! j"))
+ :c clipboard-actions.copy
+ :x clipboard-actions.cut
+ :p clipboard-actions.paste}
+ :float {:winblend 0
+ :curdir_window {:enable false :highlight_dirname true}
+ :win_opts (fn []
+ (let [width (math.floor (* vim.o.columns 0.7))
+ height (math.floor (* vim.o.lines 0.7))]
+ {:border :rounded : width : height}))}
+ :hide_cursor false
+ :on_init (fn []
+ (vim.api.nvim_buf_set_keymap 0 :x :J
+ ":<C-u>lua require(\"lir.mark.actions\").toggle_mark(\"v\")<CR>"
+ {:noremap true :silent true}))})
+
+(fn setup []
+ (let [actions (require :lir.actions)
+ clipboard-actions (require :lir.clipboard.actions)
+ mark-actions (require :lir.mark.actions)
+ lir (require :lir)]
+ (tset vim.g :loaded_netrw 1)
+ (tset vim.g :loaded_netrwPlugin 1)
+ (lir.setup (opts actions mark-actions clipboard-actions))
+ (vim.keymap.set :n "-" ":lua require'lir.float'.toggle()<cr>"
+ {:noremap true :silent true})))
+
+{1 :tamago324/lir.nvim
+ :keys "-"
+ :config (fn []
+ (setup))
+ :dependencies [:kyazdani42/nvim-web-devicons]}
diff --git a/fnl/plugins/editor/persistence.fnl b/fnl/plugins/editor/persistence.fnl
new file mode 100644
index 0000000..4cde73e
--- /dev/null
+++ b/fnl/plugins/editor/persistence.fnl
@@ -0,0 +1,5 @@
+;; Session manager.
+
+{1 :folke/persistence.nvim
+ :event :VeryLazy
+ :opts {:options [:buffers :curdir :tabpages :winsize :help]}}
diff --git a/fnl/plugins/editor/spectre.fnl b/fnl/plugins/editor/spectre.fnl
new file mode 100644
index 0000000..92a33ba
--- /dev/null
+++ b/fnl/plugins/editor/spectre.fnl
@@ -0,0 +1,54 @@
+;; Find and replace.
+
+(local opts {:color_devicons true
+ :highlight {:ui :String :search :DiffChange :replace :DiffDelete}
+ :mapping {:toggle_line {:map :t
+ :cmd "<cmd>lua require('spectre').toggle_line()<CR>"
+ :desc "toggle current item"}
+ :enter_file {:map :<cr>
+ :cmd "<cmd>lua require('spectre.actions').select_entry()<CR>"
+ :desc "goto current file"}
+ :send_to_qf {:map :Q
+ :cmd "<cmd>lua require('spectre.actions').send_to_qf()<CR>"
+ :desc "send all item to quickfix"}
+ :replace_cmd {:map :c
+ :cmd "<cmd>lua require('spectre.actions').replace_cmd()<CR>"
+ :desc "input replace vim command"}
+ :show_option_menu {:map :o
+ :cmd "<cmd>lua require('spectre').show_options()<CR>"
+ :desc "show option"}
+ :run_replace {:map :R
+ :cmd "<cmd>lua require('spectre.actions').run_replace()<CR>"
+ :desc "replace all"}
+ :change_view_mode {:map :m
+ :cmd "<cmd>lua require('spectre').change_view()<CR>"
+ :desc "change result view mode"}
+ :toggle_ignore_case {:map :I
+ :cmd "<cmd>lua require('spectre').change_options('ignore-case')<CR>"
+ :desc "toggle ignore case"}
+ :toggle_ignore_hidden {:map :H
+ :cmd "<cmd>lua require('spectre').change_options('hidden')<CR>"
+ :desc "toggle search hidden"}}
+ :find_engine {:rg {:cmd :rg
+ :args [:--color=never
+ :--no-heading
+ :--with-filename
+ :--line-number
+ :--column]
+ :options {:ignore-case {:value :--ignore-case
+ :icon "[I]"
+ :desc "ignore case"}
+ :hidden {:value :--hidden
+ :desc "hidden file"
+ :icon "[H]"}}}}
+ :replace_engine {:sed {:cmd :sed :args nil}
+ :options {:ignore-case {:value :--ignore-case
+ :icon "[I]"
+ :desc "ignore case"}}}
+ :default {:find {:cmd :rg :options [:ignore-case]}
+ :replace {:cmd :sed}}
+ :replace_vim_cmd :cdo
+ :is_open_target_win true
+ :is_insert_mode false})
+
+{1 :windwp/nvim-spectre :event :BufReadPost : opts}
diff --git a/fnl/plugins/editor/stay-in-place.fnl b/fnl/plugins/editor/stay-in-place.fnl
new file mode 100644
index 0000000..b264a05
--- /dev/null
+++ b/fnl/plugins/editor/stay-in-place.fnl
@@ -0,0 +1,3 @@
+;; Keep cursor at character when indenting.
+
+{1 :gbprod/stay-in-place.nvim :event :BufReadPost :config true}
diff --git a/fnl/plugins/editor/surround.fnl b/fnl/plugins/editor/surround.fnl
new file mode 100644
index 0000000..e8fda32
--- /dev/null
+++ b/fnl/plugins/editor/surround.fnl
@@ -0,0 +1,3 @@
+;; Surround selections.
+
+{1 :kylechui/nvim-surround :event :InsertEnter :config true}
diff --git a/fnl/plugins/editor/symbols-outline.fnl b/fnl/plugins/editor/symbols-outline.fnl
new file mode 100644
index 0000000..4195de0
--- /dev/null
+++ b/fnl/plugins/editor/symbols-outline.fnl
@@ -0,0 +1,3 @@
+;; List tree of symbols.
+
+{1 :simrat39/symbols-outline.nvim :cmd :SymbolsOutline :config true}
diff --git a/fnl/plugins/editor/telescope.fnl b/fnl/plugins/editor/telescope.fnl
new file mode 100644
index 0000000..df8c031
--- /dev/null
+++ b/fnl/plugins/editor/telescope.fnl
@@ -0,0 +1,113 @@
+;; Telescope a highly extendable fuzzy finder over lists.
+
+(fn setup []
+ (let [telescope (require :telescope)
+ actions (require :telescope.actions)]
+ (telescope.setup {:defaults {:prompt_prefix "  "
+ :selection_caret "> "
+ :path_display [:smart]
+ :color_devicons false
+ :vimgrep_arguments [:rg
+ :--color=never
+ :--no-heading
+ :--with-filename
+ :--line-number
+ :--column
+ :--smart-case
+ :--hidden]
+ :mappings {:i {:<C-n> actions.cycle_history_next
+ :<C-p> actions.cycle_history_prev
+ :<C-j> actions.move_selection_next
+ :<C-k> actions.move_selection_previous
+ :<C-c> actions.close
+ :<Down> actions.move_selection_next
+ :<Up> actions.move_selection_previous
+ :<CR> actions.select_default
+ :<C-x> actions.select_horizontal
+ :<C-v> actions.select_vertical
+ :<C-t> actions.select_tab
+ :<C-u> actions.preview_scrolling_up
+ :<C-d> actions.preview_scrolling_down
+ :<PageUp> actions.results_scrolling_up
+ :<PageDown> actions.results_scrolling_down
+ :<Tab> (+ actions.toggle_selection
+ actions.move_selection_worse)
+ :<S-Tab> (+ actions.toggle_selection
+ actions.move_selection_better)
+ :<C-q> (+ actions.send_to_qflist
+ actions.open_qflist)
+ :<M-q> (+ actions.send_selected_to_qflist
+ actions.open_qflist)
+ :<C-l> actions.complete_tag
+ :<C-_> actions.which_key}
+ :n {:<esc> actions.close
+ :<CR> actions.select_default
+ :<C-x> actions.select_horizontal
+ :<C-v> actions.select_vertical
+ :<C-t> actions.select_tab
+ :<Tab> (+ actions.toggle_selection
+ actions.move_selection_worse)
+ :<S-Tab> (+ actions.toggle_selection
+ actions.move_selection_better)
+ :<C-q> (+ actions.send_to_qflist
+ actions.open_qflist)
+ :<M-q> (+ actions.send_selected_to_qflist
+ actions.open_qflist)
+ :j actions.move_selection_next
+ :k actions.move_selection_previous
+ :H actions.move_to_top
+ :M actions.move_to_middle
+ :L actions.move_to_bottom
+ :<Down> actions.move_selection_next
+ :<Up> actions.move_selection_previous
+ :gg actions.move_to_top
+ :G actions.move_to_bottom
+ :q actions.close
+ :<C-u> actions.preview_scrolling_up
+ :<C-d> actions.preview_scrolling_down
+ :<PageUp> actions.results_scrolling_up
+ :<PageDown> actions.results_scrolling_down
+ :dd actions.delete_buffer
+ :? actions.which_key}}}
+ :extensions {:fzf {:fuzzy true
+ :override_generic_sorter true
+ :override_file_sorter true
+ :case_mode :smart_case}}})
+ (telescope.load_extension :fzf)
+ (telescope.load_extension :frecency)
+ (telescope.load_extension :orgmode)
+ (telescope.load_extension :projects)
+ (telescope.load_extension :harpoon)))
+
+{1 :nvim-telescope/telescope.nvim
+ :cmd :Telescope
+ :dependencies [:nvim-lua/popup.nvim
+ :nvim-telescope/telescope-frecency.nvim
+ {1 :nvim-telescope/telescope-fzf-native.nvim :build :make}
+ :tami5/sqlite.lua
+ {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 (lambda [_ opts]
+ (let [project (require :project_nvim)]
+ (project.setup opts)))}
+ :nvim-lua/plenary.nvim
+ :nvim-telescope/telescope-fzf-native.nvim
+ :nvim-telescope/telescope-frecency.nvim
+ :joaomsa/telescope-orgmode.nvim]
+ :config (fn []
+ (setup))}
diff --git a/fnl/plugins/editor/toggleterm.fnl b/fnl/plugins/editor/toggleterm.fnl
new file mode 100644
index 0000000..d75aea1
--- /dev/null
+++ b/fnl/plugins/editor/toggleterm.fnl
@@ -0,0 +1,5 @@
+;; Terminal inside nvim.
+
+{1 :akinsho/toggleterm.nvim
+ :cmd :ToggleTerm
+ :opts {:size 16 :shade_terminals false}}
diff --git a/fnl/plugins/editor/treesitter.fnl b/fnl/plugins/editor/treesitter.fnl
new file mode 100644
index 0000000..1d96a13
--- /dev/null
+++ b/fnl/plugins/editor/treesitter.fnl
@@ -0,0 +1,39 @@
+;; Treesitter is a tool for building syntax trees for source files.
+;; In the neovim context it helps with better coloring.
+
+(local opts {:ensure_installed [:c
+ :rust
+ :lua
+ :hcl
+ :org
+ :haskell
+ :python
+ :fennel
+ :make
+ :go
+ :ocaml
+ :erlang
+ :vim
+ :yaml
+ :html
+ :toml
+ :dockerfile
+ :markdown
+ :latex]
+ :sync_install false
+ :ignore_install [""]
+ :autopairs {:enable true}
+ :highlight {:enable true :disable [:org]}
+ :context_commentstring {:enable true :enable_autocmd false}
+ :indent {:enable true :disable [:yaml :python :css]}
+ :playground {:enable true}})
+
+(fn setup []
+ (let [treesitter (require :nvim-treesitter.configs)]
+ (treesitter.setup opts)))
+
+{1 :nvim-treesitter/nvim-treesitter
+ :build ":TSUpdate"
+ :event :BufReadPost
+ :config (fn []
+ (setup))}
diff --git a/fnl/plugins/editor/trim.fnl b/fnl/plugins/editor/trim.fnl
new file mode 100644
index 0000000..7f224bc
--- /dev/null
+++ b/fnl/plugins/editor/trim.fnl
@@ -0,0 +1,3 @@
+;; Trim whitespaces on save.
+
+{1 :cappyzawa/trim.nvim :event :BufFilePre :opts {:disable [:python]}}
diff --git a/fnl/plugins/editor/trouble.fnl b/fnl/plugins/editor/trouble.fnl
new file mode 100644
index 0000000..3f736bb
--- /dev/null
+++ b/fnl/plugins/editor/trouble.fnl
@@ -0,0 +1,81 @@
+;; Pretty diagnostics.
+
+(local opts {:position :bottom
+ ;; position of the list can be: bottom, top, left, right
+ :height 10
+ ;; height of the trouble list when position is top or bottom
+ :width 50
+ ;; width of the list when position is left or right
+ :icons true
+ ;; use devicons for filenames
+ :mode :workspace_diagnostics
+ ;; "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
+ :fold_open ""
+ ;; icon used for open folds
+ :fold_closed ""
+ ;; icon used for closed folds
+ :group true
+ ;; group results by file
+ :padding true
+ ;; add an extra new line on top of the list
+ :action_keys {;; key mappings for actions in the trouble list
+ ;; map to {} to remove a mapping for example:
+ ;; close {}
+ :close :q
+ ;; close the list
+ :cancel :<esc>
+ ;; cancel the preview and get back to your last window / buffer / cursor
+ :refresh :r
+ ;; manually refresh
+ :jump [:<cr> :<tab>]
+ ;; jump to the diagnostic or open / close folds
+ :open_split [:<c-x>]
+ ;; open buffer in new split
+ :open_vsplit [:<c-v>]
+ ;; open buffer in new vsplit
+ :open_tab [:<c-t>]
+ ;; open buffer in new tab
+ :jump_close [:o]
+ ;; jump to the diagnostic and close the list
+ :toggle_mode :m
+ ;; toggle between "workspace" and "document" diagnostics mode
+ :toggle_preview :P
+ ;; toggle auto_preview
+ :hover :K
+ ;; opens a small popup with the full multiline message
+ :preview :p
+ ;; preview the diagnostic location
+ :close_folds [:zM :zm]
+ ;; close all folds
+ :open_folds [:zR :zr]
+ ;; open all folds
+ :toggle_fold [:zA :za]
+ ;; toggle fold of current file
+ :previous :k
+ ;; previous item
+ :next :j
+ ;; next item
+ }
+ :indent_lines true
+ ;; add an indent guide below the fold icons
+ :auto_open false
+ ;; automatically open the list when you have diagnostics
+ :auto_close false
+ ;; automatically close the list when you have no diagnostics
+ :auto_preview true
+ ;; automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
+ :auto_fold false
+ ;; automatically fold a file trouble list at creation
+ :auto_jump [:lsp_definitions]
+ ;; for the given modes, automatically jump if there is only a single result
+ :signs {;; icons / text used for a diagnostic
+ :error ""
+ :warning ""
+ :hint ""
+ :information ""
+ :other "﫠"}
+ :use_diagnostic_signs false
+ ;; enabling this will use the signs defined in your lsp client
+ })
+
+{1 :folke/trouble.nvim :cmd :TroubleToggle : opts}
diff --git a/fnl/plugins/editor/undotree.fnl b/fnl/plugins/editor/undotree.fnl
new file mode 100644
index 0000000..9aa8114
--- /dev/null
+++ b/fnl/plugins/editor/undotree.fnl
@@ -0,0 +1,3 @@
+;; Tree of undo history.
+
+{1 :mbbill/undotree :cmd :UndotreeToggle}
diff --git a/fnl/plugins/editor/vim-slash.fnl b/fnl/plugins/editor/vim-slash.fnl
new file mode 100644
index 0000000..6f50ae4
--- /dev/null
+++ b/fnl/plugins/editor/vim-slash.fnl
@@ -0,0 +1,6 @@
+;; Provides a set of mappings for enhancing in-buffer search experience.
+
+{1 :junegunn/vim-slash
+ :event :BufReadPost
+ :config (fn []
+ (vim.cmd "noremap <plug>(slash-after) zz"))}
diff --git a/fnl/plugins/editor/which-key.fnl b/fnl/plugins/editor/which-key.fnl
new file mode 100644
index 0000000..0b6389c
--- /dev/null
+++ b/fnl/plugins/editor/which-key.fnl
@@ -0,0 +1,168 @@
+;; Which-key provides a pop-up menu for some key mappings.
+
+(local opts {:plugins {:marks true
+ :registers true
+ :spelling {:enabled true :suggestions 20}
+ :presets {:operators false
+ :motions false
+ :text_objects false
+ :windows true
+ :nav true
+ :z true
+ :g true}}
+ :icons {:breadcrumb "»" :separator "" :group "+"}
+ :popup_mappings {:scroll_down :<c-d> :scroll_up :<c-u>}
+ :window {:border :rounded :position :bottom :winblend 0}
+ :layout {:height {:min 4 :max 25}
+ :width {:min 20 :max 50}
+ :spacing 3
+ :align :left}
+ :ignore_missing true
+ :hidden [:<silent> :<cmd> :<Cmd> :<CR> :call :lua "^:" "^ "]
+ :show_help true
+ :triggers :auto
+ :disable {:filetypes [:netrw]}
+ :triggers_blacklist {:i [:j :k] :v [:j :k]}})
+
+(local mopts {:mode :n
+ :prefix :m
+ :buffer nil
+ :silent true
+ :noremap true
+ :nowait true})
+
+(local mmappings {:a [:<cmd>HarpoonAdd<cr> :Harpoon]
+ :d [:<cmd>DiffviewFileHistory<cr> :DiffviewFileHistory]
+ :f [:<cmd>FindFiles<cr> "Find files"]
+ :g ["<cmd>Telescope live_grep theme=dropdown<cr>"
+ "Find text"]
+ :n [:<cmd>Neogit<cr> :Neogit]
+ :q ["<cmd>Gitsigns diffthis HEAD<cr>" "Gitsigns diff"]
+ :r [:<cmd>HarpoonUI<cr> "Harpoon UI"]
+ :s [:<cmd>HarpoonPrev<cr> "Harpoon Prev"]
+ :t [:<cmd>HarpoonNext<cr> "Harpoon Next"]
+ :v ["<cmd>lua vim.lsp.buf.rename()<cr>" :Rename]
+ :x ["<cmd>DiffviewOpen -uno<cr>" :DiffviewOpen]
+ :z [:<cmd>DiffviewClose<cr> :DiffviewClose]})
+
+(local nopts {:mode :n
+ :prefix :<leader>
+ :buffer nil
+ :silent true
+ :noremap true
+ :nowait true})
+
+(local find
+ {:name :find
+ :C ["<cmd>Telescope commands theme=dropdown<cr>" :Commands]
+ :H ["<cmd>Telescope highlights<cr>" :Highlights]
+ :R ["<cmd>Telescope registers theme=dropdown<cr>" :Registers]
+ :S ["<cmd>Telescope grep_string theme=dropdown<cr>" "Find String"]
+ :b ["<cmd>Telescope git_branches theme=dropdown<cr>" "Checkout branch"]
+ :c ["<cmd>Telescope colorscheme theme=dropdown<cr>" :Colorscheme]
+ :f [:<cmd>FindFiles<cr> "Find files"]
+ :h ["<cmd>Telescope help_tags theme=dropdown<cr>" :Help]
+ :k ["<cmd>Telescope keymaps theme=dropdown<cr>" :Keymaps]
+ :l ["<cmd>Telescope resume theme=dropdown<cr>" "Last Search"]
+ :p ["<cmd>Telescope projects theme=dropdown<cr>" "Find project"]
+ :r ["<cmd>Telescope oldfiles theme=dropdown<cr>" "Recent File"]
+ :t ["<cmd>Telescope live_grep theme=dropdown<cr>" "Find text"]})
+
+(local diagnostics {:name :diagnostics
+ :t [:<cmd>TroubleToggle<cr> :Trouble]
+ :g ["<cmd>Telescope diagnostics theme=dropdown<cr>"
+ "Telescope diagnostics"]})
+
+(local git {:name :git
+ :R ["<cmd>lua require 'gitsigns'.reset_buffer()<cr>"
+ "Reset Buffer"]
+ :b ["<cmd>Telescope git_branches theme=dropdown<cr>"
+ "Checkout branch"]
+ :c ["<cmd>Telescope git_commits theme=dropdown<cr>"
+ "Checkout commit"]
+ :d ["<cmd>Gitsigns diffthis HEAD<cr>" :Diff]
+ :j ["<cmd>lua require 'gitsigns'.next_hunk()<cr>" "Next Hunk"]
+ :k ["<cmd>lua require 'gitsigns'.prev_hunk()<cr>" "Prev Hunk"]
+ :l ["<cmd>lua require 'gitsigns'.blame_line()<cr>" :Blame]
+ :o ["<cmd>Telescope git_status theme=dropdown<cr>"
+ "Open changed file"]
+ :p ["<cmd>lua require 'gitsigns'.preview_hunk()<cr>"
+ "Preview Hunk"]
+ :r ["<cmd>lua require 'gitsigns'.reset_hunk()<cr>" "Reset Hunk"]
+ :s ["<cmd>lua require 'gitsigns'.stage_hunk()<cr>" "Stage Hunk"]
+ :u ["<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>"
+ "Undo Stage Hunk"]})
+
+(local lsp
+ {:name :lsp
+ :S ["<cmd>Telescope lsp_dynamic_workspace_symbols<cr>"
+ "Workspace Symbols"]
+ :a ["<cmd>lua vim.lsp.buf.code_action()<cr>" "Code Action"]
+ :f ["<cmd>lua vim.lsp.buf.format { async = true }<cr>" :Format]
+ :i [:<cmd>LspInfo<cr> :Info]
+ :l ["<cmd>lua vim.lsp.codelens.run()<cr>" "CodeLens Action"]
+ :r ["<cmd>lua vim.lsp.buf.rename()<cr>" :Rename]
+ :s ["<cmd>Telescope lsp_document_symbols<cr>" "Document Symbols"]})
+
+(local replace {:name :replace
+ :m [:<cmd>ReplaceInBuf<cr> "Replace in Buffer"]
+ :n [:<cmd>Replace<cr> :Replace]
+ :e [:<cmd>ReplaceWord<cr> "Replace Word"]})
+
+(local session
+ {:name :session
+ :m [:<cmd>RestoreSession<cr> "Restore session"]
+ :n [:<cmd>RestoreLastSession<cr> "Restore last session"]
+ :e [:<cmd>IgnoreSession<cr> "Ignore current session"]})
+
+(local treesitter
+ {:name :Treesitter :p [:<cmd>TSPlaygroundToggle<cr> :Playground]})
+
+(local nmappings {:a ["<cmd>Telescope lsp_document_symbols theme=dropdown<cr>"
+ "Document Symbols"]
+ :T treesitter
+ :<BS> [:<cmd>BufDel<CR> "Close Buffer"]
+ :j diagnostics
+ :f find
+ :g git
+ :h [:<cmd>ColorizerToggle<cr> :Colorizer]
+ :l lsp
+ :m [:<cmd>Mason<cr> :Mason]
+ :n [:<cmd>SymbolsOutline<cr> "Symbols outline"]
+ :r replace
+ :s session
+ :t [:<cmd>ToggleTerm<cr> :Terminal]
+ :u [:<cmd>UndotreeToggle<cr> :Undotree]
+ :y ["<cmd>Lazy home<cr>" :Home]
+ :z [:<cmd>ZenMode<cr> "Zen Mode"]})
+
+(local vopts {:mode :v
+ :prefix :<leader>
+ :buffer nil
+ :silent true
+ :noremap true
+ :nowait true})
+
+(local gopts {:mode :n
+ :prefix :g
+ :buffer nil
+ :silent true
+ :noremap true
+ :nowait true})
+
+(local gmappings {:a [:<cmd>OrgAgendaPrompt<cr> "Open agenda prompt"]
+ :c [:<cmd>OrgCapturePrompt<cr> "Open capture prompt"]
+ :m ["<cmd>Telescope orgmode search_headings theme=dropdown<cr>"
+ "Search headings"]})
+
+(fn setup []
+ (let [which-key (require :which-key)]
+ (which-key.setup opts)
+ (which-key.register mmappings mopts)
+ (which-key.register nmappings nopts)
+ (which-key.register gmappings gopts)))
+
+{1 :folke/which-key.nvim
+ :event :VeryLazy
+ :config (fn []
+ (setup))}
diff --git a/fnl/plugins/editor/window-picker.fnl b/fnl/plugins/editor/window-picker.fnl
new file mode 100644
index 0000000..2820409
--- /dev/null
+++ b/fnl/plugins/editor/window-picker.fnl
@@ -0,0 +1,19 @@
+;; Trim whitespaces on save.
+
+(fn pick-window [opts]
+ (let [window-picker (require :window-picker)]
+ (let [win (window-picker.pick_window)]
+ (if (not= win nil)
+ (vim.api.nvim_set_current_win win)))))
+
+{1 :s1n7ax/nvim-window-picker
+ :event :BufReadPost
+ :opts {:other_win_hl_color "#171717"
+ :fg_color "#E1E1E1"
+ :selection_chars :MNEIOARSTG}
+ :config (lambda [_ opts]
+ (let [window-picker (require :window-picker)]
+ (window-picker.setup opts)
+ (vim.keymap.set :n :<C-s>
+ (fn []
+ (pick-window)) {})))}
diff --git a/fnl/plugins/editor/zen.fnl b/fnl/plugins/editor/zen.fnl
new file mode 100644
index 0000000..6e9bee7
--- /dev/null
+++ b/fnl/plugins/editor/zen.fnl
@@ -0,0 +1,11 @@
+;; Zen mode.
+
+{1 :folke/zen-mode.nvim
+ :cmd :ZenMode
+ :opts {:window {:backdrop 1
+ :height 1
+ :width 120
+ :options {:signcolumn :no :number false :relativenumber false}}
+ :plugins {:gitsigns {:enabled false}
+ :tmux {:enabled true}
+ :twilight {:enabled true}}}}