Last active
July 17, 2022 19:58
-
-
Save jmg-duarte/717ddae1b5a45f90f57d5f692c9229e9 to your computer and use it in GitHub Desktop.
Deprecated in favor of https://github.com/jmg-duarte/nvim-config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- vim-plug | |
local Plug = vim.fn['plug#'] | |
vim.call('plug#begin', '~/.config/nvim/plugged') | |
-- plenary provides utility functions for other plugins | |
-- think of it as a neovim plugin standard library | |
Plug('nvim-lua/plenary.nvim') | |
-- fuzzy finder file browser | |
Plug('nvim-telescope/telescope.nvim') | |
-- while neovim has builtin lsp support | |
-- coc just makes everything easier to use | |
Plug('neoclide/coc.nvim', {branch='release'}) | |
-- treesitter provides decent syntax highlighting | |
Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'}) | |
-- fuzzy finder (used by fugitive) | |
Plug('junegunn/fzf') | |
Plug('junegunn/fzf.vim') | |
-- status line | |
Plug('itchyny/lightline.vim') | |
Plug('maximbaz/lightline-ale') | |
-- rust support (even though i dont know how helpful this one is | |
Plug('rust-lang/rust.vim') | |
-- syntax checking hacks | |
Plug('dense-analysis/ale') | |
-- Git | |
Plug('tpope/vim-fugitive') | |
Plug('mhinz/vim-signify') | |
-- surround things | |
Plug('machakann/vim-sandwich') | |
-- comment things | |
Plug('tpope/vim-commentary') | |
-- formatter | |
Plug('sbdchd/neoformat') | |
-- themes | |
-- Plug('altercation/vim-colors-solarized') | |
Plug('sainnhe/gruvbox-material') | |
vim.call('plug#end') | |
-- force vim to use utf-8 as file encoding | |
vim.opt.fileencoding = "utf-8" | |
vim.opt.number = true | |
vim.opt.relativenumber = true | |
vim.opt.confirm = true -- confirm exiting | |
vim.opt.hlsearch = true | |
vim.opt.tabstop = 4 | |
vim.opt.softtabstop = 4 | |
vim.opt.expandtab = true | |
vim.opt.autoindent = true | |
vim.opt.shiftwidth = 4 | |
vim.opt.wildmode = "longest,list" | |
vim.opt.cc = "88" | |
vim.opt.cursorline = true | |
vim.opt.mouse = "a" | |
-- default (4000ms) sucks | |
vim.opt.updatetime = 100 | |
vim.opt.signcolumn = 'yes' | |
vim.opt.shortmess[#vim.opt.shortmess+1] = 'c' | |
-- make the default copy/paste buffer the system clipboard | |
vim.opt.clipboard = "unnamedplus" | |
-- render whitespace | |
vim.opt.listchars = 'tab:▷ ,trail:·,extends:◣,precedes:◢,nbsp:○' | |
vim.opt.list = true | |
-- Add highlight on yank | |
vim.cmd [[ | |
augroup YankHighlight | |
autocmd! | |
autocmd TextYankPost * silent! lua vim.highlight.on_yank() | |
augroup end | |
]] | |
-- syntax coloring | |
vim.cmd('syntax enable') | |
vim.opt.background = "dark" | |
vim.cmd('filetype plugin indent on') | |
if vim.opt.termguicolors then | |
vim.opt.termguicolors = true | |
end | |
vim.g.gruvbox_material_background = 'hard' | |
vim.g.gruvbox_material_better_performance = 1 | |
vim.g.gruvbox_material_foreground = 'original' | |
vim.g.gruvbox_material_enable_italic = 1 | |
vim.g.gruvbox_material_ui_contrast = 'high' | |
vim.g.gruvbox_material_statusline_style = 'original' | |
vim.cmd('colorscheme gruvbox-material') | |
-- rust-analyzed things | |
vim.g.rustfmt_autosave = 1 | |
vim.g.rustfmt_emit_files = 1 | |
vim.g.rustfmt_fail_silently = 0 | |
-- disable some Ale LSP in favor of Coc | |
vim.g.ale_disable_lsp = true | |
vim.g.ale_sign_column_always = true | |
-- always showtabline | |
vim.opt.showtabline = 2 | |
-- autocmd to set ocaml indent to 2 | |
vim.api.nvim_exec([[autocmd FileType ocaml setlocal shiftwidth=2 softtabstop=2 expandtab]], false) | |
-- LightlineFilename | |
-- https://github.com/itchyny/lightline.vim/issues/293 | |
vim.api.nvim_exec([[ | |
function! LightlineFilename() | |
let root = fnamemodify(get(b:, 'git_dir'), ':h') | |
let path = expand('%:p') | |
if path[:len(root)-1] ==# root | |
return path[len(root)+1:] | |
endif | |
return expand('%') | |
endfunction | |
]], false) | |
-- lightline config | |
vim.g.lightline = { | |
colorscheme = 'gruvbox_material'; | |
active = { | |
left = { | |
{'mode', 'paste'}, | |
{'gitbranch', 'readonly', 'gitfilename', 'modified'} | |
}; | |
right = {{ | |
'linter_checking', | |
'linter_infos', | |
'linter_warnings', | |
'linter_errors', | |
'linter_ok' | |
}, {'lineinfo'}, {'percent'}, {'fileformat', 'fileencoding', 'filetype' }} | |
}; | |
tabline = { | |
left = { | |
{'tabs'} | |
}; | |
right = { | |
{'close'} | |
}; | |
}; | |
tab = { | |
active = {'tabnum', 'filename', 'modified'}; | |
inactive = {'tabnum', 'filename', 'modified'}; | |
}; | |
component_function = { | |
gitbranch = 'FugitiveHead'; -- requires tpope/vim-fugitive | |
gitfilename = 'LightlineFilename'; -- requires tpope/vim-fugitive | |
}; | |
component_expand = { | |
linter_checking = 'lightline#ale#checking'; | |
linter_infos = 'lightline#ale#infos'; | |
linter_warnings = 'lightline#ale#warnings'; | |
linter_errors = 'lightline#ale#errors'; | |
linter_ok = 'lightline#ale#ok'; | |
}; | |
component_type = { | |
linter_checking = 'right'; | |
linter_infos = 'right'; | |
linter_warnings = 'warning'; | |
linter_errors = 'error'; | |
linter_ok = 'right'; | |
} | |
} | |
-- autocmd to delete trailling whitespace | |
vim.api.nvim_exec([[autocmd BufWritePre * :%s/\s\+$//e]], false) | |
-- autocmd to set ocaml indent to 2 | |
vim.api.nvim_exec([[autocmd FileType ocaml setlocal shiftwidth=2 softtabstop=2 expandtab]], false) | |
vim.api.nvim_exec([[autocmd CursorHold * silent call CocActionAsync('highlight')]], false) | |
-- treesitter config | |
require('nvim-treesitter.configs').setup { | |
ensure_installed = {"rust", "python"}, | |
sync_install = false, | |
highlight = {enable = true} | |
} | |
require('telescope').setup { | |
defaults = { | |
file_ignore_patterns = {".git", "target"} | |
} | |
} | |
vim.cmd [[ autocmd User CocStatusChange,CocDiagnosticChange call lightline#update() ]] | |
local map = vim.api.nvim_set_keymap | |
-- Misc | |
-- Using curly-brackets on mac is awful | |
-- https://vi.stackexchange.com/a/21425 | |
map('n', '[', '{', {}) | |
map('n', ']', '}', {}) | |
map('n', '<leader>nt', ':tabnext<CR>', {noremap = true}) | |
map('n', '<leader>pt', ':tabprevious<CR>', {noremap = true}) | |
map('n', '<leader>|', ':vsplit<CR>', {noremap = true}) | |
map('n', '<leader>-', ':split<CR>', {noremap = true}) | |
-- Telescope | |
map('n', '<leader>ff', ':Telescope find_files<cr>', {noremap = true}) | |
map('n', '<leader>fg', ':Telescope live_grep<CR>', {noremap = true}) | |
map('n', '<leader>fb', ':Telescope buffers<CR>', {noremap = true}) | |
map('n', '<leader>fh', ':Telescope help_tags<CR>', {noremap = true}) | |
-- Coc Settings | |
-- Show Documentation with K | |
vim.cmd [[ | |
function! ShowDocumentation() | |
if CocAction('hasProvider', 'hover') | |
call CocActionAsync('doHover') | |
else | |
call feedkeys('K', 'in') | |
endif | |
endfunction | |
]] | |
map('n', 'K', ':call ShowDocumentation()<CR>', {noremap = true}) | |
-- Definition and friends | |
map('n', 'gd', '<Plug>(coc-definition)', {}) | |
map('n', 'gy', '<Plug>(coc-type-definition)', {}) | |
map('n', 'gi', '<Plug>(coc-implementation)', {}) | |
map('n', 'gr', '<Plug>(coc-references)', {}) | |
map('n', '<c-space>', 'coc#refresh()', {}) | |
-- rename | |
map('n', '<leader>rn', '<Plug>(coc-rename)', {}) | |
-- Add `:Format` command to format current buffer. | |
vim.cmd [[ command! -nargs=0 Format :call CocActionAsync('format') ]] | |
-- -- Mappings for CoCList | |
-- -- Show all diagnostics. | |
-- map('n', '<silent><nowait> <leader>la', ':<C-u>CocList diagnostics<cr>', {noremap = true}) | |
-- -- Manage extensions. | |
-- map('n', '<silent><nowait> <leader>le', ':<C-u>CocList extensions<cr>', {noremap = true}) | |
-- -- Show commands. | |
-- map('n', '<silent><nowait> <leader>lc', ':<C-u>CocList commands<cr>', {noremap = true}) | |
-- -- Find symbol of current document. | |
-- map('n', '<silent><nowait> <leader>lo', ':<C-u>CocList outline<cr>', {noremap = true}) | |
-- -- Search workspace symbols. | |
-- map('n', '<silent><nowait> <leader>ls', ':<C-u>CocList -I symbols<cr>', {noremap = true}) | |
-- -- Do default action for next item. | |
-- map('n', '<silent><nowait> <leader>lj', ':<C-u>CocNext<CR>', {noremap = true}) | |
-- -- Do default action for previous item. | |
-- map('n', '<silent><nowait> <leader>lk', ':<C-u>CocPrev<CR>', {noremap = true}) | |
-- -- Resume latest coc list. | |
-- map('n', '<silent><nowait> <leader>lp', ':<C-u>CocListResume<CR>', {noremap = true}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment