Update use! macro to work more like Emacs's use-package
This commit is contained in:
parent
f3d4ab7797
commit
8ef3d14e1e
@ -33,14 +33,35 @@
|
|||||||
: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!'
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
;; Treesitter
|
;; Treesitter
|
||||||
(use! :nvim-treesitter/nvim-treesitter
|
(use! :nvim-treesitter/nvim-treesitter
|
||||||
:config #(setup! "nvim-treesitter.configs"
|
:config
|
||||||
|
(setup! :nvim-treesitter.configs
|
||||||
:ensure_installed :all
|
:ensure_installed :all
|
||||||
:sync_install false
|
:sync_install false
|
||||||
:auto_install true
|
:auto_install true
|
||||||
@ -25,7 +26,8 @@
|
|||||||
;; 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,7 +35,8 @@
|
|||||||
;; 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
|
||||||
|
(setup! :lualine
|
||||||
:options { :section_separators ""
|
:options { :section_separators ""
|
||||||
:component_separators "│" }
|
:component_separators "│" }
|
||||||
:sections { :lualine_x [
|
:sections { :lualine_x [
|
||||||
@ -46,7 +49,8 @@
|
|||||||
;; 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
|
||||||
|
(setup! :bufferline
|
||||||
:options {
|
:options {
|
||||||
:always_show_bufferline false
|
:always_show_bufferline false
|
||||||
:mode :tabs
|
:mode :tabs
|
||||||
@ -56,7 +60,8 @@
|
|||||||
|
|
||||||
;; fzf (a fuzzy finder)
|
;; fzf (a fuzzy finder)
|
||||||
(use! :ibhagwan/fzf-lua
|
(use! :ibhagwan/fzf-lua
|
||||||
:config #(let [fzf (require :fzf-lua)]
|
:config
|
||||||
|
(let [fzf (require :fzf-lua)]
|
||||||
(fzf.register_ui_select)
|
(fzf.register_ui_select)
|
||||||
(bind! :n :<leader>fq fzf.quickfix)
|
(bind! :n :<leader>fq fzf.quickfix)
|
||||||
(bind! :n :<leader>fr fzf.registers)
|
(bind! :n :<leader>fr fzf.registers)
|
||||||
@ -102,34 +107,39 @@
|
|||||||
|
|
||||||
;; 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
|
||||||
|
(setup! :nvim-find-other
|
||||||
:c [ "h" "H" ]
|
:c [ "h" "H" ]
|
||||||
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
|
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
|
||||||
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
|
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
|
||||||
@ -139,11 +149,11 @@
|
|||||||
"FindOtherFile"
|
"FindOtherFile"
|
||||||
find-other.find_other_current_buffer
|
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"
|
||||||
@ -157,22 +167,23 @@
|
|||||||
: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
|
||||||
|
(let [map (require :snippy.mapping)]
|
||||||
(bind! [ :i :s ] :<tab> ((. map :next) :<tab>))
|
(bind! [ :i :s ] :<tab> ((. map :next) :<tab>))
|
||||||
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>))))
|
(bind! [ :i :s ] :<s-tab> (map.previous :<tab>))))
|
||||||
|
|
||||||
@ -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