Update use! macro to work more like Emacs's use-package
This commit is contained in:
parent
f3d4ab7797
commit
8ef3d14e1e
@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
;; Better autocommands
|
;; Better autocommands
|
||||||
(lambda hook! [hooks ?patterns callback]
|
(lambda hook! [hooks ?patterns callback]
|
||||||
(let [hook_table (if (= (type hooks) :table)
|
(let [hook_table (if (= (type hooks) :table)
|
||||||
hooks
|
hooks
|
||||||
[ hooks ])
|
[ hooks ])
|
||||||
pattern_table (if (not ?patterns)
|
pattern_table (if (not ?patterns)
|
||||||
[]
|
[]
|
||||||
(= (type ?patterns) :table)
|
(= (type ?patterns) :table)
|
||||||
?patterns
|
?patterns
|
||||||
[ ?patterns ])]
|
[ ?patterns ])]
|
||||||
(var group "config-hook")
|
(var group "config-hook")
|
||||||
(each [_ hook (ipairs hook_table)]
|
(each [_ hook (ipairs hook_table)]
|
||||||
@ -27,20 +27,41 @@
|
|||||||
(each [_ pattern (ipairs pattern_table)]
|
(each [_ pattern (ipairs pattern_table)]
|
||||||
(set group (.. group "-" pattern)))
|
(set group (.. group "-" pattern)))
|
||||||
`(vim.api.nvim_create_autocmd ,hook_table
|
`(vim.api.nvim_create_autocmd ,hook_table
|
||||||
{ :group
|
{ :group
|
||||||
(vim.api.nvim_create_augroup ,group
|
(vim.api.nvim_create_augroup ,group
|
||||||
{ :clear true })
|
{ :clear true })
|
||||||
:pattern ,pattern_table
|
:pattern ,pattern_table
|
||||||
:callback ,callback })))
|
:callback ,callback })))
|
||||||
;; Nicer macro for use
|
;; 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))
|
||||||
(lambda use! [repo ...]
|
(lambda use! [repo ...]
|
||||||
(local output [ repo ])
|
(local output [ repo ])
|
||||||
(var last_key nil)
|
(var last_key nil)
|
||||||
|
(var config_mode false)
|
||||||
|
(var has_config false)
|
||||||
|
(var config_entries (list `lambda []))
|
||||||
(each [_ val (ipairs [...])]
|
(each [_ val (ipairs [...])]
|
||||||
(if last_key
|
(if config_mode
|
||||||
|
(if (= (type val) :string)
|
||||||
|
(set config_mode false)
|
||||||
|
(table.insert config_entries val))
|
||||||
|
last_key
|
||||||
(do (tset output last_key val)
|
(do (tset output last_key val)
|
||||||
(set last_key nil))
|
(set last_key nil))
|
||||||
|
(= val :config)
|
||||||
|
(do (set config_mode true)
|
||||||
|
(set has_config true))
|
||||||
(set last_key val)))
|
(set last_key val)))
|
||||||
|
(if has_config
|
||||||
|
(tset output :config config_entries))
|
||||||
`(use ,output))
|
`(use ,output))
|
||||||
|
|
||||||
;; Can be passed to :config of `use!'
|
;; Can be passed to :config of `use!'
|
||||||
@ -62,7 +83,7 @@
|
|||||||
(lambda module-fn! [mod func]
|
(lambda module-fn! [mod func]
|
||||||
`(. (require ,mod) ,func))
|
`(. (require ,mod) ,func))
|
||||||
|
|
||||||
{: bind!
|
{: bind!
|
||||||
: hook!
|
: hook!
|
||||||
: use!
|
: use!
|
||||||
: setup!
|
: setup!
|
||||||
|
249
fnl/plugin.fnl
249
fnl/plugin.fnl
@ -14,18 +14,20 @@
|
|||||||
|
|
||||||
;; Treesitter
|
;; Treesitter
|
||||||
(use! :nvim-treesitter/nvim-treesitter
|
(use! :nvim-treesitter/nvim-treesitter
|
||||||
:config #(setup! "nvim-treesitter.configs"
|
:config
|
||||||
:ensure_installed :all
|
(setup! :nvim-treesitter.configs
|
||||||
:sync_install false
|
:ensure_installed :all
|
||||||
:auto_install true
|
:sync_install false
|
||||||
:highlight { :enable true
|
:auto_install true
|
||||||
:additional_vim_regex_highlighting false }
|
:highlight { :enable true
|
||||||
:indent { :enable true }))
|
:additional_vim_regex_highlighting false }
|
||||||
|
:indent { :enable true }))
|
||||||
|
|
||||||
;; nightfox.nvim (colorscheme)
|
;; nightfox.nvim (colorscheme)
|
||||||
(use! :EdenEast/nightfox.nvim
|
(use! :EdenEast/nightfox.nvim
|
||||||
:after :nvim-treesitter
|
:after :nvim-treesitter
|
||||||
:config #(vim.cmd.colorscheme :carbonfox))
|
:config
|
||||||
|
(vim.cmd.colorscheme :carbonfox))
|
||||||
|
|
||||||
;; Devicons
|
;; Devicons
|
||||||
(use! :kyazdani42/nvim-web-devicons)
|
(use! :kyazdani42/nvim-web-devicons)
|
||||||
@ -33,148 +35,157 @@
|
|||||||
;; lualine.nvim
|
;; lualine.nvim
|
||||||
(use! :nvim-lualine/lualine.nvim
|
(use! :nvim-lualine/lualine.nvim
|
||||||
:after [ :nightfox.nvim :nvim-web-devicons ]
|
:after [ :nightfox.nvim :nvim-web-devicons ]
|
||||||
:config #(setup! :lualine
|
:config
|
||||||
:options { :section_separators ""
|
(setup! :lualine
|
||||||
:component_separators "│" }
|
:options { :section_separators ""
|
||||||
:sections { :lualine_x [
|
:component_separators "│" }
|
||||||
{ 1 #(.. "recording @" (vim.fn.reg_recording))
|
:sections { :lualine_x [
|
||||||
:cond #(not= (# (vim.fn.reg_recording)) 0) }
|
{ 1 #(.. "recording @" (vim.fn.reg_recording))
|
||||||
:encoding
|
:cond #(not= (# (vim.fn.reg_recording)) 0) }
|
||||||
:fileformat
|
:encoding
|
||||||
:filetype ]}))
|
:fileformat
|
||||||
|
:filetype ]}))
|
||||||
|
|
||||||
;; bufferline.nvim
|
;; bufferline.nvim
|
||||||
(use! :akinsho/bufferline.nvim
|
(use! :akinsho/bufferline.nvim
|
||||||
:after [ :nvim-web-devicons :nightfox.nvim ]
|
:after [ :nvim-web-devicons :nightfox.nvim ]
|
||||||
:config #(setup! :bufferline
|
:config
|
||||||
:options {
|
(setup! :bufferline
|
||||||
:always_show_bufferline false
|
:options {
|
||||||
:mode :tabs
|
:always_show_bufferline false
|
||||||
:numbers :buffer-id
|
:mode :tabs
|
||||||
:show_buffer_close_icons false
|
:numbers :buffer-id
|
||||||
:show_close_icon false }))
|
:show_buffer_close_icons false
|
||||||
|
:show_close_icon false }))
|
||||||
|
|
||||||
;; fzf (a fuzzy finder)
|
;; fzf (a fuzzy finder)
|
||||||
(use! :ibhagwan/fzf-lua
|
(use! :ibhagwan/fzf-lua
|
||||||
:config #(let [fzf (require :fzf-lua)]
|
:config
|
||||||
(fzf.register_ui_select)
|
(let [fzf (require :fzf-lua)]
|
||||||
(bind! :n :<leader>fq fzf.quickfix)
|
(fzf.register_ui_select)
|
||||||
(bind! :n :<leader>fr fzf.registers)
|
(bind! :n :<leader>fq fzf.quickfix)
|
||||||
(bind! :n :<leader>fj fzf.jumps)
|
(bind! :n :<leader>fr fzf.registers)
|
||||||
(bind! :n :<leader>fa fzf.marks)
|
(bind! :n :<leader>fj fzf.jumps)
|
||||||
(bind! :n :<leader>fh fzf.help_tags)
|
(bind! :n :<leader>fa fzf.marks)
|
||||||
(bind! :n :<leader>g fzf.live_grep)
|
(bind! :n :<leader>fh fzf.help_tags)
|
||||||
(bind! :n :<leader>fg fzf.live_grep)
|
(bind! :n :<leader>g fzf.live_grep)
|
||||||
(bind! :n :<leader>G fzf.grep)
|
(bind! :n :<leader>fg fzf.live_grep)
|
||||||
(bind! :n :<leader>fG fzf.grep)
|
(bind! :n :<leader>G fzf.grep)
|
||||||
(bind! :n :<leader>b fzf.buffers)
|
(bind! :n :<leader>fG fzf.grep)
|
||||||
(bind! :n :gb fzf.buffers)
|
(bind! :n :<leader>b fzf.buffers)
|
||||||
(bind! :n :<leader>fu fzf.git_status)
|
(bind! :n :gb fzf.buffers)
|
||||||
(bind! :n :<leader>fm fzf.man_pages)
|
(bind! :n :<leader>fu fzf.git_status)
|
||||||
(bind! :n :<leader>fe fzf.diagnostics_document)
|
(bind! :n :<leader>fm fzf.man_pages)
|
||||||
(bind! :n :<leader>fE fzf.diagnostics_workspace)
|
(bind! :n :<leader>fe fzf.diagnostics_document)
|
||||||
(bind! :n :<leader>d fzf.loclist)
|
(bind! :n :<leader>fE fzf.diagnostics_workspace)
|
||||||
(bind! :n :<leader>fp fzf.spell_suggest)
|
(bind! :n :<leader>d fzf.loclist)
|
||||||
(bind! :n :<leader>i fzf.files)
|
(bind! :n :<leader>fp fzf.spell_suggest)
|
||||||
(bind! :n :z= fzf.spell_suggest)
|
(bind! :n :<leader>i fzf.files)
|
||||||
(bind! :n :<leader>ff (fn []
|
(bind! :n :z= fzf.spell_suggest)
|
||||||
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
|
(bind! :n :<leader>ff (fn []
|
||||||
(if (= code 0)
|
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
|
||||||
(fzf.git_files)
|
(if (= code 0)
|
||||||
(fzf.files)))))
|
(fzf.git_files)
|
||||||
(fn jump-or-open-terminal []
|
(fzf.files)))))
|
||||||
"If no terminal buffer exists, create one. Otherwise, open new one."
|
(fn jump-or-open-terminal []
|
||||||
(var term_count 0)
|
"If no terminal buffer exists, create one. Otherwise, open new one."
|
||||||
(var last_id 0)
|
(var term_count 0)
|
||||||
(var terms [ ])
|
(var last_id 0)
|
||||||
(each [_ id (pairs (vim.api.nvim_list_bufs))]
|
(var terms [ ])
|
||||||
(let [name (vim.api.nvim_buf_get_name id)]
|
(each [_ id (pairs (vim.api.nvim_list_bufs))]
|
||||||
(when (vim.startswith name "term://")
|
(let [name (vim.api.nvim_buf_get_name id)]
|
||||||
(table.insert terms name)
|
(when (vim.startswith name "term://")
|
||||||
(set term_count (+ term_count 1))
|
(table.insert terms name)
|
||||||
(set last_id id))))
|
(set term_count (+ term_count 1))
|
||||||
(if (= term_count 0)
|
(set last_id id))))
|
||||||
(vim.cmd.terminal)
|
(if (= term_count 0)
|
||||||
(= term_count 1)
|
(vim.cmd.terminal)
|
||||||
(vim.cmd.buffer last_id)
|
(= term_count 1)
|
||||||
(fzf.buffers { :query "term://" })))
|
(vim.cmd.buffer last_id)
|
||||||
(bind! :n :<leader>t jump-or-open-terminal)))
|
(fzf.buffers { :query "term://" })))
|
||||||
|
(bind! :n :<leader>t jump-or-open-terminal)))
|
||||||
|
|
||||||
;; Nvim surround
|
;; Nvim surround
|
||||||
(use! :kylechui/nvim-surround
|
(use! :kylechui/nvim-surround
|
||||||
:config #(setup! :nvim-surround))
|
:config
|
||||||
|
(setup! :nvim-surround))
|
||||||
|
|
||||||
;; Leap
|
;; Leap
|
||||||
(use! :ggandor/leap.nvim
|
(use! :ggandor/leap.nvim
|
||||||
:after :nvim-treesitter
|
:after :nvim-treesitter
|
||||||
:config (fn []
|
:config
|
||||||
((. (require :leap) :add_default_mappings))
|
((. (require :leap) :add_default_mappings))
|
||||||
(bind! :o :z "<plug>(leap-forward-to)")
|
(bind! :o :z "<plug>(leap-forward-to)")
|
||||||
(bind! :o :Z "<plug>(leap-backward-to)")
|
(bind! :o :Z "<plug>(leap-backward-to)")
|
||||||
(vim.api.nvim_set_hl 0 :LeapBackdrop { :link :Comment })))
|
(vim.api.nvim_set_hl 0 :LeapBackdrop { :link :Comment }))
|
||||||
|
|
||||||
;; Leap spooky (remote operations)
|
;; Leap spooky (remote operations)
|
||||||
(use! :ggandor/leap-spooky.nvim
|
(use! :ggandor/leap-spooky.nvim
|
||||||
:after :leap.nvim
|
:after :leap.nvim
|
||||||
:config #(setup! :leap-spooky))
|
:config
|
||||||
|
(setup! :leap-spooky))
|
||||||
|
|
||||||
;; Flit (leap for 'till' and 'forward' motions)
|
;; Flit (leap for 'till' and 'forward' motions)
|
||||||
(use! :ggandor/flit.nvim
|
(use! :ggandor/flit.nvim
|
||||||
:after :leap.nvim
|
:after :leap.nvim
|
||||||
:config #(setup! :flit))
|
:config
|
||||||
|
(setup! :flit))
|
||||||
|
|
||||||
;; Comment.nvim
|
;; Comment.nvim
|
||||||
(use! :numToStr/Comment.nvim
|
(use! :numToStr/Comment.nvim
|
||||||
:config #(setup! :Comment))
|
:config
|
||||||
|
(setup! :Comment))
|
||||||
|
|
||||||
;; nvim-find-other
|
;; nvim-find-other
|
||||||
(use! "https://git.zander.im/Zander671/nvim-find-other.git"
|
(use! "https://git.zander.im/Zander671/nvim-find-other.git"
|
||||||
:config (fn [] (setup! :nvim-find-other
|
:config
|
||||||
:c [ "h" "H" ]
|
(setup! :nvim-find-other
|
||||||
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
|
:c [ "h" "H" ]
|
||||||
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
|
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
|
||||||
:hpp [ "cpp" "cxx" "c++" "cc" ])
|
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
|
||||||
(let [find-other (require :nvim-find-other)]
|
:hpp [ "cpp" "cxx" "c++" "cc" ])
|
||||||
(vim.api.nvim_create_user_command
|
(let [find-other (require :nvim-find-other)]
|
||||||
"FindOtherFile"
|
(vim.api.nvim_create_user_command
|
||||||
find-other.find_other_current_buffer
|
"FindOtherFile"
|
||||||
{})
|
find-other.find_other_current_buffer
|
||||||
(bind! :n :go find-other.find_other_current_buffer))))
|
{})
|
||||||
|
(bind! :n :go find-other.find_other_current_buffer)))
|
||||||
|
|
||||||
;; illuminate (same symbol highlight)
|
;; illuminate (same symbol highlight)
|
||||||
(use! :RRethy/vim-illuminate
|
(use! :RRethy/vim-illuminate
|
||||||
:config (fn []
|
:config
|
||||||
(module-call! :illuminate :configure)
|
(module-call! :illuminate :configure)
|
||||||
{ :providers [
|
{ :providers [
|
||||||
"lsp"
|
"lsp"
|
||||||
"treesitter"
|
"treesitter"
|
||||||
"ragex" ]
|
"ragex" ]
|
||||||
:modes_denylist [
|
:modes_denylist [
|
||||||
:markdown
|
:markdown
|
||||||
:text
|
:text
|
||||||
:gitconfig
|
:gitconfig
|
||||||
:gitignore ]
|
:gitignore ]
|
||||||
:delay 0 }
|
:delay 0 }
|
||||||
(hook! :FileType :lua #(vim.api.nvim_set_hl 0
|
(hook! :FileType :lua #(vim.api.nvim_set_hl 0
|
||||||
:IlluminatedWordText
|
:IlluminatedWordText
|
||||||
{}))))
|
{})))
|
||||||
|
|
||||||
;; vlime (lisp environment)
|
;; vlime (lisp environment)
|
||||||
(use! :vlime/vlime
|
(use! :vlime/vlime
|
||||||
:config (fn []
|
:config
|
||||||
(set vim.g.vlime_cl_impl :my_sbcl)
|
(set vim.g.vlime_cl_impl :my_sbcl)
|
||||||
(set vim.g.vlime_address [ "127.0.0.1" 52842 ])
|
(set vim.g.vlime_address [ "127.0.0.1" 52842 ])
|
||||||
(vim.cmd "function! VlimeBuildServerCommandFor_my_sbcl(vlime_loader, vlime_eval)
|
(vim.cmd "function! VlimeBuildServerCommandFor_my_sbcl(vlime_loader, vlime_eval)
|
||||||
return [ \"/usr/bin/sbcl\",
|
return [ \"/usr/bin/sbcl\",
|
||||||
\\ \"--load\", a:vlime_loader,
|
\\ \"--load\", a:vlime_loader,
|
||||||
\\ \"--eval\", \"(vlime:main :port 52842)\" ]
|
\\ \"--eval\", \"(vlime:main :port 52842)\" ]
|
||||||
endfunction")))
|
endfunction"))
|
||||||
|
|
||||||
;; Snippy
|
;; Snippy
|
||||||
(use! :dcampos/nvim-snippy
|
(use! :dcampos/nvim-snippy
|
||||||
:config #(let [map (require :snippy.mapping)]
|
:config
|
||||||
(bind! [ :i :s ] :<tab> ((. map :next) :<tab>))
|
(let [map (require :snippy.mapping)]
|
||||||
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>))))
|
(bind! [ :i :s ] :<tab> ((. map :next) :<tab>))
|
||||||
|
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>))))
|
||||||
|
|
||||||
;; nvim-cmp (autocomplete)
|
;; nvim-cmp (autocomplete)
|
||||||
(use! :hrsh7th/nvim-cmp
|
(use! :hrsh7th/nvim-cmp
|
||||||
@ -186,22 +197,26 @@
|
|||||||
{ 1 :ray-x/cmp-treesitter
|
{ 1 :ray-x/cmp-treesitter
|
||||||
:after :nvim-cmp }
|
:after :nvim-cmp }
|
||||||
:dcampos/cmp-snippy ]
|
:dcampos/cmp-snippy ]
|
||||||
:config (module-fn! :plugin.cmp :configure))
|
:config
|
||||||
|
(module-call! :plugin.cmp :configure))
|
||||||
|
|
||||||
;; guess style from buffer
|
;; guess style from buffer
|
||||||
(use! :NMAC427/guess-indent.nvim
|
(use! :NMAC427/guess-indent.nvim
|
||||||
:config #(setup! :guess-indent :auto_cmd true))
|
:config
|
||||||
|
(setup! :guess-indent :auto_cmd true))
|
||||||
|
|
||||||
;; lspconfig
|
;; lspconfig
|
||||||
(use! :neovim/nvim-lspconfig
|
(use! :neovim/nvim-lspconfig
|
||||||
:after [ :cmp-nvim-lsp
|
:after [ :cmp-nvim-lsp
|
||||||
:fzf-lua ]
|
:fzf-lua ]
|
||||||
:config (module-fn! :plugin.lsp :configure))
|
:config
|
||||||
|
(module-call! :plugin.lsp :configure))
|
||||||
|
|
||||||
;; nvim-jdtls
|
;; nvim-jdtls
|
||||||
(use! :mfussenegger/nvim-jdtls
|
(use! :mfussenegger/nvim-jdtls
|
||||||
:after :nvim-lspconfig
|
:after :nvim-lspconfig
|
||||||
:config (module-fn! :plugin.jdtls :configure))
|
:config
|
||||||
|
(module-call! :plugin.jdtls :configure))
|
||||||
|
|
||||||
;; Sync all packages on first launch
|
;; Sync all packages on first launch
|
||||||
(if _G.first_launch
|
(if _G.first_launch
|
||||||
|
Reference in New Issue
Block a user