mirror of
https://github.com/elkowar/dots-of-war.git
synced 2024-11-06 03:12:24 +00:00
Epic use macro
This commit is contained in:
parent
c4e7ed4ee6
commit
5a5de804e3
6 changed files with 132 additions and 91 deletions
|
@ -1,4 +1,10 @@
|
|||
{
|
||||
"optOut": false,
|
||||
"lastUpdateCheck": 1619802461034
|
||||
"lastUpdateCheck": 1620514416532,
|
||||
"update": {
|
||||
"latest": "7.12.0",
|
||||
"current": "6.14.12",
|
||||
"type": "major",
|
||||
"name": "npm"
|
||||
}
|
||||
}
|
|
@ -23,47 +23,44 @@
|
|||
(vim.cmd "filetype plugin indent on")
|
||||
(vim.cmd "syntax on")
|
||||
|
||||
(set vim.o.showmode false)
|
||||
(set vim.o.foldmethod "marker")
|
||||
(set vim.o.undodir (.. vim.env.HOME "/.vim/undo-dir"))
|
||||
(set vim.o.undofile true)
|
||||
(set vim.o.shortmess (.. vim.o.shortmess "c")) ; Don't give completion messages like 'match 1 of 2' or 'The only match'
|
||||
(set vim.o.hidden true)
|
||||
(set vim.o.encoding "utf-8")
|
||||
(set vim.o.number false)
|
||||
(set vim.o.relativenumber false)
|
||||
(set vim.o.compatible false)
|
||||
(set vim.o.cursorline true)
|
||||
(set vim.o.incsearch true)
|
||||
(set vim.o.hlsearch true)
|
||||
(set vim.o.inccommand "nosplit")
|
||||
(set vim.o.signcolumn "yes")
|
||||
(set vim.o.shiftwidth 2)
|
||||
(set vim.o.tabstop 2)
|
||||
(set vim.o.backspace "indent,eol,start")
|
||||
(set vim.o.autoindent true)
|
||||
(set vim.o.smartindent true)
|
||||
(set vim.o.expandtab true)
|
||||
(set vim.o.wrap false)
|
||||
(set vim.o.completeopt "longest,menuone,noselect")
|
||||
(set vim.o.laststatus 2)
|
||||
(set vim.o.showmode true)
|
||||
(set vim.o.splitbelow true)
|
||||
(set vim.o.splitright true)
|
||||
(set vim.o.mouse "a")
|
||||
(set vim.o.shell "bash")
|
||||
(set vim.o.background "dark")
|
||||
(se foldmethod "marker")
|
||||
(se showmode false)
|
||||
(se undodir (.. vim.env.HOME "/.vim/undo-dir"))
|
||||
(se undofile true)
|
||||
(se shortmess (.. vim.o.shortmess "c")) ; Don't give completion messages like 'match 1 of 2' or 'The only match'
|
||||
(se hidden true)
|
||||
(se encoding "utf-8")
|
||||
(se number false)
|
||||
(se relativenumber false)
|
||||
(se compatible false)
|
||||
(se cursorline true)
|
||||
(se incsearch true)
|
||||
(se hlsearch true)
|
||||
(se inccommand "nosplit")
|
||||
(se signcolumn "yes")
|
||||
(se shiftwidth 2)
|
||||
(se tabstop 2)
|
||||
(se backspace "indent,eol,start")
|
||||
(se autoindent true)
|
||||
(se smartindent true)
|
||||
(se expandtab true)
|
||||
(se wrap false)
|
||||
(se completeopt "longest,menuone,noselect")
|
||||
(se laststatus 2)
|
||||
(se showmode true)
|
||||
(se splitbelow true)
|
||||
(se splitright true)
|
||||
(se mouse "a")
|
||||
(se shell "bash")
|
||||
(se background "dark")
|
||||
|
||||
(when (vim.fn.has "termguicolors")
|
||||
(set vim.o.termguicolors true))
|
||||
|
||||
(when (not (vim.fn.has "gui_running"))
|
||||
(set vim.o.t_Co 256))
|
||||
(se termguicolors true))
|
||||
|
||||
(vim.cmd "colorscheme gruvbox")
|
||||
(vim-let &t_ut "")
|
||||
|
||||
(vim.cmd "autocmd! BufReadPost *.hs :set shiftwidth=2)")
|
||||
(vim.cmd "autocmd! BufReadPost *.hs :set shiftwidth=2")
|
||||
(vim.cmd "autocmd! FileType vim setlocal foldmethod=marker")
|
||||
|
||||
;Disables automatic commenting on newline)
|
||||
|
|
|
@ -1,59 +1,87 @@
|
|||
{:augroup
|
||||
(fn [name ...]
|
||||
`(do
|
||||
(nvim.ex.augroup ,(tostring name))
|
||||
(nvim.ex.autocmd_)
|
||||
,...
|
||||
(nvim.ex.augroup :END)))
|
||||
(fn [name ...]
|
||||
`(do
|
||||
(nvim.ex.augroup ,(tostring name))
|
||||
(nvim.ex.autocmd_)
|
||||
,...
|
||||
(nvim.ex.augroup :END)))
|
||||
|
||||
:autocmd
|
||||
(fn [...]
|
||||
`(nvim.ex.autocmd ,...))
|
||||
:autocmd
|
||||
(fn [...]
|
||||
`(nvim.ex.autocmd ,...))
|
||||
|
||||
:_:
|
||||
(fn [name ...]
|
||||
`((. nvim.ex ,(tostring name)) ,...))
|
||||
|
||||
:viml->fn
|
||||
(fn [name]
|
||||
`(.. "lua require('" *module-name* "')['" ,(tostring name) "']()"))
|
||||
|
||||
:dbg
|
||||
(fn [x]
|
||||
`(let [view# (. (require "aniseed.fennel") :view)]
|
||||
(print (.. `,(tostring x) " => " (view# ,x)))
|
||||
,x))
|
||||
|
||||
:dbg-call
|
||||
(fn [x ...]
|
||||
`(do
|
||||
(a.println ,...)
|
||||
(,x ,...)))
|
||||
|
||||
:pkg
|
||||
(fn [name mappings ...]
|
||||
`(if (~= nil (. packer_plugins `,(tostring name)))
|
||||
(let ,mappings ,...)
|
||||
(print (.. "plugin disabled " `,(tostring name)))))
|
||||
|
||||
:vim-let
|
||||
(fn [field value]
|
||||
(let [text (.. "let " `,(tostring field) "=\"" value "\"")]
|
||||
`(vim.cmd ,text)))
|
||||
|
||||
:each-pair
|
||||
(fn [args ...]
|
||||
(let [[l# r# d#] args]
|
||||
`(let [data# ,d#]
|
||||
(for [i# 1 (a.count data#) 2]
|
||||
(let [,l# (. data# i#)
|
||||
,r# (. data# (+ i# 1))]
|
||||
,...)))))}
|
||||
:_:
|
||||
(fn [name ...]
|
||||
`((. nvim.ex ,(tostring name)) ,...))
|
||||
|
||||
:viml->fn
|
||||
(fn [name]
|
||||
`(.. "lua require('" *module-name* "')['" ,(tostring name) "']()"))
|
||||
|
||||
:dbg
|
||||
(fn [x]
|
||||
`(let [view# (. (require "aniseed.fennel") :view)]
|
||||
(print (.. `,(tostring x) " => " (view# ,x)))
|
||||
,x))
|
||||
|
||||
:dbg-call
|
||||
(fn [x ...]
|
||||
`(do
|
||||
(a.println ,...)
|
||||
(,x ,...)))
|
||||
|
||||
:pkg
|
||||
(fn [name mappings ...]
|
||||
`(if (~= nil (. packer_plugins `,(tostring name)))
|
||||
(let ,mappings ,...)
|
||||
(print (.. "plugin disabled " `,(tostring name)))))
|
||||
|
||||
:vim-let
|
||||
(fn [field value]
|
||||
(let [text (.. "let " `,(tostring field) "=\"" value "\"")]
|
||||
`(vim.cmd ,text)))
|
||||
|
||||
:each-pair
|
||||
(fn [args ...]
|
||||
(let [[l# r# d#] args]
|
||||
`(let [data# ,d#]
|
||||
(for [i# 1 (a.count data#) 2]
|
||||
(let [,l# (. data# i#)
|
||||
,r# (. data# (+ i# 1))]
|
||||
,...)))))
|
||||
|
||||
:use-macro
|
||||
(fn [...]
|
||||
(let [a (require "aniseed.core")
|
||||
fennel (require "aniseed.fennel")
|
||||
args [...]
|
||||
use-statements []]
|
||||
(for [i 1 (a.count args) 2]
|
||||
(let [name (. args i)
|
||||
block (. args (+ i 1))]
|
||||
(a.assoc block 1 name)
|
||||
(when (. block :mod)
|
||||
(a.assoc block :config `#(require ,(. block :mod))))
|
||||
(a.assoc block :mod nil)
|
||||
(table.insert use-statements block)))
|
||||
|
||||
(let [use-sym (gensym)]
|
||||
`(let [packer# (require "packer")]
|
||||
(packer#.startup
|
||||
(fn [,use-sym]
|
||||
,(unpack
|
||||
(icollect [_# v# (ipairs use-statements)]
|
||||
`(,use-sym ,v#)))))))))
|
||||
|
||||
|
||||
:se
|
||||
(fn [name value]
|
||||
(let [str-name (tostring name)
|
||||
(info-ok scope) (pcall #(. (vim.api.nvim_get_option_info str-name) :scope))]
|
||||
(if info-ok
|
||||
(match scope
|
||||
:global `(tset vim.o ,str-name ,value)
|
||||
:win `(tset vim.wo ,str-name ,value)
|
||||
:buf `(tset vim.bo ,str-name ,value)
|
||||
_ (print (.. "option " str-name " has unhandled scope " scope)))
|
||||
(print (.. "Unknown vim-option: " str-name)))))}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
(module plugins
|
||||
{require {utils utils}})
|
||||
{require {utils utils}
|
||||
require-macros [macros]})
|
||||
|
||||
(utils.use
|
||||
(use-macro
|
||||
:nvim-telescope/telescope.nvim {:mod "plugins.telescope"
|
||||
:cmd ["Telescope"]
|
||||
:requires [:nvim-lua/popup.nvim :nvim-lua/plenary.nvim]}
|
||||
|
||||
:p00f/nvim-ts-rainbow {}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
telescope telescope
|
||||
actions telescope.actions}})
|
||||
|
||||
(print "initializing telescope")
|
||||
|
||||
(telescope.setup {})
|
||||
|
||||
(utils.keymap :n :<C-p> ":Telescope find_files<CR>")
|
||||
|
|
|
@ -42,6 +42,12 @@
|
|||
(nvim.buf_del_keymap 0 mode from)
|
||||
(nvim.del_keymap mode from)))
|
||||
|
||||
(defn pairs->tuples [xs]
|
||||
(let [result []]
|
||||
(each-pair [l r xs]
|
||||
(table.insert result (values l r)))
|
||||
result))
|
||||
|
||||
(defn- safe-require-plugin-config [name]
|
||||
(xpcall
|
||||
#(require name)
|
||||
|
|
Loading…
Reference in a new issue