319 lines
9.1 KiB
VimL
319 lines
9.1 KiB
VimL
call plug#begin('~/.local/share/nvim/plugged')
|
|
|
|
" =============================================================================
|
|
" Key usability plugins
|
|
" =============================================================================
|
|
|
|
" FZF Fuzzy Search
|
|
Plug 'junegunn/fzf', { 'dir': '~/.fzf' }
|
|
Plug 'junegunn/fzf.vim'
|
|
|
|
" Floating terminal support for Neovim
|
|
Plug 'voldikss/vim-floaterm'
|
|
|
|
" Neovim LSP
|
|
Plug 'neovim/nvim-lspconfig'
|
|
|
|
" Treesitter
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
|
|
" Plenary - lua components used by other plugins
|
|
Plug 'nvim-lua/plenary.nvim'
|
|
|
|
" Completion
|
|
Plug 'hrsh7th/cmp-nvim-lsp' " Builtin LSP as a completion source
|
|
Plug 'hrsh7th/cmp-path' " Support for path as a completion source
|
|
Plug 'hrsh7th/cmp-buffer' " Support for loaded buffers as completion source
|
|
Plug 'hrsh7th/nvim-cmp' " Primary plugin
|
|
|
|
" =============================================================================
|
|
" Languages and project type support.
|
|
" =============================================================================
|
|
|
|
" Janet Support
|
|
Plug 'janet-lang/janet.vim', { 'for': ['janet'] }
|
|
|
|
" Racket Support
|
|
Plug 'wlangstroth/vim-racket', { 'for': ['rkt'] }
|
|
|
|
" Generalized support for LISPs (Clojure, Racket, Janet)
|
|
Plug 'Olical/conjure', { 'tag': 'v4.25.0', 'for': ['janet'] }
|
|
|
|
" Zig Support
|
|
Plug 'ziglang/zig.vim', { 'for': ['zig'] }
|
|
|
|
" Scala Support
|
|
" Note: Metals should not be configured with the other LSP items.
|
|
Plug 'scalameta/nvim-metals', { 'for': ['scala', 'sbt'] }
|
|
|
|
" =============================================================================
|
|
" Visual enhancements
|
|
" =============================================================================
|
|
|
|
Plug 'sainnhe/gruvbox-material'
|
|
" Plug 'rebelot/kanagawa.nvim'
|
|
|
|
call plug#end()
|
|
|
|
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
filetype plugin indent on
|
|
syntax on
|
|
let mapleader=","
|
|
let maplocalleader=","
|
|
|
|
" === Color Scheme === {{
|
|
set termguicolors
|
|
set background=dark
|
|
let g:gruvbox_material_palette = 'mix'
|
|
let g:gruvbox_material_background = 'hard'
|
|
let g:gruvbox_material_enable_bold = 1
|
|
colorscheme gruvbox-material
|
|
"colorscheme kanagawa
|
|
|
|
" === History and Undo Levels === {{
|
|
set history=512
|
|
set undolevels=128
|
|
set undofile
|
|
set undodir=~/.config/nvim/undo
|
|
" }}
|
|
|
|
" === Assorted Core Settings === {{
|
|
set noswapfile
|
|
set nocompatible
|
|
set modelines=0
|
|
set hidden " Hide buffers
|
|
set encoding=utf-8 " Always use UTF-8 explicitly
|
|
set number " Show line numbers by default
|
|
set cursorline " Highlight the current line
|
|
set showcmd " Display incomplete commands at the bottom
|
|
set noerrorbells " ... we just don't like beeping
|
|
set visualbell " Flash rather than beep
|
|
set t_vb= " Don't flash please
|
|
set ttyfast " Some optimizations for rendering
|
|
set ruler " Show row and column number
|
|
set laststatus=2 " Last window has a status line
|
|
set showmatch " Show matching parens
|
|
set lazyredraw " redraw only when necessary, hopefully more efficient.
|
|
set pastetoggle=<F2> " Cheap way to paste toggle
|
|
set colorcolumn=80 " Right margin display
|
|
set shortmess-=F " Ensure audocmd works for filetype
|
|
set shortmess+=c " Avoid showing extra message when using completion
|
|
set spelllang=en_us
|
|
" }}
|
|
|
|
" === Basic Completion Settings === {{
|
|
" menu = use a popup menu to show possible completions
|
|
" menuone = show a menu even if there is only one match
|
|
" noinsert = do not insert text for a match until user selects one
|
|
" noselect = do not select a match from the menu automatically
|
|
set completeopt=menu,menuone,noinsert,noselect
|
|
" }}
|
|
|
|
" === Indentation === {{
|
|
set tabstop=4
|
|
set shiftwidth=4
|
|
set softtabstop=4
|
|
set expandtab
|
|
set smarttab
|
|
set autoindent
|
|
" }}
|
|
|
|
" === Search Settings === {{
|
|
set ignorecase
|
|
set smartcase
|
|
set incsearch
|
|
set showmatch
|
|
set hlsearch
|
|
" }}
|
|
|
|
" === General Ignores === {{
|
|
set wildignore=*.class,*.pyc,*.swp,*.o,*.jar
|
|
set wildignore+=*/tmp/*,*.zip,*.tar,*.gz,*.bz2,*.xz
|
|
set wildignore+=*/.git/*
|
|
set wildignore+=*/.metals/*,*/.bloop/*,*/.bsp/*
|
|
set wildignore+=*/node_modules/*
|
|
" }}
|
|
|
|
" === FZF Configuration === {{
|
|
let $FZF_DEFAULT_COMMAND='rg --files --no-messages "" .'
|
|
" }}
|
|
|
|
" === Key Mappings === {{
|
|
|
|
" Use Tab and Shift+Tab to navigate popup menus
|
|
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
|
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
|
|
|
" Clear search highlighting
|
|
nmap <silent> <leader>/ :nohlsearch<CR>
|
|
|
|
" Save current buffer
|
|
nnoremap <leader>s :up<cr>
|
|
|
|
" Move to previous buffer
|
|
nnoremap <leader>bp :bp<cr>
|
|
|
|
" Move to next buffer
|
|
nnoremap <leader>bn :bn<cr>
|
|
|
|
" Delete current buffer
|
|
nnoremap <leader>bd :bd<cr>
|
|
|
|
" Press ; to show a list of active buffers (+ fuzzy search)
|
|
nmap ; :Buffers<CR>
|
|
|
|
" Press Ctrl+P to show a list of files (+ fuzzy search)
|
|
nmap <C-p> :Files<CR>
|
|
|
|
" Press <leader> + f to use ripgrep for search
|
|
nmap <leader>f :Rg<space>
|
|
|
|
" LSP key bindings
|
|
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
|
|
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
|
nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
|
|
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
|
|
nnoremap <silent> gds <cmd>lua vim.lsp.buf.document_symbol()<CR>
|
|
nnoremap <silent> gws <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
|
|
nnoremap <silent> <leader>D <cmd>lua vim.lsp.buf.type_definition()<CR>
|
|
nnoremap <silent> <leader>rn <cmd>lua vim.lsp.buf.rename()<CR>
|
|
nnoremap <silent> <leader>ca <cmd>lua vim.lsp.buf.code_action()<CR>
|
|
nnoremap <silent> <leader>q <cmd>lua vim.lsp.diagnostic.set_loclist()<CR>
|
|
nnoremap <silent> <leader>e <cmd>lua vim.lsp.diagnostic.open_float()<CR>
|
|
nnoremap <silent> [c <cmd>lua vim.lsp.diagnostic.goto_prev { wrap = false }<CR>
|
|
nnoremap <silent> ]c <cmd>lua vim.lsp.diagnostic.goto_next { wrap = false }<CR>
|
|
|
|
" Window movement
|
|
map <C-j> <C-w>j
|
|
map <C-k> <C-w>k
|
|
map <C-h> <C-w>h
|
|
map <C-l> <C-w>l
|
|
" }}
|
|
|
|
" === JSON Support === {{
|
|
|
|
" Properly handle comments in JSON.
|
|
autocmd FileType json syntax match Comment +\/\/.\+$+
|
|
|
|
" }}
|
|
|
|
" === netrw === {{
|
|
let g:netrw_banner = 0
|
|
let g:netrw_liststyle = 3
|
|
let g:netrw_browse_split = 4
|
|
let g:netrw_altv = 1
|
|
let g:netrw_winsize = 25
|
|
" }}
|
|
|
|
" === floaterm Configuration === {{
|
|
let g:floaterm_keymap_new = '<leader>tc'
|
|
let g:floaterm_keymap_prev = '<leader>tp'
|
|
let g:floaterm_keymap_next = '<leader>tn'
|
|
let g:floaterm_keymap_toggle = '<leader>tt'
|
|
let g:floaterm_width = 0.8
|
|
let g:floaterm_height = 0.8
|
|
let g:floaterm_gitcommit = 'split'
|
|
" }}
|
|
|
|
" === nvim-cmp Configuration (Completion Plugin) === {{
|
|
lua << EOF
|
|
local cmp = require("cmp")
|
|
cmp.setup({
|
|
sources = {
|
|
{ name = "nvim_lsp" },
|
|
{ name = "path" },
|
|
{ name = 'buffer', option = { keyword_length = 3 }, },
|
|
},
|
|
mapping = {
|
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
|
["<Tab>"] = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
["<S-Tab>"] = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
},
|
|
})
|
|
EOF
|
|
" }}
|
|
|
|
" === LSP Configuration === {{
|
|
lua << EOF
|
|
local lsp = require('lspconfig')
|
|
|
|
-- Use an on_attach function to configure after LSP attaches to buffer
|
|
local on_attach = function(client, bufnr)
|
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
end
|
|
|
|
-- advertise the nvim-cmp capabilities to LSP servers
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
|
|
|
lsp.zls.setup {
|
|
on_attach = on_attach,
|
|
flags = {
|
|
debounce_text_changes = 150
|
|
},
|
|
capabilities = capabilities
|
|
}
|
|
|
|
-- Note that metals is totally separate
|
|
-- It's also absurdly slow on a Raspberry Pi, it's only viable for somewhat
|
|
-- powerful machines (as is Scala dev in general).
|
|
metals_config = require("metals").bare_config()
|
|
|
|
metals_config.settings = {
|
|
showImplicitArguments = true,
|
|
serverVersion = "0.10.9+255-c4955009-SNAPSHOT",
|
|
}
|
|
|
|
metals_config.capabilities = capabilities
|
|
|
|
vim.cmd([[augroup lsp]])
|
|
vim.cmd([[autocmd!]])
|
|
vim.cmd([[autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc]])
|
|
vim.cmd([[autocmd FileType java,scala,sbt lua require("metals").initialize_or_attach(metals_config)]])
|
|
vim.cmd([[augroup end]])
|
|
EOF
|
|
" }}
|
|
|
|
" === Treesitter Configuration === {{
|
|
lua <<EOF
|
|
require'nvim-treesitter.configs'.setup {
|
|
-- One of "all", "maintained", or a list of languages
|
|
ensure_installed = { "c", "zig", "bash", "scala" },
|
|
|
|
-- Install languages synchronously (only applied to `ensure_installed`)
|
|
sync_install = false,
|
|
|
|
-- List of parsers to ignore installing
|
|
ignore_install = { },
|
|
|
|
highlight = {
|
|
enable = true,
|
|
disable = {},
|
|
-- 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,
|
|
},
|
|
|
|
indent = {
|
|
enable = true
|
|
}
|
|
}
|
|
EOF
|
|
" }}
|