diff --git a/home/.config/nvim/coc-settings.json b/home/.config/nvim/coc-settings.json deleted file mode 100644 index eefe671..0000000 --- a/home/.config/nvim/coc-settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "diagnostic.displayByAle": true -} diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua new file mode 100644 index 0000000..bbccb97 --- /dev/null +++ b/home/.config/nvim/init.lua @@ -0,0 +1,4 @@ +require('plugins') +require('settings') +require('mappings') +require('autocmd') diff --git a/home/.config/nvim/init.vim b/home/.config/nvim/init.vim deleted file mode 100644 index a93363f..0000000 --- a/home/.config/nvim/init.vim +++ /dev/null @@ -1,102 +0,0 @@ -scriptencoding utf-8 - -function GoPostUpdate() - :GoInstallBinaries - :GoUpdateBinaries -endfunction - -" automatically install vim-plug if it doesn't exist -let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' -if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -" disable ALE LSP since we have coc.nvim -let g:ale_disable_lsp = 1 - -call plug#begin($HOME.'/.nvim/plugged') - -Plug 'morhetz/gruvbox' " color scheme - -Plug 'airblade/vim-gitgutter' " show file changes for git VCS -Plug 'bronson/vim-trailing-whitespace' " per the name, remove trailing whitespace -Plug 'easymotion/vim-easymotion' " easy code navigation with -Plug 'editorconfig/editorconfig-vim' " EditorConfig support -Plug 'fatih/vim-go', { 'do': ':exec GoPostUpdate()' } " THE Go plugin -Plug 'junegunn/fzf', { 'do': { -> fzf#install } } " fast file name search -Plug 'majutsushi/tagbar' " class & variable lister -Plug 'mg979/vim-visual-multi', { 'branch': 'master' } " multi cursor support -Plug 'mhinz/vim-signify' " show file changes for pretty much any VCS -Plug 'mileszs/ack.vim' " easy code searching -Plug 'moll/vim-bbye' " Bdelete a buffer without removing the split -Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': { -> coc#util#install() }} " ezpz LSP support -Plug 'scrooloose/nerdcommenter' " perform quick comments with -Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " shows a directory view -Plug 'sheerun/vim-polyglot' " highlighting & indent for languages -Plug 'tpope/vim-fugitive' " awesome git support -Plug 'tpope/vim-sensible' " some obviously sane default config changes -Plug 'tpope/vim-surround' " easy surrounding modifier -Plug 'vim-airline/vim-airline' " nice lightweight status line -Plug 'vim-airline/vim-airline-themes' " themes for vim-airline -Plug 'w0rp/ale' " async linting engine - -call plug#end() - -" speed improvements for fzf -if executable('ag') - let $FZF_DEFAULT_COMMAND = 'ag --skip-vcs-ignores --nocolor -g "" -l' - let g:ackprg = 'ag --vimgrep' -endif - -let g:gruvbox_contrast_dark = 'hard' - -set background=dark " make sure dark mode is used -autocmd vimenter * ++nested colorscheme gruvbox " Color scheme -set laststatus=2 " Enable airline -let g:airline_theme = 'gruvbox' " Airline color scheme -let g:airline#extensions#tabline#enabled = 1 " Enable tab list in airline -let g:airline#extensions#tabline#left_sep = ' ' -let g:airline#extensions#tabline#left_alt_sep = '|' -let g:airline#extensions#whitespace#mixed_indent_algo = 1 -let g:airline_powerline_fonts = 1 -set list " Show tabs -set listchars=tab:\|\ ,trail:ยท " Show whitestape by using the pipe symbol and dots -set tabstop=4 " Tabs look like 4 spaces -set softtabstop=0 noexpandtab " Tabs look like 4 spaces -set shiftwidth=4 " Tabs look like 4 spaces -set number " Show line numbers -set cursorline " Highlight entire line that cursor is on -let g:tagbar_left = 1 " Make tagbar appear on the left -autocmd CompleteDone * pclose " Remove scratchpad after selection -set mouse= " Disable mouse -set lazyredraw " Make large files bearable -set regexpengine=1 " Make searching large files bearable - -" make J work with docblocks and such (if possible) -if v:version > 703 || v:version == 703 && has('patch541') - set formatoptions+=j -endif - -" Enable syntax-highlighting for Go -let g:go_highlight_functions = 1 -let g:go_highlight_methods = 1 -let g:go_highlight_fields = 1 -let g:go_highlight_types = 1 -let g:go_highlight_operators = 1 -let g:go_highlight_build_constraints = 1 - -" Use goimports instead of gofmt for import paths -let g:go_fmt_command = "goimports" - -" Use golangci-lint instead of gometalinter for linting -let g:go_metalinter_command = "golangci-lint" - -" Lint Go on save -let g:go_metalinter_autosave = 1 - -" Key mappings -" use FZF for control p -map :FZF -map :NERDTreeToggle -map :TagbarToggle diff --git a/home/.config/nvim/lua/autocmd.lua b/home/.config/nvim/lua/autocmd.lua new file mode 100644 index 0000000..539ee92 --- /dev/null +++ b/home/.config/nvim/lua/autocmd.lua @@ -0,0 +1,7 @@ +local api = vim.api + +-- set the theme to gruvbox +api.nvim_command("autocmd vimenter * ++nested colorscheme gruvbox") + +-- run nvim-lightbulb for all files +vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()]] diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..ac8e4c3 --- /dev/null +++ b/home/.config/nvim/lua/mappings.lua @@ -0,0 +1,26 @@ +local api = vim.api + +local M = {} +function M.map(mode, keydef, command, opts) + local options = {noremap = true} + if opts then options = vim.tbl_extend("force", options, opts) end + api.nvim_set_keymap(mode, keydef, command, options) +end + +-- fzf searching +M.map("", "ff", "lua require('telescope.builtin').find_files()") +M.map("", "fg", "lua require('telescope.builtin').live_grep()") +M.map("", "fb", "lua require('telescope.builtin').buffers()") +M.map("", "fh", "lua require('telescope.builtin').help_tags()") +M.map("", "fb", "lua require('telescope.builtin').file_browser()") + +-- easymotion +M.map("", "j", "lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.AFTER_CURSOR})") +M.map("", "k", "lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.BEFORE_CURSOR})") +M.map("", "l", "lua require('hop').hint_words({direction = require('hop.hint').HintDirection.AFTER_CURSOR, current_line_only = true})") +M.map("", "h", "lua require('hop').hint_words({direction = require('hop.hint').HintDirection.BEFORE_CURSOR, current_line_only = true})") + +api.nvim_command(":command Bd lua MiniBufremove.delete()") +api.nvim_command(":command FixWhitespace lua MiniTrailspace.trim()") + +return M diff --git a/home/.config/nvim/lua/plugins/config/cmp.lua b/home/.config/nvim/lua/plugins/config/cmp.lua new file mode 100644 index 0000000..87a1553 --- /dev/null +++ b/home/.config/nvim/lua/plugins/config/cmp.lua @@ -0,0 +1,46 @@ +local cmp = require'cmp' + +cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }) + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, + }) +}) + +-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) diff --git a/home/.config/nvim/lua/plugins/config/gitsigns.lua b/home/.config/nvim/lua/plugins/config/gitsigns.lua new file mode 100644 index 0000000..c0c7c9a --- /dev/null +++ b/home/.config/nvim/lua/plugins/config/gitsigns.lua @@ -0,0 +1,8 @@ +require("gitsigns").setup { + current_line_blame = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "right_align", + delay = 0, + }, +} diff --git a/home/.config/nvim/lua/plugins/config/hop.lua b/home/.config/nvim/lua/plugins/config/hop.lua new file mode 100644 index 0000000..e82f65c --- /dev/null +++ b/home/.config/nvim/lua/plugins/config/hop.lua @@ -0,0 +1 @@ +require("hop").setup() diff --git a/home/.config/nvim/lua/plugins/config/indentblankline.lua b/home/.config/nvim/lua/plugins/config/indentblankline.lua new file mode 100644 index 0000000..973ed01 --- /dev/null +++ b/home/.config/nvim/lua/plugins/config/indentblankline.lua @@ -0,0 +1,6 @@ +require("indent_blankline").setup { + show_current_context = true, + show_current_context_start = true, +} + +vim.g.indent_blankline_use_treesitter = true diff --git a/home/.config/nvim/lua/plugins/config/lspinstall.lua b/home/.config/nvim/lua/plugins/config/lspinstall.lua new file mode 100644 index 0000000..8a90683 --- /dev/null +++ b/home/.config/nvim/lua/plugins/config/lspinstall.lua @@ -0,0 +1,99 @@ +local lsp_installer_servers = require'nvim-lsp-installer.servers' +local cmp_lsp = require('cmp_nvim_lsp') +local null_ls = require("null-ls") + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + -- Enable completion triggered by + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + + -- See `:help vim.lsp.*` for documentation on any of the below functions + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + --buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'gd', "lua require('telescope.builtin').lsp_definitions()", opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + --buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', 'gi', "lua require('telescope.builtin').lsp_implementations()", opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + --buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'D', "lua require('telescope.builtin').lsp_type_definitions()", opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + --buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + buf_set_keymap('n', 'ca', "lua require('telescope.builtin').lsp_code_actions()", opts) + --buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('', 'gr', "lua require('telescope.builtin').lsp_references()", opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) + + local sources = { + null_ls.builtins.formatting.gofumpt, + null_ls.builtins.formatting.goimports, + null_ls.builtins.formatting.isort, + null_ls.builtins.formatting.black.with({ + extra_args = { "-l 120" } + }), + null_ls.builtins.diagnostics.flake8.with({ + extra_args = { "--max-line-length=120" } + }), + null_ls.builtins.formatting.rubocop, + null_ls.builtins.formatting.rustfmt, + null_ls.builtins.diagnostics.shellcheck, + null_ls.builtins.formatting.stylua, + } + + null_ls.config({sources = sources }) +end + +local lspServers = { + bashls = {}, + cssls = {}, + dockerls = {}, + eslint = {}, + gopls = { + cmd = {"gopls", "serve"}, + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + }, + }, + }, + html = {}, + jsonls = {}, + sumneko_lua = {}, + jedi_language_server = {}, + rust_analyzer = {}, + terraformls = {}, + tsserver = {}, + lemminx = {}, + yamlls = {} +} + +for lspServer, opts in pairs(lspServers) do + local server_available, requested_server = lsp_installer_servers.get_server(lspServer) + if server_available then + opts["capabilities"] = cmp_lsp.update_capabilities(vim.lsp.protocol.make_client_capabilities()) + opts["on_attach"] = on_attach + requested_server:on_ready(function () + requested_server:setup(opts) + end) + if not requested_server:is_installed() then + requested_server:install() + end + end +end diff --git a/home/.config/nvim/lua/plugins/config/mini.lua b/home/.config/nvim/lua/plugins/config/mini.lua new file mode 100644 index 0000000..bb28b65 --- /dev/null +++ b/home/.config/nvim/lua/plugins/config/mini.lua @@ -0,0 +1,6 @@ +require("mini.bufremove").setup() +require("mini.comment").setup() +require("mini.cursorword").setup() +require("mini.surround").setup() +require("mini.trailspace").setup() +require("mini.tabline").setup() diff --git a/home/.config/nvim/lua/plugins/config/statusline.lua b/home/.config/nvim/lua/plugins/config/statusline.lua new file mode 100644 index 0000000..372e4ce --- /dev/null +++ b/home/.config/nvim/lua/plugins/config/statusline.lua @@ -0,0 +1,3 @@ +local statusline = require("statusline") + +statusline.tableline = false diff --git a/home/.config/nvim/lua/plugins/config/treesitter.lua b/home/.config/nvim/lua/plugins/config/treesitter.lua new file mode 100644 index 0000000..5a91042 --- /dev/null +++ b/home/.config/nvim/lua/plugins/config/treesitter.lua @@ -0,0 +1,14 @@ +require'nvim-treesitter.configs'.setup { + ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages + sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) + ignore_install = {}, -- List of parsers to ignore installing + highlight = { + enable = true, -- false will disable the whole extension + disable = {}, -- list of language that will be disabled + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} diff --git a/home/.config/nvim/lua/plugins/init.lua b/home/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..33e872d --- /dev/null +++ b/home/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,55 @@ +local fn = vim.fn + +local install_path = fn.stdpath('data') .. '/site/pack/paqs/start/paq-nvim' + +if fn.empty(fn.glob(install_path)) > 0 then + fn.system({'git', 'clone', '--depth=1', 'https://github.com/savq/paq-nvim.git', install_path}) +end + +require "paq" { + "savq/pag-nvim"; -- let Paq manage itself + + "morhetz/gruvbox"; -- gruvbox theme + + "beauwilliams/statusline.lua"; -- status & tab line + + "lewis6991/gitsigns.nvim"; -- git gutter + "nvim-lua/plenary.nvim"; -- dependency of lewis6991/gitsigns.nvim, nvim-telescope/telescope.nvim + + "nvim-telescope/telescope.nvim"; -- fzf searching + + "phaazon/hop.nvim"; -- easymotion navigation + + "echasnovski/mini.nvim"; -- bunch of good small plugins: whitespace, buffer layout, commenting, surround, tabline, etc + + {"nvim-treesitter/nvim-treesitter", run=TSUpdate}; -- nice and quick syntax tree + + "lukas-reineke/indent-blankline.nvim"; -- pretty visualization of line indents + + "kosayoda/nvim-lightbulb"; -- shows a light bulb like vs code for code actions + "nvim-lua/lsp-status.nvim"; -- nice statusline components for LSP servers + + "rhysd/vim-grammarous"; -- grammar checking + + -- LSP Server + "neovim/nvim-lspconfig"; + "williamboman/nvim-lsp-installer"; + "jose-elias-alvarez/null-ls.nvim"; + + -- autocomplete with nvim-cmp + "hrsh7th/cmp-nvim-lsp"; + "hrsh7th/cmp-buffer"; + "hrsh7th/cmp-path"; + "hrsh7th/cmp-cmdline"; + "hrsh7th/nvim-cmp"; + "L3MON4D3/LuaSnip"; + "saadparwaiz1/cmp_luasnip"; +} + +require("plugins.config.cmp") +require("plugins.config.gitsigns") +require("plugins.config.hop") +require("plugins.config.indentblankline") +require("plugins.config.mini") +require("plugins.config.treesitter") +require("plugins.config.lspinstall") diff --git a/home/.config/nvim/lua/settings.lua b/home/.config/nvim/lua/settings.lua new file mode 100644 index 0000000..1d0e3ec --- /dev/null +++ b/home/.config/nvim/lua/settings.lua @@ -0,0 +1,28 @@ +local g = vim.g +local opt = vim.opt +local cmd = vim.cmd + +-- color theme +-- gruvbox is used via the autocmd require +g.gruvbox_contrast_dark = "hard" -- hard contrast mode for gruvobx +opt.background = "dark" -- make sure dark mode is used + + +opt.mouse = 'c' -- disable mouse +opt.number = true -- show line numbers +-- opt.cursorline = true -- highlight the line that the cursor is on +opt.laststatus = 2 -- always show the status line +opt.autoindent = true -- turn on autoindent +opt.smarttab = true -- turn on smart tabs +opt.incsearch = true -- turn on incremental search +opt.ruler = true -- show ruler on page +opt.lazyredraw = true -- make large files bearable +opt.regexpengine = 1 -- make searching large files bearable + +-- tabs look like 4 spaces +opt.expandtab = true +opt.tabstop = 4 +opt.shiftwidth = 4 +opt.softtabstop = 4 + +cmd('filetype plugin indent on') diff --git a/home/.zshrc b/home/.zshrc index 690a08b..38d8e57 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -61,6 +61,7 @@ plugins=( fzf git git-extras + gpg-agent golang grunt helm