diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua new file mode 100644 index 0000000..40749d4 --- /dev/null +++ b/dot_config/nvim/init.lua @@ -0,0 +1,13 @@ +-- Safely require files +local function safe_require(module) + local success, loaded_module = pcall(require, module) + if success then + return loaded_module + end + vim.cmd.echo('Error loading ' .. module) +end + +safe_require('core.options') +safe_require('core.keymaps') +safe_require('core.autocommands') +safe_require('core.bootstrap') diff --git a/dot_config/nvim/init.vim b/dot_config/nvim/init.vim deleted file mode 100644 index 22484b1..0000000 --- a/dot_config/nvim/init.vim +++ /dev/null @@ -1,12 +0,0 @@ -set runtimepath^=~/.vim runtimepath+=~/.vim/after -let &packpath = &runtimepath -lua require('plugins') - -" Language providers -let g:python3_host_prog = '~/.pyenv/versions/py3nvim/bin/python' - -" Disable these so they don't show up in :checkhealth -let g:loaded_perl_provider = 0 -let g:loaded_ruby_provider = 0 - -lua require("settings") diff --git a/dot_config/nvim/lua/core/autocommands.lua.tmpl b/dot_config/nvim/lua/core/autocommands.lua.tmpl new file mode 100644 index 0000000..f07fb41 --- /dev/null +++ b/dot_config/nvim/lua/core/autocommands.lua.tmpl @@ -0,0 +1,2 @@ + +-- vim:ft=lua diff --git a/dot_config/nvim/lua/core/bootstrap.lua.tmpl b/dot_config/nvim/lua/core/bootstrap.lua.tmpl new file mode 100644 index 0000000..bf92f4a --- /dev/null +++ b/dot_config/nvim/lua/core/bootstrap.lua.tmpl @@ -0,0 +1,43 @@ +-- Bootstrap Lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +local opts = { + git = { + log = { '--since=3 days ago' }, + timeout = 60, + }, + ui = { custom_keys = { false } }, + install = { colorscheme = { 'tokyonight' } }, + checker = { enabled = true }, + performance = { + rtp = { + disabled_plugins = { + 'gzip', + 'netrwPlugin', + 'tarPlugin', + 'tohtml', + 'tutor', + 'zipPlugin', + 'rplugin', + 'matchparen', + 'matchit', + }, + }, + }, +} + +-- Load the plugins and options +require('lazy').setup('plugins', opts) + +-- vim:ft=lua diff --git a/dot_config/nvim/lua/core/keymaps.lua.tmpl b/dot_config/nvim/lua/core/keymaps.lua.tmpl new file mode 100644 index 0000000..64a08ac --- /dev/null +++ b/dot_config/nvim/lua/core/keymaps.lua.tmpl @@ -0,0 +1,4 @@ +local cmd = vim.cmd +local g = vim.g + +-- vim:ft=lua diff --git a/dot_config/nvim/lua/settings.lua b/dot_config/nvim/lua/core/options.lua.tmpl similarity index 65% rename from dot_config/nvim/lua/settings.lua rename to dot_config/nvim/lua/core/options.lua.tmpl index 3b9a012..f69d3ce 100644 --- a/dot_config/nvim/lua/settings.lua +++ b/dot_config/nvim/lua/core/options.lua.tmpl @@ -1,6 +1,18 @@ -local cmd = vim.cmd +local opt = vim.opt local g = vim.g +-- Language providers +g.python3_host_prog = '~/.pyenv/versions/py3nvim/bin/python' +-- Disable these so they don't show up in :checkhealth +g.loaded_perl_provider = 0 +g.loaded_ruby_provider = 0 + +-- Configure fonts +g.guifont = "Sauce_Code_Pro_ExtraLight_Nerd_Font_Complete:h12" + + +-- TODO: refactor this into Lua +local cmd = vim.cmd cmd([[ set fo=tcqln scs sm tm=200 bs=2 ai bg=dark title set ignorecase nohlsearch number showcmd @@ -16,6 +28,4 @@ cmd([[ set completeopt=menu filetype on ]]) - --- Configure fonts -g.guifont = "Sauce_Code_Pro_ExtraLight_Nerd_Font_Complete:h12" +-- vim:ft=lua diff --git a/dot_config/nvim/lua/plugins.lua.tmpl b/dot_config/nvim/lua/plugins.lua.tmpl deleted file mode 100644 index efa40ba..0000000 --- a/dot_config/nvim/lua/plugins.lua.tmpl +++ /dev/null @@ -1,147 +0,0 @@ --- Bootstrap installing packer -local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) - vim.cmd [[packadd packer.nvim]] - return true - end - return false -end - -local packer_bootstrap = ensure_packer() - - --- Configure packer -return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - -- General plugins - use 'tpope/vim-fugitive' - use 'tpope/vim-surround' - use 'cohama/lexima.vim' - use 'ntpeters/vim-better-whitespace' - use {'nathanaelkane/vim-indent-guides', - config = function() - vim.g.indent_guides_start_level = 2 - vim.cmd([[ - hi IndentGuidesOdd ctermbg=black - hi IndentGuidesEven ctermbg=darkgrey - ]]) - end - } - use 'ConradIrwin/vim-bracketed-paste' - use 'xolox/vim-misc' - use 'xolox/vim-notes' - use 'sheerun/vim-polyglot' - use 'mbbill/undotree' - use 'machakann/vim-highlightedyank' - use 'tpope/vim-commentary' - use 'tpope/vim-speeddating' - use 'AndrewRadev/splitjoin.vim' - use {'dkarter/bullets.vim', - config = function() - vim.g.bullets_enabled_file_types = { - 'markdown', 'text', 'gitcommit', 'scratch' - } - end - } - use 'antoyo/vim-licenses' - use 'folke/todo-comments.nvim' - - -- Lang Server - use {'neoclide/coc.nvim', - requires = {'vim-airline/vim-airline'}, - config = function() - require("coc") - end, - branch = 'release'} - - use {'vim-syntastic/syntastic', - config = function() - require("syntastic") - end - } - - -- User Interface - use 'scrooloose/nerdtree' - use 'ctrlpvim/ctrlp.vim' - use {'vim-airline/vim-airline', - config = function() - vim.g.airline_powerline_fonts = 1 - end - } - use {'lewis6991/gitsigns.nvim', - config = function() - require('gitsigns').setup { - attach_to_untracked = false, - numhl = true, - signcolumn = false - } - end - } - - -- Speed up loading/set custom filetypes - -- See https://github.com/nathom/filetype.nvim#customization for info on - -- setting custom types - use 'nathom/filetype.nvim' - - use 'ryanoasis/vim-devicons' - use 'rhysd/committia.vim' - - -- Skeletons and snippets - use {'pgilad/vim-skeletons', - requires = {'SirVer/ultisnips'}, - config = function() - vim.cmd("let skeletons#autoRegister = 1") - end - } - use {'SirVer/ultisnips', - requires = {'honza/vim-snippets'} - } - - {{- if ne .environment "work" }} - use {'github/copilot.vim'} - {{- end }} - - -- Python - use 'majutsushi/tagbar' - use 'psf/black' - - -- (Java|Type)Script - use 'Quramy/tsuquyomi' - use 'Quramy/vim-js-pretty-template' - use 'leafgarland/typescript-vim' - - -- Dev Ops stuff - use 'digitalrounin/vim-yaml-folds' - use {'hashivim/vim-terraform', - config = function() - vim.cmd([[silent! autocmd! filetypedetect BufRead,BufNewFile *.tf]]) - vim.cmd([[autocmd BufRead,BufNewFile *.hcl set filetype=hcl]]) - vim.cmd([[autocmd BufRead,BufNewFile .terraformrc,terraform.rc set filetype=hcl]]) - vim.cmd([[autocmd BufRead,BufNewFile *.tf,*.tfvars set filetype=terraform]]) - vim.cmd([[autocmd BufRead,BufNewFile *.tfstate,*.tfstate.backup set filetype=json]]) - - vim.g.terraform_fmt_on_save = 1 - vim.g.terraform_align = 1 - end - } - use 'juliosueiras/vim-terraform-completion' - use 'speshak/vim-cfn' - use 'hashicorp/sentinel.vim' - - use 'ynkdir/vim-vimlparser' - use 'syngan/vim-vimlint' - - -- Optimiser - use "lewis6991/impatient.nvim" - - if packer_bootstrap then - require('packer').sync() - end -end) - --- vim:ft=lua diff --git a/dot_config/nvim/lua/plugins/code.lua.tmpl b/dot_config/nvim/lua/plugins/code.lua.tmpl new file mode 100644 index 0000000..888147d --- /dev/null +++ b/dot_config/nvim/lua/plugins/code.lua.tmpl @@ -0,0 +1,58 @@ +-- Programming specific plugins +return { + -- Skeletons and snippets + {'pgilad/vim-skeletons', + dependencies = {'SirVer/ultisnips'}, + config = function(plugin) + vim.cmd("let skeletons#autoRegister = 1") + end + }, + {'SirVer/ultisnips', + dependencies = {'honza/vim-snippets'} + }, + + 'github/copilot.vim', + + -- Python + 'majutsushi/tagbar', + 'psf/black', + + -- (Java|Type)Script + 'Quramy/tsuquyomi', + 'Quramy/vim-js-pretty-template', + 'leafgarland/typescript-vim', + + -- Dev Ops stuff + 'digitalrounin/vim-yaml-folds', + {'hashivim/vim-terraform', + config = function(plugin) + vim.cmd([[silent! autocmd! filetypedetect BufRead,BufNewFile *.tf]]) + vim.cmd([[autocmd BufRead,BufNewFile *.hcl set filetype=hcl]]) + vim.cmd([[autocmd BufRead,BufNewFile .terraformrc,terraform.rc set filetype=hcl]]) + vim.cmd([[autocmd BufRead,BufNewFile *.tf,*.tfvars set filetype=terraform]]) + vim.cmd([[autocmd BufRead,BufNewFile *.tfstate,*.tfstate.backup set filetype=json]]) + + vim.g.terraform_fmt_on_save = 1 + vim.g.terraform_align = 1 + end + }, + 'juliosueiras/vim-terraform-completion', + 'speshak/vim-cfn', + 'hashicorp/sentinel.vim', + + 'ynkdir/vim-vimlparser', + 'syngan/vim-vimlint', + + -- Speed up loading/set custom filetypes + -- See https://github.com/nathom/filetype.nvim#customization for info on + -- setting custom types + 'nathom/filetype.nvim', + + 'ryanoasis/vim-devicons', + 'rhysd/committia.vim', + + -- Optimiser + "lewis6991/impatient.nvim", +} + +-- vim:ft=lua diff --git a/dot_config/nvim/lua/plugins/editor.lua.tmpl b/dot_config/nvim/lua/plugins/editor.lua.tmpl new file mode 100644 index 0000000..74ae0be --- /dev/null +++ b/dot_config/nvim/lua/plugins/editor.lua.tmpl @@ -0,0 +1,224 @@ +-- Plugins for general editor look & feel, not specific to a programming +-- language +return { + -- User interface + 'scrooloose/nerdtree', + 'ctrlpvim/ctrlp.vim', + {'vim-airline/vim-airline', + config = function(plugin) + vim.g.airline_powerline_fonts = 1 + end + }, + -- General plugins + 'tpope/vim-fugitive', + 'tpope/vim-surround', + 'cohama/lexima.vim', + 'ntpeters/vim-better-whitespace', + {'nathanaelkane/vim-indent-guides', + config = function() + vim.g.indent_guides_start_level = 2 + vim.cmd([[ + hi IndentGuidesOdd ctermbg=black + hi IndentGuidesEven ctermbg=darkgrey + ]]) + end + }, + + 'AndrewRadev/splitjoin.vim', + 'ConradIrwin/vim-bracketed-paste', + 'sheerun/vim-polyglot', + 'mbbill/undotree', + 'machakann/vim-highlightedyank', + 'tpope/vim-commentary', + 'tpope/vim-speeddating', + 'antoyo/vim-licenses', + + {'dkarter/bullets.vim', + config = function() + vim.g.bullets_enabled_file_types = { + 'markdown', 'text', 'gitcommit', 'scratch' + } + end + }, + + -- todo-comments.nvim + { + 'folke/todo-comments.nvim', + dependencies = 'nvim-lua/plenary.nvim', + event = { 'BufReadPost', 'BufNewFile' }, + config = true, + keys = { + { + ']t', + function() + return require('todo-comments').jump_next() + end, + desc = 'Jump to next todo comment', + }, + { + '[t', + function() + return require('todo-comments').jump_prev() + end, + desc = 'Jump to previous todo comment', + }, + }, + }, + + -- nvim-autopairs + { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + opts = { + disable_filetype = { 'TelescopePrompt', 'text' }, + disable_in_macro = false, + check_ts = true, + }, + }, + + -- gitsigns.nvim + { + 'lewis6991/gitsigns.nvim', + init = function() + -- load gitsigns only when a git file is opened + vim.api.nvim_create_autocmd({ 'BufRead' }, { + group = vim.api.nvim_create_augroup('GitSignsLazyLoad', { clear = true }), + callback = function() + vim.fn.system('git -C ' .. '"' .. vim.fn.expand('%:p:h') .. '"' .. ' rev-parse') + if vim.v.shell_error == 0 then + vim.api.nvim_del_augroup_by_name('GitSignsLazyLoad') + vim.schedule(function() + require('lazy').load({ plugins = { 'gitsigns.nvim' } }) + end) + end + end, + }) + end, + ft = 'gitcommit', + keys = { + --[[ { + 'gj', + function() + return require('gitsigns').next_hunk() + end, + desc = 'Next hunk', + }, + { + 'gk', + function() + return require('gitsigns').prev_hunk() + end, + desc = 'Previous hunk', + }, ]] + { + 'gB', + function() + return require('gitsigns').blame_line() + end, + desc = 'Open git blame', + }, + { + 'gp', + function() + return require('gitsigns').preview_hunk_inline() + end, + desc = 'Preview the hunk', + }, + { + 'gr', + function() + return require('gitsigns').reset_hunk() + end, + mode = { 'n', 'v' }, + desc = 'Reset the hunk', + }, + { + 'gR', + function() + return require('gitsigns').reset_buffer() + end, + desc = 'Reset the buffer', + }, + { + 'gs', + function() + return require('gitsigns').stage_hunk() + end, + mode = { 'n', 'v' }, + desc = 'Stage the hunk', + }, + { + 'gS', + function() + return require('gitsigns').stage_buffer() + end, + desc = 'Stage the buffer', + }, + { + 'gu', + function() + return require('gitsigns').undo_stage_hunk() + end, + desc = 'Unstage the hunk', + }, + { + 'gd', + function() + return require('gitsigns').diffthis() + end, + desc = 'Open a diff', + }, + { + 'gq', + function() + return require('gitsigns').setqflist() + end, + desc = 'Open quickfix list with hunks', + }, + { + 'gl', + function() + return require('gitsigns').setloclist() + end, + desc = 'Open location list with hunks', + }, + { + 'gL', + function() + return require('gitsigns').toggle_current_line_blame() + end, + desc = 'Toggle line blame', + }, + { + ']g', + function() + return require('gitsigns').next_hunk() + end, + desc = 'Next hunk', + }, + { + '[g', + function() + return require('gitsigns').prev_hunk() + end, + desc = 'Previous hunk', + }, + }, + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '-' }, + topdelete = { text = '-' }, + changedelete = { text = '~' }, + }, + attach_to_untracked = true, + numhl = true, + -- word_diff = true, + }, + }, + + +} + +-- vim:ft=lua diff --git a/dot_config/nvim/lua/plugins/lsp.lua.tmpl b/dot_config/nvim/lua/plugins/lsp.lua.tmpl new file mode 100644 index 0000000..5f8c5c8 --- /dev/null +++ b/dot_config/nvim/lua/plugins/lsp.lua.tmpl @@ -0,0 +1,31 @@ +return { + {'neoclide/coc.nvim', + dependencies = {'vim-airline/vim-airline'}, + config = function(plugin) + require("coc") + end, + branch = 'release' + }, + + {'vim-syntastic/syntastic', + config = function(plugin) + -- Status line + vim.g.statusline = "%#warningmsg#" .. "%{SyntasticStatuslineFlag()}" .. "%*" + + vim.g.syntastic_always_populate_loc_list = 1 + vim.g.syntastic_auto_loc_list = 1 + vim.g.syntastic_check_on_open = 0 + vim.g.syntastic_check_on_wq = 0 + vim.g.syntastic_aggregate_errors = 1 + + -- Checker configs + vim.g.syntastic_python_checkers = {'flake8', 'mypy'} + vim.g.syntastic_yaml_checkers = {'yamllint'} + vim.g.syntastic_cloudformation_checkers = {'cfn_lint'} + vim.g.syntastic_javascript_checkers = {'eslint'} + end + }, + +} + +-- vim:ft=lua diff --git a/dot_config/nvim/lua/syntastic.lua b/dot_config/nvim/lua/syntastic.lua deleted file mode 100644 index 50ebe02..0000000 --- a/dot_config/nvim/lua/syntastic.lua +++ /dev/null @@ -1,20 +0,0 @@ -local g = vim.g - --- Status line -vim.cmd([[ - set statusline+=%#warningmsg# - set statusline+=%{SyntasticStatuslineFlag()} - set statusline+=%* -]]) - -g.syntastic_always_populate_loc_list = 1 -g.syntastic_auto_loc_list = 1 -g.syntastic_check_on_open = 0 -g.syntastic_check_on_wq = 0 -g.syntastic_aggregate_errors = 1 - --- Checker configs -g.syntastic_python_checkers = {'flake8', 'mypy'} -g.syntastic_yaml_checkers = {'yamllint'} -g.syntastic_cloudformation_checkers = {'cfn_lint'} -g.syntastic_javascript_checkers = {'eslint'} diff --git a/dot_config/nvim/lua/utils.lua b/dot_config/nvim/lua/utils.lua index f735d11..9dcf79a 100644 --- a/dot_config/nvim/lua/utils.lua +++ b/dot_config/nvim/lua/utils.lua @@ -54,10 +54,6 @@ M.define_augroups({ -- will cause split windows to be resized evenly if main window is resized { "VimResized", "*", "wincmd =" }, }, - _packer_compile = { - -- will cause split windows to be resized evenly if main window is resized - { "BufWritePost", "plugins.lua", "PackerCompile" }, - }, _qf = { -- will cause split windows to be resized evenly if main window is resized { "FileType", "qf", "set nobuflisted" }, diff --git a/dot_gitconfig.tmpl b/dot_gitconfig.tmpl index 7e866ee..fd820d6 100644 --- a/dot_gitconfig.tmpl +++ b/dot_gitconfig.tmpl @@ -68,7 +68,7 @@ check = true [diff "spaceman-diff"] - command = {{ findExecutable "spaceman-diff" list("/usr/local/bin/" "/opt/homebrew/bin") }} + command = {{ findExecutable "spaceman-diff" (list "/usr/local/bin/" "/opt/homebrew/bin") }} indentHeuristic = on # diff-so-fancy recommended defaults diff --git a/dot_ssh/config b/dot_ssh/config index 3e904e0..2aeefd7 100644 --- a/dot_ssh/config +++ b/dot_ssh/config @@ -8,6 +8,10 @@ HashKnownHosts yes Include conf.d/* +Host github.com + Hostname ssh.github.com + Port 443 + User git # SSH over Session Manager host i-* mi-* diff --git a/run_once_clean_packer.sh b/run_once_clean_packer.sh new file mode 100755 index 0000000..aa8c4f3 --- /dev/null +++ b/run_once_clean_packer.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Script to clean up remnants of packer.nvim to allow a clean transition to lazy.nvim + +rm -f ~/.config/nvim/plugin/packer_compiled.lua +rm -rf ~/.local/share/nvim/site/pack/packer diff --git a/run_once_install-nvim-pyenv.sh b/run_once_install-nvim-pyenv.sh old mode 100644 new mode 100755 index d912c39..5e97890 --- a/run_once_install-nvim-pyenv.sh +++ b/run_once_install-nvim-pyenv.sh @@ -1,11 +1,19 @@ -#!/bin/bash +#!/bin/bash -e VER=3.10.5 VENV_NAME=py3nvim # Load pyenv +eval "$(pyenv init -)" eval "$(pyenv virtualenv-init - bash)" pyenv install --skip-existing ${VER} -pyenv virtualenv ${VER} ${VENV_NAME} + +# Create the venv if it doesn't exist +if ! pyenv virtualenvs | grep -q ${VENV_NAME} +then + pyenv virtualenv ${VER} ${VENV_NAME} +fi + +# Activate the venv and install the required pip modules pyenv activate ${VENV_NAME} python3 -m pip install pynvim diff --git a/run_once_vim.sh b/run_once_vim.sh deleted file mode 100644 index dc3cc14..0000000 --- a/run_once_vim.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# Install packer & plugins -nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'