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= " 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 pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " Clear search highlighting nmap / :nohlsearch " Save current buffer nnoremap s :up " Move to previous buffer nnoremap bp :bp " Move to next buffer nnoremap bn :bn " Delete current buffer nnoremap bd :bd " Press ; to show a list of active buffers (+ fuzzy search) nmap ; :Buffers " Press Ctrl+P to show a list of files (+ fuzzy search) nmap :Files " Press + f to use ripgrep for search nmap f :Rg " LSP key bindings nnoremap K lua vim.lsp.buf.hover() nnoremap gd lua vim.lsp.buf.definition() nnoremap gi lua vim.lsp.buf.implementation() nnoremap gr lua vim.lsp.buf.references() nnoremap gds lua vim.lsp.buf.document_symbol() nnoremap gws lua vim.lsp.buf.workspace_symbol() nnoremap D lua vim.lsp.buf.type_definition() nnoremap rn lua vim.lsp.buf.rename() nnoremap ca lua vim.lsp.buf.code_action() nnoremap q lua vim.lsp.diagnostic.set_loclist() nnoremap e lua vim.lsp.diagnostic.open_float() nnoremap [c lua vim.lsp.diagnostic.goto_prev { wrap = false } nnoremap ]c lua vim.lsp.diagnostic.goto_next { wrap = false } " Window movement map j map k map h map 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 = 'tc' let g:floaterm_keymap_prev = 'tp' let g:floaterm_keymap_next = 'tn' let g:floaterm_keymap_toggle = '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 = { [""] = cmp.mapping.confirm({ select = true }), [""] = function(fallback) if cmp.visible() then cmp.select_next_item() else fallback() end end, [""] = 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.11.1", } 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 <