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
|
||||
: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))
|
||||
(lambda use! [repo ...]
|
||||
(local output [ repo ])
|
||||
(var last_key nil)
|
||||
(var config_mode false)
|
||||
(var has_config false)
|
||||
(var config_entries (list `lambda []))
|
||||
(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)
|
||||
(set last_key nil))
|
||||
(= val :config)
|
||||
(do (set config_mode true)
|
||||
(set has_config true))
|
||||
(set last_key val)))
|
||||
(if has_config
|
||||
(tset output :config config_entries))
|
||||
`(use ,output))
|
||||
|
||||
;; Can be passed to :config of `use!'
|
||||
|
@ -14,7 +14,8 @@
|
||||
|
||||
;; Treesitter
|
||||
(use! :nvim-treesitter/nvim-treesitter
|
||||
:config #(setup! "nvim-treesitter.configs"
|
||||
:config
|
||||
(setup! :nvim-treesitter.configs
|
||||
:ensure_installed :all
|
||||
:sync_install false
|
||||
:auto_install true
|
||||
@ -25,7 +26,8 @@
|
||||
;; nightfox.nvim (colorscheme)
|
||||
(use! :EdenEast/nightfox.nvim
|
||||
:after :nvim-treesitter
|
||||
:config #(vim.cmd.colorscheme :carbonfox))
|
||||
:config
|
||||
(vim.cmd.colorscheme :carbonfox))
|
||||
|
||||
;; Devicons
|
||||
(use! :kyazdani42/nvim-web-devicons)
|
||||
@ -33,7 +35,8 @@
|
||||
;; lualine.nvim
|
||||
(use! :nvim-lualine/lualine.nvim
|
||||
:after [ :nightfox.nvim :nvim-web-devicons ]
|
||||
:config #(setup! :lualine
|
||||
:config
|
||||
(setup! :lualine
|
||||
:options { :section_separators ""
|
||||
:component_separators "│" }
|
||||
:sections { :lualine_x [
|
||||
@ -46,7 +49,8 @@
|
||||
;; bufferline.nvim
|
||||
(use! :akinsho/bufferline.nvim
|
||||
:after [ :nvim-web-devicons :nightfox.nvim ]
|
||||
:config #(setup! :bufferline
|
||||
:config
|
||||
(setup! :bufferline
|
||||
:options {
|
||||
:always_show_bufferline false
|
||||
:mode :tabs
|
||||
@ -56,7 +60,8 @@
|
||||
|
||||
;; fzf (a fuzzy finder)
|
||||
(use! :ibhagwan/fzf-lua
|
||||
:config #(let [fzf (require :fzf-lua)]
|
||||
:config
|
||||
(let [fzf (require :fzf-lua)]
|
||||
(fzf.register_ui_select)
|
||||
(bind! :n :<leader>fq fzf.quickfix)
|
||||
(bind! :n :<leader>fr fzf.registers)
|
||||
@ -102,34 +107,39 @@
|
||||
|
||||
;; Nvim surround
|
||||
(use! :kylechui/nvim-surround
|
||||
:config #(setup! :nvim-surround))
|
||||
:config
|
||||
(setup! :nvim-surround))
|
||||
|
||||
;; Leap
|
||||
(use! :ggandor/leap.nvim
|
||||
:after :nvim-treesitter
|
||||
:config (fn []
|
||||
:config
|
||||
((. (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 })))
|
||||
(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))
|
||||
:config
|
||||
(setup! :leap-spooky))
|
||||
|
||||
;; Flit (leap for 'till' and 'forward' motions)
|
||||
(use! :ggandor/flit.nvim
|
||||
:after :leap.nvim
|
||||
:config #(setup! :flit))
|
||||
:config
|
||||
(setup! :flit))
|
||||
|
||||
;; Comment.nvim
|
||||
(use! :numToStr/Comment.nvim
|
||||
:config #(setup! :Comment))
|
||||
:config
|
||||
(setup! :Comment))
|
||||
|
||||
;; nvim-find-other
|
||||
(use! "https://git.zander.im/Zander671/nvim-find-other.git"
|
||||
:config (fn [] (setup! :nvim-find-other
|
||||
:config
|
||||
(setup! :nvim-find-other
|
||||
:c [ "h" "H" ]
|
||||
:h [ "c" "C" "cpp" "cxx" "c++" "cc" ]
|
||||
:cpp [ "hpp" "hxx" "h++" "hh" "h" "H" ]
|
||||
@ -139,11 +149,11 @@
|
||||
"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)
|
||||
(use! :RRethy/vim-illuminate
|
||||
:config (fn []
|
||||
:config
|
||||
(module-call! :illuminate :configure)
|
||||
{ :providers [
|
||||
"lsp"
|
||||
@ -157,22 +167,23 @@
|
||||
:delay 0 }
|
||||
(hook! :FileType :lua #(vim.api.nvim_set_hl 0
|
||||
:IlluminatedWordText
|
||||
{}))))
|
||||
{})))
|
||||
|
||||
;; vlime (lisp environment)
|
||||
(use! :vlime/vlime
|
||||
:config (fn []
|
||||
:config
|
||||
(set vim.g.vlime_cl_impl :my_sbcl)
|
||||
(set vim.g.vlime_address [ "127.0.0.1" 52842 ])
|
||||
(vim.cmd "function! VlimeBuildServerCommandFor_my_sbcl(vlime_loader, vlime_eval)
|
||||
return [ \"/usr/bin/sbcl\",
|
||||
\\ \"--load\", a:vlime_loader,
|
||||
\\ \"--eval\", \"(vlime:main :port 52842)\" ]
|
||||
endfunction")))
|
||||
endfunction"))
|
||||
|
||||
;; 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 ] :<s-tab> (map.previous :<tab>))))
|
||||
|
||||
@ -186,22 +197,26 @@
|
||||
{ 1 :ray-x/cmp-treesitter
|
||||
:after :nvim-cmp }
|
||||
:dcampos/cmp-snippy ]
|
||||
:config (module-fn! :plugin.cmp :configure))
|
||||
:config
|
||||
(module-call! :plugin.cmp :configure))
|
||||
|
||||
;; guess style from buffer
|
||||
(use! :NMAC427/guess-indent.nvim
|
||||
:config #(setup! :guess-indent :auto_cmd true))
|
||||
:config
|
||||
(setup! :guess-indent :auto_cmd true))
|
||||
|
||||
;; lspconfig
|
||||
(use! :neovim/nvim-lspconfig
|
||||
:after [ :cmp-nvim-lsp
|
||||
:fzf-lua ]
|
||||
:config (module-fn! :plugin.lsp :configure))
|
||||
:config
|
||||
(module-call! :plugin.lsp :configure))
|
||||
|
||||
;; nvim-jdtls
|
||||
(use! :mfussenegger/nvim-jdtls
|
||||
:after :nvim-lspconfig
|
||||
:config (module-fn! :plugin.jdtls :configure))
|
||||
:config
|
||||
(module-call! :plugin.jdtls :configure))
|
||||
|
||||
;; Sync all packages on first launch
|
||||
(if _G.first_launch
|
||||
|
Reference in New Issue
Block a user