Compare commits

...

2 commits

18 changed files with 304 additions and 107 deletions

View file

@ -1,3 +0,0 @@
{
"diagnostic.displayByAle": true
}

View file

@ -0,0 +1,4 @@
require('plugins')
require('settings')
require('mappings')
require('autocmd')

View file

@ -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 <Leader><Leader>
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 <Leader>
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 <C-p> :FZF <CR>
map <F2> :NERDTreeToggle <CR>
map <F3> :TagbarToggle <CR>

View file

@ -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()]]

View file

@ -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("", "<leader>ff", "<cmd>lua require('telescope.builtin').find_files()<cr>")
M.map("", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>")
M.map("", "<leader>fb", "<cmd>lua require('telescope.builtin').buffers()<cr>")
M.map("", "<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>")
M.map("", "<leader>fb", "<cmd>lua require('telescope.builtin').file_browser()<cr>")
-- easymotion
M.map("", "<leader><leader>j", "<cmd>lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.AFTER_CURSOR})<cr>")
M.map("", "<leader><leader>k", "<cmd>lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.BEFORE_CURSOR})<cr>")
M.map("", "<leader><leader>l", "<cmd>lua require('hop').hint_words({direction = require('hop.hint').HintDirection.AFTER_CURSOR, current_line_only = true})<cr>")
M.map("", "<leader><leader>h", "<cmd>lua require('hop').hint_words({direction = require('hop.hint').HintDirection.BEFORE_CURSOR, current_line_only = true})<cr>")
api.nvim_command(":command Bd lua MiniBufremove.delete()")
api.nvim_command(":command FixWhitespace lua MiniTrailspace.trim()")
return M

View file

@ -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 = {
['<tab>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = 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' }
})
})

View file

@ -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,
},
}

View file

@ -0,0 +1 @@
require("hop").setup()

View file

@ -0,0 +1,6 @@
require("indent_blankline").setup {
show_current_context = true,
show_current_context_start = true,
}
vim.g.indent_blankline_use_treesitter = true

View file

@ -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 <c-x><c-o>
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', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
--buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'gd', "<cmd>lua require('telescope.builtin').lsp_definitions()<CR>", opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
--buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', 'gi', "<cmd>lua require('telescope.builtin').lsp_implementations()<CR>", opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
--buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>D', "<cmd>lua require('telescope.builtin').lsp_type_definitions()<CR>", opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
--buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', '<space>ca', "<cmd>lua require('telescope.builtin').lsp_code_actions()<CR>", opts)
--buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('', 'gr', "<cmd>lua require('telescope.builtin').lsp_references()<CR>", opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', 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

View file

@ -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()

View file

@ -0,0 +1,3 @@
local statusline = require("statusline")
statusline.tableline = false

View file

@ -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,
},
}

View file

@ -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")

View file

@ -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')

View file

@ -1 +0,0 @@
../.config/nvim/coc-settings.json

View file

@ -1 +0,0 @@
.config/nvim/init.vim

View file

@ -61,6 +61,7 @@ plugins=(
fzf
git
git-extras
gpg-agent
golang
grunt
helm