Simplify plugin list

This commit is contained in:
2022-11-30 22:27:40 -08:00
parent 74ada64375
commit 0991e5eacb
4 changed files with 247 additions and 437 deletions

70
fnl/macros.fnl Normal file
View File

@ -0,0 +1,70 @@
;;; macros.fnl - useful macros
;; Helpful keymaping functions
(lambda bind! [mode key cmd ?a1 ?a2]
(let [desc (or ?a2 ?a1)
buf (if (and ?a1 ?a2) ?a1 ?a2)
opts { :noremap true
:silent true
:buffer buf }]
(when desc
(tset opts :desc desc))
`(vim.keymap.set ,mode ,key ,cmd ,opts)))
;; Better autocommands
(lambda hook! [hooks ?patterns callback]
(let [hook_table (if (= (type hooks) :table)
hooks
[ hooks ])
pattern_table (if (not ?patterns)
[]
(= (type ?patterns) :table)
?patterns
[ ?patterns ])]
(var group "config-hook")
(each [_ hook (ipairs hook_table)]
(set group (.. group "-" hook)))
(each [_ pattern (ipairs pattern_table)]
(set group (.. group "-" pattern)))
`(vim.api.nvim_create_autocmd ,hook_table
{ :group
(vim.api.nvim_create_augroup ,group
{ :clear true })
:pattern ,pattern_table
:callback ,callback })))
;; Nicer macro for use
(lambda use! [repo ...]
(local output [ repo ])
(var last_key nil)
(each [_ val (ipairs [...])]
(if last_key
(do (tset output last_key val)
(set last_key nil))
(set last_key val)))
`(use ,output))
;; Can be passed to :config of `use!'
;; to call a plugin's `setup' function
(lambda setup! [pkg ...] (local output [ ])
(var last_key nil)
(each [_ val (ipairs [...])]
(if last_key
(do (tset output last_key val)
(set last_key nil))
(set last_key val)))
`((. (require ,pkg) :setup) ,output))
;; Call module function
(lambda module-call! [mod func ...]
`((. (require ,mod) ,func) ,...))
;; Return module function
(lambda module-fn! [mod func]
`(. (require ,mod) ,func))
{: bind!
: hook!
: use!
: setup!
: module-call!
: module-fn!}

174
fnl/plugin.fnl Normal file
View File

@ -0,0 +1,174 @@
;;; plugin.fnl - plugin configurations
(import-macros {: bind! : hook!
: use! : setup!
: module-call!
: module-fn!} :macros)
(fn [use]
;; Packer
(use! :wbthomason/packer.nvim)
;; tangerine.nvim (auto fennel compile)
(use! :udayvir-singh/tangerine.nvim)
;; Treesitter
(use! :nvim-treesitter/nvim-treesitter
:config #(setup! "nvim-treesitter.configs"
:ensure_installed :all
:sync_install false
:auto_install true
:highlight { :enable true
:additional_vim_regex_highlighting false }
:indent { :enable true }))
;; nightfox.nvim (colorscheme)
(use! :EdenEast/nightfox.nvim
:after :nvim-treesitter
:config #(vim.cmd.colorscheme :carbonfox))
;; Devicons
(use! :kyazdani42/nvim-web-devicons)
;; lualine.nvim
(use! :nvim-lualine/lualine.nvim
:after [ :nightfox.nvim :nvim-web-devicons ]
:config #(setup! :lualine
:options { :section_separators ""
:component_separators "│" }
:sections { :lualine_x [
{ 1 #(.. "recording @" (vim.fn.reg_recording))
:cond #(not= (# (vim.fn.reg_recording)) 0) }
:encoding
:fileformat
:filetype ]}))
;; bufferline.nvim
(use! :akinsho/bufferline.nvim
:after [ :nvim-web-devicons :nightfox.nvim ]
:config #(setup! :bufferline
:options {
:always_show_bufferline false
:mode :tabs
:numbers :buffer-id
:show_buffer_close_icons false
:show_close_icon false }))
;; fzf (a fuzzy finder)
(use! :ibhagwan/fzf-lua
:config (fn []
(let [fzf (require :fzf-lua)]
(fzf.register_ui_select)
(bind! :n :<leader>fq fzf.quickfix)
(bind! :n :<leader>fr fzf.registers)
(bind! :n :<leader>fj fzf.jumps)
(bind! :n :<leader>fa fzf.marks)
(bind! :n :<leader>fh fzf.help_tags)
(bind! :n :<leader>g fzf.live_grep)
(bind! :n :<leader>fg fzf.live_grep)
(bind! :n :<leader>G fzf.grep)
(bind! :n :<leader>fG fzf.grep)
(bind! :n :<leader>b fzf.buffers)
(bind! :n :gb fzf.buffers)
(bind! :n :<leader>fu fzf.git_status)
(bind! :n :<leader>fm fzf.man_pages)
(bind! :n :<leader>fe fzf.diagnostics_document)
(bind! :n :<leader>fE fzf.diagnostics_workspace)
(bind! :n :<leader>fp fzf.spell_suggest)
(bind! :n :<leader>i fzf.files)
(bind! :n :z= fzf.spell_suggest)
(bind! :n :<leader>ff (fn []
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
(if (= code 0)
(fzf.git_files)
(fzf.files))))))))
;; Nvim surround
(use! :kylechui/nvim-surround
:config #(setup! :nvim-surround))
;; Leap
(use! :ggandor/leap.nvim
:after :nvim-treesitter
:config (fn []
((. (require :leap) :add_default_mappings))
(bind! :o :z "<plug>(leap-forward-to)")
(bind! :o :Z "<plug>(leap-backward-to)")
(vim.api.nvim_set_hl 0 :LeapBackdrop { :link :Comment })))
;; Leap spooky (remote operations)
(use! :ggandor/leap-spooky.nvim
:after :leap.nvim
:config #(setup! :leap-spooky))
;; Flit (leap for 'till' and 'forward' motions)
(use! :ggandor/flit.nvim
:after :leap.nvim
:config #(setup! :flit))
;; Comment.nvim
(use! :numToStr/Comment.nvim
:config #(setup! :Comment))
;; nvim-find-other
(use! "https://git.zander.im/Zander671/nvim-find-other.git"
:config (fn [] (setup! :nvim-find-other
:c [ "h" "H" ]
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
:hpp [ "cpp" "cxx" "c++" "cc" ])
(let [find_other (require :nvim-find-other)]
(vim.api.nvim_create_user_command
"FindOtherFile"
find_other.find_other_current_buffer
{})
(bind! :n :go find_other.find_other_current_buffer))))
(use! :RRethy/vim-illuminate
:config (fn []
(module-call! :illuminate :configure)
{ :providers [
"lsp"
"treesitter"
"ragex" ]
:modes_denylist [
:markdown
:text
:gitconfig
:gitignore ]
:delay 0 }
(hook! :FileType :lua #(vim.api.nvim_set_hl 0
:IlluminatedWordText
{}))))
;; Snippy
(use! :dcampos/nvim-snippy
:config #(let [map (require :snippy.mapping)]
(bind! [ :i :s ] :<tab> ((. map :next) :<tab>))
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>))))
;; nvim-cmp (autocomplete)
(use! :hrsh7th/nvim-cmp
:requires [ :hrsh7th/cmp-buffer
:hrsh7th/cmp-path
:hrsh7th/cmp-cmdline
:hrsh7th/cmp-nvim-lsp
{ 1 :ray-x/cmp-treesitter
:after :nvim-cmp }
:dcampos/cmp-snippy ]
:config (module-fn! :plugin.cmp :configure))
;; lspconfig
(use! :neovim/nvim-lspconfig
:after [ :cmp-nvim-lsp
:fzf-lua ]
:config (module-fn! :plugin.lsp :configure))
;; nvim-jdtls
(use! :mfussenegger/nvim-jdtls
:after :nvim-lspconfig
:config (module-fn! :plugin.jdtls :configure))
;; Sync all packages on first launch
(if _G.first_launch
(module-call! :packer :sync)))