() for days!

This commit is contained in:
elkowar 2021-05-08 22:24:53 +02:00
parent 7256f19a47
commit 32cee319fb
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
12 changed files with 169 additions and 273 deletions

View file

@ -2,6 +2,7 @@
{autoload {utils utils {autoload {utils utils
nvim aniseed.nvim nvim aniseed.nvim
a aniseed.core a aniseed.core
str aniseed.string
fennel aniseed.fennel fennel aniseed.fennel
colors colors} colors colors}
require-macros [macros]}) require-macros [macros]})
@ -14,8 +15,63 @@
(make-errors-epic (require "plugins.lsp")) (make-errors-epic (require "plugins.lsp"))
(make-errors-epic (require "keybinds")) (make-errors-epic (require "keybinds"))
; Basic setup --------------------------------------- foldstart
(set vim.g.conjure#client#fennel#aniseed#aniseed_module_prefix "aniseed.") (vim-let mapleader "\\<Space>")
(vim-let maplocalleader ",")
(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/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")
(when (vim.fn.has "termguicolors")
(set vim.o.termguicolors true))
(when (not (vim.fn.has "gui_running"))
(set vim.o.t_Co 256))
(vim.cmd "colorscheme gruvbox")
(vim-let &t_ut "")
(vim.cmd "autocmd! BufReadPost *.hs :set shiftwidth=2)")
(vim.cmd "autocmd! FileType vim setlocal foldmethod=marker")
;Disables automatic commenting on newline)
(vim.cmd "autocmd! FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o")
; Auto-close quickfix list when element is selected)
(vim.cmd "autocmd! FileType qf nnoremap <buffer> <CR> <CR>:cclose<CR>")
; foldend
; Colors ------------------------------------------------------- foldstart ; Colors ------------------------------------------------------- foldstart
@ -23,13 +79,35 @@
["GruvboxBlueSign" "GruvboxAquaSign" "GruvboxRedSign" "GruvboxYellowSign" "GruvboxGreenSign" "GruvboxOrangeSign" "GruvboxPurpleSign"] ["GruvboxBlueSign" "GruvboxAquaSign" "GruvboxRedSign" "GruvboxYellowSign" "GruvboxGreenSign" "GruvboxOrangeSign" "GruvboxPurpleSign"]
{:bg "NONE"}) {:bg "NONE"})
; hide empty line ~'s
(utils.highlight :EndOfBuffer {:bg "NONE" :fg colors.dark0})
(utils.highlight :LineNr {:bg "NONE"})
(utils.highlight-add :Pmenu {:bg colors.dark0_hard})
(utils.highlight-add :PmenuSel {:bg colors.bright_aqua})
(utils.highlight-add :PmenuSbar {:bg colors.dark0_hard})
(utils.highlight-add :PmenuThumb {:bg colors.dark1})
(utils.highlight-add :NormalFloat {:bg colors.dark0_hard})
(utils.highlight-add :SignColumn {:bg colors.dark0})
(vim.cmd "highlight link Function GruvboxGreen")
; foldend ; foldend
; Plugin config ----------------------- foldstart
;(nvim-biscuits.setup {} (set vim.g.VM_leader "m") ; visual-multi leader
;{ :on_events ["InsertLeave" "CursorHoldI"]})
; rust.vim
(set vim.g.rust_clip_command "xclip -selection clipboard")
(set vim.g.rustfmt_autosave 1)
(set vim.g.conjure#client#fennel#aniseed#aniseed_module_prefix "aniseed.")
(set vim.g.vim_parinfer_filetypes ["carp" "fennel"])
; foldend
; :: and _ as space ------------------------------------------------------------------- foldstart ; :: and _ as space ------------------------------------------------------------------- foldstart
(var remapped-space nil) (var remapped-space nil)
@ -56,5 +134,21 @@
; foldend ; foldend
; :: autoclose empty unnamed buffers ----------------------------------------------- foldstart
; vim:foldmarker=foldstart,foldend (fn _G.clean_no_name_empty_buffers []
(let [bufs (a.filter #(and (vim.api.nvim_buf_get_option $1 "buflisted")
(a.empty? (vim.fn.bufname $1))
(< (vim.fn.bufwinnr $1) 0)
(if (vim.api.nvim_buf_is_loaded $1)
(a.empty? (vim.api.nvim_buf_get_lines $1 0 -1 false))
false))
(vim.fn.range 1 (vim.api.nvim_buf_get_number "$")))]
(when (not (a.empty? bufs))
(nvim.command (.. "bd " (str.join " " bufs))))))
(nvim.command "autocmd! BufCreate * :call v:lua.clean_no_name_empty_buffers()")
; foldend
; vim:foldmarker=foldstart,foldend

View file

@ -13,10 +13,19 @@
(utils.keymap :i :<esc> "compe#close('<esc>')" {:expr true}) (utils.keymap :i :<esc> "compe#close('<esc>')" {:expr true})
(utils.keymap :n :<C-p> "<cmd>Telescope find_files<cr>") (utils.keymap [:n] :<C-p> "<cmd>Telescope find_files<cr>")
(utils.keymap :n :K "<Nop>")
(utils.keymap :v :K "<Nop>")
; TODO let's see if i want these
; (utils.keymap :n :<C-h> "<C-w><C-h>")
; (utils.keymap :n :<C-j> "<C-w><C-j>")
; (utils.keymap :n :<C-k> "<C-w><C-k>")
; (utils.keymap :n :<C-l> "<C-w><C-l>")
(fn cmd [s desc] [(.. "<cmd>" s "<cr>") desc]) (fn cmd [s desc] [(.. "<cmd>" s "<cr>") desc])
(fn rebind [s desc] [s desc]) (fn rebind [s desc] [s desc])

View file

@ -30,6 +30,11 @@
(let ,mappings ,...) (let ,mappings ,...)
(print (.. "plugin disabled " `,(tostring name))))) (print (.. "plugin disabled " `,(tostring name)))))
:vim-let
(fn [field value]
(let [text (.. "let " `,(tostring field) "=\"" value "\"")]
`(vim.cmd ,text)))
:each-pair :each-pair
(fn [args ...] (fn [args ...]
(let [[l# r# d#] args] (let [[l# r# d#] args]

View file

@ -5,10 +5,11 @@
:nvim-telescope/telescope.nvim {:mod "plugins.telescope" :nvim-telescope/telescope.nvim {:mod "plugins.telescope"
:requires [:nvim-lua/popup.nvim :nvim-lua/plenary.nvim]} :requires [:nvim-lua/popup.nvim :nvim-lua/plenary.nvim]}
:p00f/nvim-ts-rainbow {:mod "plugins.treesitter"} :p00f/nvim-ts-rainbow {}
:romgrk/nvim-treesitter-context {} :romgrk/nvim-treesitter-context {}
:JoosepAlviste/nvim-ts-context-commentstring {} :JoosepAlviste/nvim-ts-context-commentstring {}
:nvim-treesitter/nvim-treesitter {:run ":TSUpdate"} :nvim-treesitter/nvim-treesitter {:mod "plugins.treesitter"
:run ":TSUpdate"}
; :code-biscuits/nvim-biscuits {} ; show opening line after closing curly ; :code-biscuits/nvim-biscuits {} ; show opening line after closing curly
@ -50,7 +51,6 @@
:mg979/vim-visual-multi {} :mg979/vim-visual-multi {}
:hauleth/sad.vim {} ; Use siw instead of ciw. when using . afterwards, will find the next occurrence of the changed word and change it too :hauleth/sad.vim {} ; Use siw instead of ciw. when using . afterwards, will find the next occurrence of the changed word and change it too
:wellle/targets.vim {} ; more text objects. IE: cin (change in next parens). generally better handling of surrounding objects. :wellle/targets.vim {} ; more text objects. IE: cin (change in next parens). generally better handling of surrounding objects.
:unblevable/quick-scope {} ; highlight targets when pressing f<character>
:iamcco/markdown-preview.nvim {:run vim.fn.mkdp#util#install} :iamcco/markdown-preview.nvim {:run vim.fn.mkdp#util#install}
@ -67,9 +67,9 @@
:tami5/compe-conjure {} :tami5/compe-conjure {}
:machakann/vim-highlightedyank {} :machakann/vim-highlightedyank {}
:ciaranm/detectindent {} :ciaranm/detectindent {:mod "plugins.detect-indent"}
:pechorin/any-jump.vim {} :pechorin/any-jump.vim {}
:justinmk/vim-sneak {} :justinmk/vim-sneak {:mod "plugins.sneak"}
:psliwka/vim-smoothie {} :psliwka/vim-smoothie {}
:editorconfig/editorconfig-vim {} :editorconfig/editorconfig-vim {}
:honza/vim-snippets {} :honza/vim-snippets {}
@ -90,7 +90,7 @@
:sheerun/vim-polyglot {} ; Syntax highlighting for most languages :sheerun/vim-polyglot {} ; Syntax highlighting for most languages
:HerringtonDarkholme/yats.vim {} ; typescript syntax highlighting :HerringtonDarkholme/yats.vim {} ; typescript syntax highlighting
:mxw/vim-jsx {} :mxw/vim-jsx {}
;:mattn/emmet-vim {} :mattn/emmet-vim {:mod "plugins.emmet"}
:purescript-contrib/purescript-vim {} :purescript-contrib/purescript-vim {}

View file

@ -0,0 +1,6 @@
(module plugins.detect-indent)
(vim.cmd "autocmd! BufReadPost * :DetectIndent")
(set vim.g.detectindent_preferred_expandtab 1)
(set vim.g.detectindent_preferred_indent 2)

View file

@ -0,0 +1,7 @@
(module plugins.emmet)
(set vim.g.user_emmet_mode "n")
(set vim.g.user_emmet_leader_key "<leader>e")
(set vim.g.user_emmet_settings {:javascript.jsx {:extends "jsx"}
:typescript.jsx {:extends "jsx"}})

View file

@ -12,9 +12,13 @@
:changedelete {:text "▍"}} :changedelete {:text "▍"}}
:keymaps {:noremap true :keymaps {:noremap true
:buffer true} :buffer true}
:current_line_blame true :current_line_blame false
:update_debounce 100}) :update_debounce 100})
(utils.highlight "GitSignsAdd" {:bg "NONE" :fg colors.bright_aqua}) (utils.highlight "GitSignsAdd" {:bg "NONE" :fg colors.bright_aqua})
(utils.highlight "GitSignsDelete" {:bg "NONE" :fg colors.neutral_red}) (utils.highlight "GitSignsDelete" {:bg "NONE" :fg colors.neutral_red})
(utils.highlight "GitSignsChange" {:bg "NONE" :fg colors.bright_blue}) (utils.highlight "GitSignsChange" {:bg "NONE" :fg colors.bright_blue})
; this no work, but https://github.com/lewis6991/gitsigns.nvim/blob/d89f88384567afc7a72b597e130008126fdb97f7/teal/gitsigns/highlight.tl#L19
; REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
; (utils.highlight "GitSignsCurrentLineBlame" {:bg "NONE" :fg colors.dark0_soft})

View file

@ -6,9 +6,8 @@
require-macros [macros]}) require-macros [macros]})
(fn on_attach [client bufnr] (fn on_attach [client bufnr]
(pkg lsp-signature.nvim [lsp_signature (require "lsp_signature")] (pkg lsp_signature.nvim [lsp_signature (require "lsp_signature")]
(lsp_signature.on_attach)) (lsp_signature.on_attach))
(if client.resolved_capabilities.document_highlight (if client.resolved_capabilities.document_highlight

View file

@ -0,0 +1,7 @@
(module plugins.sneak
{autoload {utils utils}})
(set vim.g.sneak#label 1)
(utils.keymap [:n :o] :<DEL> "<Plug>Sneak_s" {:noremap false})
(utils.keymap [:n :o] :<S-DEL> "<Plug>Sneak_s" {:noremap false})

View file

@ -3,8 +3,6 @@
telescope telescope telescope telescope
actions telescope.actions}}) actions telescope.actions}})
(telescope.setup (telescope.setup {})
{:defaults
{:i { "<esc>" actions.close}}})
(utils.keymap :n :<C-p> ":Telescope find_files<CR>") (utils.keymap :n :<C-p> ":Telescope find_files<CR>")

View file

@ -14,6 +14,9 @@
(a.println (fennel.view x)) (a.println (fennel.view x))
x) x)
(defn single-to-list [x]
"Returns the list given to it. If given a single value, wraps it in a list"
(if (a.table? x) x [x]))
(defn contains? [list elem] (defn contains? [list elem]
(or (a.some #(= elem $1) list)) false) (or (a.some #(= elem $1) list)) false)
@ -26,16 +29,19 @@
(defn without-keys [keys t] (defn without-keys [keys t]
(filter-table #(not (contains? keys $1)) t)) (filter-table #(not (contains? keys $1)) t))
(defn keymap [mode from to ?opts]
"Set a mapping in the given mode, and some optional parameters, defaulting to {:noremap true :silent true}. (defn keymap [modes from to ?opts]
"Set a mapping in the given modes, and some optional parameters, defaulting to {:noremap true :silent true}.
If :buffer is set, uses buf_set_keymap rather than set_keymap" If :buffer is set, uses buf_set_keymap rather than set_keymap"
(local full-opts (local full-opts
(->> (or ?opts {}) (->> (or ?opts {})
(a.merge {:noremap true :silent true}) (a.merge {:noremap true :silent true})
(without-keys [:buffer]))) (without-keys [:buffer])))
(if (and ?opts (?. ?opts :buffer)) (if (and ?opts (?. ?opts :buffer))
(a.println (fennel.view modes))
(each [_ mode (ipairs (single-to-list modes))]
(nvim.buf_set_keymap 0 mode from to full-opts) (nvim.buf_set_keymap 0 mode from to full-opts)
(nvim.set_keymap mode from to full-opts))) (nvim.set_keymap mode from to full-opts))))
(defn del-keymap [mode from ?buf-local] (defn del-keymap [mode from ?buf-local]
"Remove a keymap. Arguments: mode, mapping, bool if mapping should be buffer-local." "Remove a keymap. Arguments: mode, mapping, bool if mapping should be buffer-local."
@ -43,7 +49,6 @@
(nvim.buf_del_keymap 0 mode from) (nvim.buf_del_keymap 0 mode from)
(nvim.del_keymap mode from))) (nvim.del_keymap mode from)))
(defn- safe-require-plugin-config [name] (defn- safe-require-plugin-config [name]
(xpcall (xpcall
#(require name) #(require name)
@ -70,20 +75,18 @@
(defn highlight [group-arg colset] (defn highlight [group-arg colset]
(let [default { :fg "NONE" :bg "NONE" :gui "NONE"} (let [default { :fg "NONE" :bg "NONE" :gui "NONE"}
opts (a.merge default colset) opts (a.merge default colset)]
hl-groups (if (a.string? group-arg) [group-arg] group-arg)] (each [_ group (ipairs (single-to-list group-arg))]
(each [_ group (ipairs hl-groups)]
(nvim.command (.. "hi! "group" guifg='"opts.fg"' guibg='"opts.bg"' gui='"opts.gui"'"))))) (nvim.command (.. "hi! "group" guifg='"opts.fg"' guibg='"opts.bg"' gui='"opts.gui"'")))))
(defn highlight-add [group-arg colset] (defn highlight-add [group-arg colset]
(let [hl-groups (if (a.string? group-arg) [group-arg] group-arg)] (each [_ group (ipairs (single-to-list group-arg))]
(each [_ group (ipairs hl-groups)]
(nvim.command (nvim.command
(.. "hi! " (.. "hi! "
group group
(surround-if-present " guibg='"colset.bg"'") (surround-if-present " guibg='"colset.bg"'")
(surround-if-present " guifg='"colset.fg"'") (surround-if-present " guifg='"colset.fg"'")
(surround-if-present " gui='"colset.gui"'")))))) (surround-if-present " gui='"colset.gui"'")))))
(defn comp [f g] (defn comp [f g]

View file

@ -1,11 +1,3 @@
" __ _(_)_ __ ___ _ __ ___
" \ \ / / | '_ ` _ \| '__/ __|
" \ V /| | | | | | | | | (__
" \_/ |_|_| |_| |_|_| \___|
"set runtimepath^=~/coding/tmp/coc.nvim/
let g:vim_config_root = expand('<sfile>:p:h') let g:vim_config_root = expand('<sfile>:p:h')
let $VIM_ROOT = g:vim_config_root let $VIM_ROOT = g:vim_config_root
@ -28,231 +20,3 @@ ensure("Olical", "aniseed")
vim.g["aniseed#env"] = { compile = true } vim.g["aniseed#env"] = { compile = true }
EOF EOF
"luafile $VIM_ROOT/plugins.lua
if &shell =~# 'fish$'
set shell=bash
endif
let mapleader ="\<Space>"
" ewwwwwwwwwwwwwwwwwwwww
let maplocalleader = ','
"let maplocalleader = 'm'
" Vanilla VIM configuration ------------------------------------ {{{
filetype plugin indent on
syntax on
set noshowmode " mode is already shown in airline
set foldmethod=marker
set undodir=~/.vim/undo-dir
set undofile
set shortmess+=c " Don't give completion messages like 'match 1 of 2' or 'The only match'
set hidden
set encoding=utf-8
set nonumber norelativenumber
set nocompatible
set cursorline
set incsearch
set hlsearch
set inccommand=nosplit
set signcolumn=yes
if (has("termguicolors"))
set termguicolors
endif
" Indentation
set shiftwidth=2
set tabstop=2
set backspace=indent,eol,start
set autoindent smartindent noet expandtab
set nowrap
set noshowmode " hide the mode as shown by vim, because the status line does it better!
set completeopt=longest,menuone,noselect " Enable autocompletion
set laststatus=2
set noshowmode
set background=dark
colorscheme gruvbox
let g:onedark_terminal_italics=1
hi LineNr ctermbg=NONE guibg=NONE
hi Comment cterm=italic
let &t_ut=''
" hide empty line ~'s
highlight EndOfBuffer ctermfg=black ctermbg=black guibg=NONE guifg='#282828'
hi Pmenu ctermbg=black guibg='#1d2021'
hi PmenuSel guibg='#8ec07c'
hi PmenuSbar guibg='#1d2021'
hi PmenuThumb guibg='#3c3836'
hi WhichKeyFloating ctermbg=black guibg='#282828'
hi NormalFloat ctermbg=black guibg='#1d2021'
hi SignColumn ctermbg=NONE guibg='#282828'
hi link Function GruvboxGreen
if !has("nvim")
set term=xterm-256color
endif
" Clipboard support in WSL
func! GetSelectedText()
normal gv"xy
let result = getreg("x")
return result
endfunc
if !has("clipboard") && executable("clip.exe")
vnoremap <C-C> :call system('clip.exe', GetSelectedText())<CR>
vnoremap <C-X> :call system('clip.exe', GetSelectedText())<CR>gvx
endif
" Mouse config
set mouse=a
if !has("nvim")
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
end
if !has('gui_running')
set t_Co=256
endif
augroup basics
autocmd!
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o "Disables automatic commenting on newline:
autocmd FileType vim setlocal foldmethod=marker
" file type assignments
autocmd BufRead,BufNewFile *.ddl setlocal filetype=sql
" Auto-close quickfix list when element
autocmd FileType qf nnoremap <buffer> <CR> <CR>:cclose<CR>
augroup END
" autoclose empty unedited buffers
function! CleanNoNameEmptyBuffers()
let buffers = filter(range(1, bufnr('$')), 'buflisted(v:val) && empty(bufname(v:val)) && bufwinnr(v:val) < 0 && (getbufline(v:val, 1, "$") == [""])')
if !empty(buffers)
exe 'bd '.join(buffers, ' ')
else
echo 'No buffer deleted'
endif
endfunction
autocmd BufCreate * execute 'call CleanNoNameEmptyBuffers()'
" this nearly works, and does the same
" ; autoclose empty unedited buffers
" (fn _G.clean_no_name_empty_buffers []
" (local bufs
" (a.filter
" #(and
" (vim.api.nvim_buf_get_option $1 "buflisted")
" (a.empty? (vim.fn.bufname $1))
" (< (vim.fn.bufwinnr $1) 0)
" (vim.api.nvim_buf_is_loaded $1))
" ;(do (utils.dbg (.. (fennel.view $1) " -> " (fennel.view (vim.api.nvim_buf_is_loaded $1))) true)))
" ;(a.empty? (vim.api.nvim_buf_get_lines $1 1 (vim.api.nvim_buf_line_count $1) false)))
" (vim.fn.range 1 (vim.fn.bufnr "$"))))
" (when (not (a.empty? bufs))
" (nvim.command (.. "bd " (str.join " " bufs)))))
"
" (nvim.command "autocmd! BufCreate * :call v:lua.clean_no_name_empty_buffers()")
"
" ; autocmd BufCreate * execute 'call CleanNoNameEmptyBuffers()'
" ===============
" Basic remapping
" ===============
" Split configs
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
set splitbelow splitright
" Buffer switching
"noremap <silent> <leader>l :bnext<CR>
"noremap <silent> <leader>h :bprevious<CR>
" Disable default K mapping (would open man page of hovered word)
nnoremap K <Nop>
vnoremap K <Nop>
" }}}
" Plugin configuration --------------------------------------------------- {{{
let g:VM_leader = 'm'
autocmd BufReadPost * :DetectIndent
let g:detectindent_preferred_expandtab = 1
let g:detectindent_preferred_indent = 2
autocmd BufReadPost *.hs :set shiftwidth=2
let g:vim_parinfer_filetypes = ['carp', 'fennel']
let g:sneak#label = 1
nmap <DEL> <Plug>Sneak_s
nmap <S-DEL> <Plug>Sneak_S
omap <DEL> <Plug>Sneak_s
omap <S-DEL> <Plug>Sneak_S
let g:rust_clip_command = 'xclip -selection clipboard'
let g:rustfmt_autosave = 1
let g:user_emmet_leader_key='<leader>e'
let g:user_emmet_settings = { 'javascript.jsx' : { 'extends' : 'jsx' }, 'typescript.jsx' : { 'extends' : 'jsx' } }
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
let g:qs_lazy_highlight = 1
" }}}
" }}}
" how 2 highlight group at cursor
":exe 'hi '.synIDattr(synID(line("."), col("."), 0),"name")
"source $VIM_ROOT/whichkeyConfig.vim
let g:aniseed#env = v:true
"let g:aniseed#env = { "compile": v:false }
"let g:lexima_no_default_rules = v:true
"call lexima#set_default_rules()