From 32cee319fb3b7ed811a0babc16cb71d054ba09da Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Sat, 8 May 2021 22:24:53 +0200 Subject: [PATCH] () for days! --- files/.config/nvim/fnl/init.fnl | 110 +++++++- files/.config/nvim/fnl/keybinds.fnl | 11 +- files/.config/nvim/fnl/macros.fnl | 5 + files/.config/nvim/fnl/plugins.fnl | 12 +- .../nvim/fnl/plugins/detect-indent.fnl | 6 + files/.config/nvim/fnl/plugins/emmet.fnl | 7 + files/.config/nvim/fnl/plugins/gitsigns.fnl | 6 +- files/.config/nvim/fnl/plugins/lsp.fnl | 3 +- files/.config/nvim/fnl/plugins/sneak.fnl | 7 + files/.config/nvim/fnl/plugins/telescope.fnl | 4 +- files/.config/nvim/fnl/utils.fnl | 35 +-- files/.config/nvim/init.vim | 236 ------------------ 12 files changed, 169 insertions(+), 273 deletions(-) create mode 100644 files/.config/nvim/fnl/plugins/detect-indent.fnl create mode 100644 files/.config/nvim/fnl/plugins/emmet.fnl create mode 100644 files/.config/nvim/fnl/plugins/sneak.fnl diff --git a/files/.config/nvim/fnl/init.fnl b/files/.config/nvim/fnl/init.fnl index 8b24883..31965e6 100644 --- a/files/.config/nvim/fnl/init.fnl +++ b/files/.config/nvim/fnl/init.fnl @@ -2,6 +2,7 @@ {autoload {utils utils nvim aniseed.nvim a aniseed.core + str aniseed.string fennel aniseed.fennel colors colors} require-macros [macros]}) @@ -14,8 +15,63 @@ (make-errors-epic (require "plugins.lsp")) (make-errors-epic (require "keybinds")) +; Basic setup --------------------------------------- foldstart -(set vim.g.conjure#client#fennel#aniseed#aniseed_module_prefix "aniseed.") +(vim-let mapleader "\\") +(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 :cclose") + +; foldend ; Colors ------------------------------------------------------- foldstart @@ -23,13 +79,35 @@ ["GruvboxBlueSign" "GruvboxAquaSign" "GruvboxRedSign" "GruvboxYellowSign" "GruvboxGreenSign" "GruvboxOrangeSign" "GruvboxPurpleSign"] {: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 +; Plugin config ----------------------- foldstart -;(nvim-biscuits.setup {} - ;{ :on_events ["InsertLeave" "CursorHoldI"]}) +(set vim.g.VM_leader "m") ; visual-multi leader + + +; 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 (var remapped-space nil) @@ -40,10 +118,10 @@ (fn _G.UnbindSpaceStuff [] (when (and remapped-space (~= remapped-space {})) - (utils.del-keymap :i : true) - (when (~= remapped-space.old "") - (utils.keymap :i : remapped-space.old {:buffer true})) - (set remapped-space nil))) + (utils.del-keymap :i : true) + (when (~= remapped-space.old "") + (utils.keymap :i : remapped-space.old {:buffer true})) + (set remapped-space nil))) @@ -56,5 +134,21 @@ ; 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 diff --git a/files/.config/nvim/fnl/keybinds.fnl b/files/.config/nvim/fnl/keybinds.fnl index 5bfba6f..3e9c991 100644 --- a/files/.config/nvim/fnl/keybinds.fnl +++ b/files/.config/nvim/fnl/keybinds.fnl @@ -13,10 +13,19 @@ (utils.keymap :i : "compe#close('')" {:expr true}) -(utils.keymap :n : "Telescope find_files") +(utils.keymap [:n] : "Telescope find_files") +(utils.keymap :n :K "") +(utils.keymap :v :K "") +; TODO let's see if i want these +; (utils.keymap :n : "") +; (utils.keymap :n : "") +; (utils.keymap :n : "") +; (utils.keymap :n : "") + + (fn cmd [s desc] [(.. "" s "") desc]) (fn rebind [s desc] [s desc]) diff --git a/files/.config/nvim/fnl/macros.fnl b/files/.config/nvim/fnl/macros.fnl index b359f38..6b17487 100644 --- a/files/.config/nvim/fnl/macros.fnl +++ b/files/.config/nvim/fnl/macros.fnl @@ -30,6 +30,11 @@ (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] diff --git a/files/.config/nvim/fnl/plugins.fnl b/files/.config/nvim/fnl/plugins.fnl index 66bc39b..06785ae 100644 --- a/files/.config/nvim/fnl/plugins.fnl +++ b/files/.config/nvim/fnl/plugins.fnl @@ -5,10 +5,11 @@ :nvim-telescope/telescope.nvim {:mod "plugins.telescope" :requires [:nvim-lua/popup.nvim :nvim-lua/plenary.nvim]} - :p00f/nvim-ts-rainbow {:mod "plugins.treesitter"} + :p00f/nvim-ts-rainbow {} :romgrk/nvim-treesitter-context {} :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 @@ -50,7 +51,6 @@ :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 :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 :iamcco/markdown-preview.nvim {:run vim.fn.mkdp#util#install} @@ -67,9 +67,9 @@ :tami5/compe-conjure {} :machakann/vim-highlightedyank {} - :ciaranm/detectindent {} + :ciaranm/detectindent {:mod "plugins.detect-indent"} :pechorin/any-jump.vim {} - :justinmk/vim-sneak {} + :justinmk/vim-sneak {:mod "plugins.sneak"} :psliwka/vim-smoothie {} :editorconfig/editorconfig-vim {} :honza/vim-snippets {} @@ -90,7 +90,7 @@ :sheerun/vim-polyglot {} ; Syntax highlighting for most languages :HerringtonDarkholme/yats.vim {} ; typescript syntax highlighting :mxw/vim-jsx {} - ;:mattn/emmet-vim {} + :mattn/emmet-vim {:mod "plugins.emmet"} :purescript-contrib/purescript-vim {} diff --git a/files/.config/nvim/fnl/plugins/detect-indent.fnl b/files/.config/nvim/fnl/plugins/detect-indent.fnl new file mode 100644 index 0000000..e8fca5b --- /dev/null +++ b/files/.config/nvim/fnl/plugins/detect-indent.fnl @@ -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) + diff --git a/files/.config/nvim/fnl/plugins/emmet.fnl b/files/.config/nvim/fnl/plugins/emmet.fnl new file mode 100644 index 0000000..0b66594 --- /dev/null +++ b/files/.config/nvim/fnl/plugins/emmet.fnl @@ -0,0 +1,7 @@ +(module plugins.emmet) + +(set vim.g.user_emmet_mode "n") +(set vim.g.user_emmet_leader_key "e") +(set vim.g.user_emmet_settings {:javascript.jsx {:extends "jsx"} + :typescript.jsx {:extends "jsx"}}) + diff --git a/files/.config/nvim/fnl/plugins/gitsigns.fnl b/files/.config/nvim/fnl/plugins/gitsigns.fnl index d82c0ed..0e03bf8 100644 --- a/files/.config/nvim/fnl/plugins/gitsigns.fnl +++ b/files/.config/nvim/fnl/plugins/gitsigns.fnl @@ -12,9 +12,13 @@ :changedelete {:text "▍"}} :keymaps {:noremap true :buffer true} - :current_line_blame true + :current_line_blame false :update_debounce 100}) (utils.highlight "GitSignsAdd" {:bg "NONE" :fg colors.bright_aqua}) (utils.highlight "GitSignsDelete" {:bg "NONE" :fg colors.neutral_red}) (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}) diff --git a/files/.config/nvim/fnl/plugins/lsp.fnl b/files/.config/nvim/fnl/plugins/lsp.fnl index e170873..b6e2c5e 100644 --- a/files/.config/nvim/fnl/plugins/lsp.fnl +++ b/files/.config/nvim/fnl/plugins/lsp.fnl @@ -6,9 +6,8 @@ require-macros [macros]}) - (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)) (if client.resolved_capabilities.document_highlight diff --git a/files/.config/nvim/fnl/plugins/sneak.fnl b/files/.config/nvim/fnl/plugins/sneak.fnl new file mode 100644 index 0000000..a53b524 --- /dev/null +++ b/files/.config/nvim/fnl/plugins/sneak.fnl @@ -0,0 +1,7 @@ +(module plugins.sneak + {autoload {utils utils}}) + + +(set vim.g.sneak#label 1) +(utils.keymap [:n :o] : "Sneak_s" {:noremap false}) +(utils.keymap [:n :o] : "Sneak_s" {:noremap false}) diff --git a/files/.config/nvim/fnl/plugins/telescope.fnl b/files/.config/nvim/fnl/plugins/telescope.fnl index 5e04013..8115efe 100644 --- a/files/.config/nvim/fnl/plugins/telescope.fnl +++ b/files/.config/nvim/fnl/plugins/telescope.fnl @@ -3,8 +3,6 @@ telescope telescope actions telescope.actions}}) -(telescope.setup - {:defaults - {:i { "" actions.close}}}) +(telescope.setup {}) (utils.keymap :n : ":Telescope find_files") diff --git a/files/.config/nvim/fnl/utils.fnl b/files/.config/nvim/fnl/utils.fnl index b3dd1bf..af967ec 100644 --- a/files/.config/nvim/fnl/utils.fnl +++ b/files/.config/nvim/fnl/utils.fnl @@ -14,6 +14,9 @@ (a.println (fennel.view 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] (or (a.some #(= elem $1) list)) false) @@ -26,16 +29,19 @@ (defn without-keys [keys 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" (local full-opts (->> (or ?opts {}) (a.merge {:noremap true :silent true}) (without-keys [:buffer]))) (if (and ?opts (?. ?opts :buffer)) - (nvim.buf_set_keymap 0 mode from to full-opts) - (nvim.set_keymap mode from to full-opts))) + (a.println (fennel.view modes)) + (each [_ mode (ipairs (single-to-list modes))] + (nvim.buf_set_keymap 0 mode from to full-opts) + (nvim.set_keymap mode from to full-opts)))) (defn del-keymap [mode from ?buf-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.del_keymap mode from))) - (defn- safe-require-plugin-config [name] (xpcall #(require name) @@ -70,20 +75,18 @@ (defn highlight [group-arg colset] (let [default { :fg "NONE" :bg "NONE" :gui "NONE"} - opts (a.merge default colset) - hl-groups (if (a.string? group-arg) [group-arg] group-arg)] - (each [_ group (ipairs hl-groups)] + opts (a.merge default colset)] + (each [_ group (ipairs (single-to-list group-arg))] (nvim.command (.. "hi! "group" guifg='"opts.fg"' guibg='"opts.bg"' gui='"opts.gui"'"))))) (defn highlight-add [group-arg colset] - (let [hl-groups (if (a.string? group-arg) [group-arg] group-arg)] - (each [_ group (ipairs hl-groups)] - (nvim.command - (.. "hi! " - group - (surround-if-present " guibg='"colset.bg"'") - (surround-if-present " guifg='"colset.fg"'") - (surround-if-present " gui='"colset.gui"'")))))) + (each [_ group (ipairs (single-to-list group-arg))] + (nvim.command + (.. "hi! " + group + (surround-if-present " guibg='"colset.bg"'") + (surround-if-present " guifg='"colset.fg"'") + (surround-if-present " gui='"colset.gui"'"))))) (defn comp [f g] diff --git a/files/.config/nvim/init.vim b/files/.config/nvim/init.vim index 6e3231e..ca43d6f 100644 --- a/files/.config/nvim/init.vim +++ b/files/.config/nvim/init.vim @@ -1,11 +1,3 @@ -" __ _(_)_ __ ___ _ __ ___ -" \ \ / / | '_ ` _ \| '__/ __| -" \ V /| | | | | | | | | (__ -" \_/ |_|_| |_| |_|_| \___| - - -"set runtimepath^=~/coding/tmp/coc.nvim/ - let g:vim_config_root = expand(':p:h') let $VIM_ROOT = g:vim_config_root @@ -28,231 +20,3 @@ ensure("Olical", "aniseed") vim.g["aniseed#env"] = { compile = true } EOF -"luafile $VIM_ROOT/plugins.lua - -if &shell =~# 'fish$' - set shell=bash -endif - -let mapleader ="\" - -" 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 :call system('clip.exe', GetSelectedText()) - vnoremap :call system('clip.exe', GetSelectedText())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 :cclose - -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 -nnoremap -nnoremap -nnoremap -set splitbelow splitright - -" Buffer switching -"noremap l :bnext -"noremap h :bprevious - -" Disable default K mapping (would open man page of hovered word) -nnoremap K -vnoremap K - - -" }}} - -" 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 Sneak_s -nmap Sneak_S -omap Sneak_s -omap Sneak_S - - -let g:rust_clip_command = 'xclip -selection clipboard' -let g:rustfmt_autosave = 1 - -let g:user_emmet_leader_key='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()