From d134dd7d77ad55442bf9b5e4b62361e9fcf3e198 Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Fri, 20 May 2022 15:59:29 -0600 Subject: Getting this puppy cooking again --- init.lua | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/init.lua b/init.lua index fd6640f..59efa86 100644 --- a/init.lua +++ b/init.lua @@ -51,6 +51,10 @@ vim.o.splitright = true vim.o.splitbelow = true -- set spelling language vim.o.spelllang = "en_ca" +-- Allow hidden buffers, no complain about saved work when switching +vim.o.hidden = true +-- Ask confirm on exit instead of error +vim.o.confirm = true local highlights = { "Search ctermfg=166", @@ -84,11 +88,6 @@ vim.cmd [[ command! MakeTagsPython !ctags --exclude=venv --exclude=.venv --languages=python --python-kinds=-i -R . ]] --- When using tab, enter will accept the current selection and close the window --- instead of inserting a newline -vim.cmd [[ -inoremap pumvisible() ? "\" : "\" -]] -- Keymaps --noh gets rid of highlighted search results @@ -125,6 +124,7 @@ vim.api.nvim_set_keymap('n', '', 'fT', { noremap = true }) vim.api.nvim_set_keymap('n', '', 'vT', { noremap = true }) vim.api.nvim_set_keymap('n', '', 'vT', { noremap = true }) vim.api.nvim_set_keymap('n', '', 'w', { noremap = true }) +vim.api.nvim_set_keymap('n', '', 'wa', { noremap = true }) vim.api.nvim_set_keymap('n', 'ee', 'e!', { noremap = true }) vim.api.nvim_set_keymap('n', ' k', [[(v:count > 1 ? "m'" . v:count : '') . 'k']], { noremap = true }) vim.api.nvim_set_keymap('n', ' j', [[(v:count > 1 ? "m'" . v:count : '') . 'j']], { noremap = true }) @@ -242,7 +242,7 @@ return require('packer').startup(function() -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches -- local servers = { 'pyls', 'rust_analyzer', 'tsserver' } - local servers = { 'pyright', 'bashls' } + local servers = { 'jedi_language_server', 'bashls', 'terraformls' } -- Add additional capabilities supported by nvim-cmp local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) @@ -266,7 +266,7 @@ return require('packer').startup(function() [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), + [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, @@ -294,6 +294,7 @@ return require('packer').startup(function() end, } use 'nvim-treesitter/playground' + use 'nvim-lua/completion-nvim' use 'tpope/vim-commentary' use 'tpope/vim-surround' use 'tpope/vim-repeat' @@ -316,13 +317,27 @@ return require('packer').startup(function() end } use { - 'tpope/vim-fugitive', + 'Thornycrackers-Forks/vim-fugitive', config = function() vim.api.nvim_set_keymap('n', 'du', 'diffupdate', { noremap = true }) vim.api.nvim_set_keymap('n', 'dd', 'diffget', { noremap = true }) vim.api.nvim_set_keymap('n', 'df', 'diffput', { noremap = true }) - vim.api.nvim_set_keymap('n', 'gs', 'Git', { noremap = true }) + vim.api.nvim_set_keymap('n', 'dc', ']c', { noremap = true }) + vim.api.nvim_set_keymap('n', 'de', '[c', { noremap = true }) + -- vim.api.nvim_set_keymap('n', 'gs', 'Git', { noremap = true }) + vim.cmd([[ + function! ToggleGStatus() + if buflisted(bufname('.git/index')) + bd .git/index + else + G + res 15 + endif + endfunction + nnoremap gs :call ToggleGStatus() + ]]) vim.api.nvim_set_keymap('n', 'gb', 'Git blame', { noremap = true }) + vim.api.nvim_set_keymap('n', 'gd', 'Gdiffsplit', { noremap = true }) end } @@ -376,11 +391,16 @@ return require('packer').startup(function() sh = { "shellcheck", }, python = { "flake8" }, dockerfile = { "hadolint" }, + terraform = { "terraform_ls" }, } vim.g.ale_fixers = { sh = { "shfmt", }, python = { "isort", "black" }, + terraform = { "terraform" }, } + vim.cmd([[ + autocmd BufRead *.py :ALEFix + ]]) end } use 'junegunn/goyo.vim' @@ -392,19 +412,21 @@ return require('packer').startup(function() } use 'hashivim/vim-terraform' use { - 'jremmen/vim-ripgrep', + 'mileszs/ack.vim', config = function() vim.cmd([[ - nnoremap / :call RgSearch() - noremap ea :Rg - function! RgSearch() + nnoremap / :call AckSearch() + function! AckSearch() call inputsave() let term = input('Search: ') call inputrestore() if !empty(term) - execute "Rg " . term + execute "Ack! " . term endif endfunction + " Setting better default settings + let g:ackprg = + \ "ack -s -H --nocolor --nogroup --column --ignore-dir=.venv/ --ignore-dir=.vimcache/ --ignore-dir=migrations/ --ignore-dir=.mypy_cache/ --ignore-file=is:tags --nojs --nocss --nosass" ]]) end } -- cgit v1.2.3