diff --git a/ftplugin/rust.lua b/after/ftplugin/rust.lua similarity index 100% rename from ftplugin/rust.lua rename to after/ftplugin/rust.lua diff --git a/init.lua b/init.lua index 6989ec2..48b635d 100644 --- a/init.lua +++ b/init.lua @@ -4,12 +4,11 @@ local vimrc_git = os.getenv("HOME") .. "/src/vimrc" -- N.B. should come before plugins and plugin specific settings vim.g.mapleader = ' ' -vim.cmd("source " .. vimrc_git .. "/plug.vim") +vim.cmd("source " .. vimrc_git .. "/plug.lua") vim.cmd("source " .. vimrc_git .. "/airline.vim") -vim.cmd("source " .. vimrc_git .. "/syntastic.vim") -vim.cmd("source " .. vimrc_git .. "/fzf.vim") vim.cmd("source " .. vimrc_git .. "/lsp.vim") -vim.cmd("source " .. vimrc_git .. "/mapping.vim") +vim.cmd("source " .. vimrc_git .. "/mapping.lua") +vim.cmd("source " .. vimrc_git .. "/fzf.vim") vim.cmd("source " .. vimrc_git .. "/jsonnet.vim") vim.cmd("source " .. vimrc_git .. "/nerdtree.vim") vim.cmd("source " .. vimrc_git .. "/wiki.vim") diff --git a/init.vim b/init.vim deleted file mode 100644 index c9ead8b..0000000 --- a/init.vim +++ /dev/null @@ -1,133 +0,0 @@ -" set the directory where vimrc git project is located -let vimrc_git=$HOME . "/src/vimrc" - -" it is a big fat key, after all -" N.B. should come before plugins and plugin specific settings -let mapleader = "\" - -" source aux files also under git control -let oldwd = getcwd() -exec "cd " . vimrc_git -source plug.vim -source airline.vim -source syntastic.vim -source fzf.vim -source lsp.vim -source mapping.vim -source jsonnet.vim -source nerdtree.vim -source wiki.vim -exec "cd " . oldwd - -" set up a line number on the current line but relative above and below to help -" with motion commands -set number -set relativenumber - -" even with the nice space/tab autodetect, prefer 4 for tab stops -" but let file type specifics override (for instance a setting of 2 for markdown -set tabstop=4 -" default to folding on syntax -set foldmethod=syntax -" disable automatic line breaks, rely on visual wrapping instead -set textwidth=0 -" make white space visible, where that matters -set list! -" except for help -autocmd FileType help setlocal nolist -" set up folding preferences -set fde=1 -" vim's spelling is smart enough for code, to only check comments -set spell -" add a hint for long lines -set colorcolumn=120 -" default to expanding tabs, I'm not insane -set expandtab - -" change buffer behaviors to no longer require changes when hiding a buffer -set hidden - -" look for vimrc in the current director as well as $MYVIMRC -set exrc -" make looking for local changes secure -set secure -" more secure -set modelines=0 -" preserve some context -set scrolloff=3 -" make the cursor a bit easier to follows -set cursorline -" make search work a bit more like tab completion in bash -set incsearch -set wildmode=longest:full -set wildmenu -" line break handling -set linebreak -set showbreak=+ -" always on status line -set laststatus=2 - -" let backspace work more naturally -set backspace=start,indent,eol -" favor modern encoding -set enc=utf-8 -" more readable config for list mode -set listchars+=nbsp:¬,tab:»·,trail:· -set listchars-=eol:$ -" smarter handling of case during search -set ignorecase -set smartcase -" centralize swap to have backup without clutter -set directory=$HOME/.var/nvim/swp// -" and undo -set undofile -set undodir=$HOME/.nvim/undodir -" make pastemode more accessible -set pastetoggle= -" save when moving away -au FocusLost * :wa - -" make sure to set TERM to xterm-256color in terminal program or app -colorscheme breezy -set background=light -set termguicolors - -" ensure autoread works, to detect file changes outside the editor -set autoread -au CursorHold * checktime - -" for gui, make it easier to tell different instances apart -set title - -" keep nvim from resetting font back to default from terminal config -set guicursor= - -set guioptions-=r -set guioptions-=b -set guioptions-=T -set guioptions-=m - -set mouse=nv - -set gfn=FiraCode\ Nerd\ Font\ Mono:h10 -" from https://stackoverflow.com/a/51424640 -let s:fontsize = 10 -function! AdjustFontSize(amount) - let s:fontsize = s:fontsize+a:amount - :execute "set gfn=FiraCode\\ Nerd\\ Font\\ Mono:h" . s:fontsize -endfunction - -noremap :call AdjustFontSize(1) -noremap :call AdjustFontSize(-1) -inoremap :call AdjustFontSize(1)a -inoremap :call AdjustFontSize(-1)a - - -lua << EOF - require('nvim-projectconfig').setup({autocmd=true}) - require("trouble").setup { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - } -EOF diff --git a/lsp.vim b/lsp.vim index c269e14..0c01023 100644 --- a/lsp.vim +++ b/lsp.vim @@ -12,25 +12,6 @@ set shortmess+=c " Recognize slint files autocmd BufEnter *.slint :setlocal filetype=slint -" Configure LSP through rust-tools.nvim plugin. -" rust-tools will configure and enable certain LSP features for us. -" See https://github.com/simrat39/rust-tools.nvim#configuration -lua <", rt.hover_actions.hover_actions, { buffer = bufnr}) - -- Code action groups - vim.keymap.set("n", "a>", rt.code_action_group.code_action_group, { buffer = bufnr}) - end - }, - }, -- rust-analyer options -}) -EOF - " Setup Completion " See https://github.com/hrsh7th/nvim-cmp#basic-configuration lua <', vim.cmd.UndotreeToggle) +-- quickly toggle a left, vsplit for an insanely powerful file explorer +vim.keymap.set('n', '', vim.cmd.NERDTreeToggle) +vim.keymap.set('n', '', vim.cmd.NERDTreeFind) +-- use similar key, esc, to exit terminal mode +vim.cmd("tnoremap ") + +-- Code navigation shortcuts +-- from https://github.com/neovim/nvim-lspconfig/blob/master/test/minimal_init.lua#L34 +vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) +vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) +vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) +vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) +-- vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) +-- vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) +vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) +end, opts) +vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) +vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) +vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) + + +vim.keymap.set('n', 'xx', vim.cmd.TroubleToggle, opts) +vim.keymap.set('n', 'xw', function() + vim.cmd("TroubleToggle workspace_diagnostics") +end, opts) +vim.keymap.set('n', 'xd', function() + vim.cmd("TroubleToggle workspace_diagnostics") +end, opts) +vim.keymap.set('n', 'xq', function() + vim.cmd("TroubleToggle quickfix") +end, opts) +vim.keymap.set('n', 'xl', function() + vim.cmd("TroubleToggle loclist") +end, opts) +-- work with Trouble to view lists of diagnostic warnings/errors + +vim.keymap.set('n', 't', function() + vim.cmd("e ~/Documents/Wiki/tags.md") +end, opts) +vim.keymap.set('n', 'tr', vim.cmd.VimwikiRebuildTags, opts) +vim.keymap.set('n', 'tg', vim.cmd.VimwikiGenerateTagLinks, opts) + +-- TODO translate to lua +--function! VimwikiFindAllIncompleteTasks() +-- lvimgrep /- \[ \]/ * +-- lopen +--endfunction + +--nmap wa :call VimwikiFindAllIncompleteTasks() diff --git a/mapping.vim b/mapping.vim deleted file mode 100644 index 42aad21..0000000 --- a/mapping.vim +++ /dev/null @@ -1,48 +0,0 @@ -" quickly clear Syntastic info -nmap :SyntasticReset -" toggle gundo's display -nmap :UndotreeToggle -" quickly toggle a left, vsplit for an insanely powerful file explorer -nmap :NERDTreeToggle -" open tree to current buffer -nmap :NERDTreeFind -" use similar key, esc, to exit terminal mode -tnoremap - -" from: https://sharksforarms.dev/posts/neovim-rust/ -" Code navigation shortcuts -nnoremap lua vim.lsp.buf.definition() -nnoremap K lua vim.lsp.buf.hover() -nnoremap gD lua vim.lsp.buf.implementation() -nnoremap lua vim.lsp.buf.signature_help() -nnoremap 1gD lua vim.lsp.buf.type_definition() -nnoremap gr lua vim.lsp.buf.references() -nnoremap g0 lua vim.lsp.buf.document_symbol() -nnoremap gW lua vim.lsp.buf.workspace_symbol() -nnoremap gd lua vim.lsp.buf.definition() -nnoremap ga lua vim.lsp.buf.code_action() -nnoremap rn lua vim.lsp.buf.rename() - -" Goto previous/next diagnostic warning/error -nnoremap g[ lua vim.diagnostic.goto_prev() -nnoremap g] lua vim.diagnostic.goto_next() -nnoremap gE lua vim.diagnostic.setloclist() - -" work with Trouble to view lists of diagnostic warnings/errors -nnoremap xx TroubleToggle -nnoremap xw TroubleToggle workspace_diagnostics -nnoremap xd TroubleToggle document_diagnostics -nnoremap xq TroubleToggle quickfix -nnoremap xl TroubleToggle loclist -nnoremap gR TroubleToggle lsp_references - -nnoremap t e ~/Documents/Wiki/tags.md -nnoremap tr VimwikiRebuildTags -nnoremap tg VimwikiGenerateTagLinks - -function! VimwikiFindAllIncompleteTasks() - lvimgrep /- \[ \]/ * - lopen -endfunction - -nmap wa :call VimwikiFindAllIncompleteTasks() diff --git a/plug.lua b/plug.lua new file mode 100644 index 0000000..518c76f --- /dev/null +++ b/plug.lua @@ -0,0 +1,105 @@ +local vim = vim +local Plug = vim.fn['plug#'] + +vim.call('plug#begin') + +-- I try to keep these to a minimum and to understand what each plugin does and +-- adds to my existing(set up. I try to capture the value, at least to me, each +-- plugin adds. I've tried to logically group them, as well, to spot overlap +-- and redundancy. + +-- dynamic font resizing(using ctl and arrow keys +Plug('tenxsoydev/size-matters.nvim') + + +-- informational +-- lightweight but sophisticated status line +Plug('vim-airline/vim-airline') +Plug('vim-airline/vim-airline-themes') +-- visualize vim's undo tree +Plug('mbbill/undotree') +-- diagnostics display +Plug('folke/trouble.nvim') +-- icons for Trouble +Plug('kyazdani42/nvim-web-devicons') + + +-- files, folders, projects, etc. +-- file and dir browser +Plug('preservim/nerdtree') +-- integrate ripgrep, especially to be able to open matches, hugely useful for +-- code aware search +Plug('jremmen/vim-ripgrep') +-- Support for the cd replacement, zoxide +Plug('nanotee/zoxide.vim') +-- taskwarrior +Plug('xarthurx/taskwarrior.vim') +-- Wiki support - my life is in vimwiki +Plug('vimwiki/vimwiki', { ['branch'] = 'dev' }) + + +-- git integration +Plug('tpope/vim-fugitive') +Plug('tpope/vim-rhubarb') +Plug('mhinz/vim-signify') +-- git support for nerdtree +Plug('Xuyuanp/nerdtree-git-plugin') +-- better support for JS +Plug('pangloss/vim-javascript') +-- find, complete, etc. on steroids +-- fast fuzzy finder +Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = function() + vim.fn['fzf#install']() +end }) +Plug('junegunn/fzf.vim') +-- auto detect tab and space handling(rather than setting per project +Plug('tpope/vim-sleuth') + + +-- tools - all languages +-- look for .editorconfig(and merge into vim settings +Plug('editorconfig/editorconfig-vim') +-- auto format all the things +Plug('sbdchd/neoformat') +-- load config(from $CWD/.config/init.vim +Plug('windwp/nvim-projectconfig') + +-- Collection of common configurations for the Nvim LSP client +Plug('neovim/nvim-lspconfig') +-- Add commands to add and manage lsp plugins +Plug('williamboman/nvim-lsp-installer') + +-- Completion framework +-- I found these when updating(my lsp configuration and after using the +-- additional sources for a while, find them super useful for general editing +-- too +-- See hrsh7th's other plugins for more completion sources! +Plug('hrsh7th/nvim-cmp') +-- LSP completion source for nvim-cmp +Plug('hrsh7th/cmp-nvim-lsp') +-- Snippet completion source for nvim-cmp +Plug('hrsh7th/cmp-vsnip') +-- Other useful completion sources +Plug('hrsh7th/cmp-path') +Plug('hrsh7th/cmp-buffer') +-- Snippet engine +Plug('hrsh7th/vim-vsnip') + +-- allows other programs and scripts to hook into NeoVim's language server +-- protocol support; adopted as a pre-requisite for prettier integration +Plug('jose-elias-alvarez/null-ls.nvim') + +-- specific languages, programming(and otherwise + +-- support for the Rust programming(language +Plug('rust-lang/rust.vim') +-- handles Rust configuration for LSP +Plug('mrcjkb/rustaceanvim') + +-- support for jsonnet +Plug('google/vim-jsonnet') + +-- nvm to make JS/TS/Node easier to work with +Plug('marene/nvm.vim') + +vim.call('plug#end') diff --git a/plug.vim b/plug.vim deleted file mode 100644 index 3be7332..0000000 --- a/plug.vim +++ /dev/null @@ -1,107 +0,0 @@ -call plug#begin("~/.config/nvim/plugged") -" I try to keep these to a minimum and to understand what each plugin does and -" adds to my existing set up. I try to capture the value, at least to me, each -" plugin adds. I've tried to logically group them, as well, to spot overlap -" and redundancy. -" -Plug 'tenxsoydev/size-matters.nvim' - - -" informational -" lightweight but sophisticated status line -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -" visualize vim's undo tree -Plug 'mbbill/undotree' -" diagnostics display -Plug 'folke/trouble.nvim' -" icons for Trouble -Plug 'kyazdani42/nvim-web-devicons' - - -" files, folders, projects, etc. -" file and dir browser -Plug 'preservim/nerdtree' -" integrate ripgrep, especially to be able to open matches, hugely useful for -" code aware search -Plug 'jremmen/vim-ripgrep' -" Support for the cd replacement, zoxide -Plug 'nanotee/zoxide.vim' -" taskwarrior -Plug 'xarthurx/taskwarrior.vim' -" Wiki support - my life is in vimwiki -Plug 'vimwiki/vimwiki', { 'branch': 'dev' } - - -" git integration -Plug 'tpope/vim-fugitive' -Plug 'tpope/vim-rhubarb' -Plug 'mhinz/vim-signify' -" git support for nerdtree -Plug 'Xuyuanp/nerdtree-git-plugin' -" better support for JS -Plug 'pangloss/vim-javascript' -" find, complete, etc. on steroids -" fast fuzzy finder -Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } -Plug 'junegunn/fzf.vim' -" auto detect tab and space handling rather than setting per project -Plug 'tpope/vim-sleuth' - - -" tools - all languages -" look for .editorconfig and merge into vim settings -Plug 'editorconfig/editorconfig-vim' -" syntax checking on steroids -Plug 'scrooloose/syntastic' -" auto format all the things -Plug 'sbdchd/neoformat' -" load config from $CWD/.config/init.vim -Plug 'windwp/nvim-projectconfig' - -" Collection of common configurations for the Nvim LSP client -Plug 'neovim/nvim-lspconfig' -" Add commands to add and manage lsp plugins -Plug 'williamboman/nvim-lsp-installer' - -" Completion framework -" I found these when updating my lsp configuration and after using the -" additional sources for a while, find them super useful for general editing -" too -" See hrsh7th's other plugins for more completion sources! -Plug 'hrsh7th/nvim-cmp' -" LSP completion source for nvim-cmp -Plug 'hrsh7th/cmp-nvim-lsp' -" Snippet completion source for nvim-cmp -Plug 'hrsh7th/cmp-vsnip' -" Other useful completion sources -Plug 'hrsh7th/cmp-path' -Plug 'hrsh7th/cmp-buffer' -" Snippet engine -Plug 'hrsh7th/vim-vsnip' - -" allows other programs and scripts to hook into NeoVim's language server -" protocol support; adopted as a pre-requisite for prettier integration -Plug 'jose-elias-alvarez/null-ls.nvim' - -" specific languages, programming and otherwise - -" support for the Rust programming language -Plug 'rust-lang/rust.vim' -" the rest of the rust config came from: https://sharksforarms.dev/posts/neovim-rust/ -" To enable more of the features of rust-analyzer, such as inlay hints and more! -Plug 'simrat39/rust-tools.nvim' - -" support for jsonnet -Plug 'google/vim-jsonnet' - -" groovy syntax and indent -Plug 'vim-scripts/groovy.vim' -Plug 'vim-scripts/groovyindent-unix' - -" nvm to make JS/TS/Node easier to work with -Plug 'marene/nvm.vim' - - -" All of your Plugins must be added before the following line -call plug#end() " required diff --git a/syntastic.vim b/syntastic.vim deleted file mode 100644 index a1530dd..0000000 --- a/syntastic.vim +++ /dev/null @@ -1,11 +0,0 @@ -" configure syntastic, advanced syntax checker, with some reasonable behaviors -" -" always stick detected errors in the location list -let g:syntastic_always_populate_loc_list = 1 -" open but only when errors are detected; default closes when errors are cleared -" but doesn't open the list automatically -let g:syntastic_auto_loc_list = 0 -" check when first opening a file -let g:syntastic_check_on_open = 0 -" don't check on writing and quitting -let g:syntastic_check_on_wq = 0