let &shell = '/bin/sh' let g:python3_host_prog = expand('~/.virtualenvs/neovim3/bin/python') let g:loaded_python_provider = 0 " Disable python2 support for plugins call plug#begin('~/.local/share/nvim/plugged') if filereadable(expand("~/.config/nvim/os-plugins.vim")) source ~/.config/nvim/os-plugins.vim endif Plug 'airblade/vim-gitgutter' Plug 'airblade/vim-rooter' Plug 'cespare/vim-toml', { 'branch': 'main' } Plug 'chrisbra/unicode.vim' Plug 'dense-analysis/ale' Plug 'elixir-editors/vim-elixir' Plug 'fatih/vim-go' Plug 'Glench/Vim-Jinja2-Syntax' Plug 'glts/vim-textobj-comment' Plug 'hrsh7th/cmp-nvim-lsp', { 'branch': 'main' } Plug 'hrsh7th/nvim-cmp', { 'branch': 'main' } Plug 'ianks/vim-tsx' Plug 'jeetsukumaran/vim-buffergator' Plug 'jiangmiao/auto-pairs' Plug 'jjo/vim-cue' Plug 'jparise/vim-graphql' Plug 'junegunn/fzf.vim' Plug 'junegunn/vim-easy-align' Plug 'kana/vim-textobj-user' Plug 'keith/swift.vim' Plug 'L3MON4D3/LuaSnip' Plug 'leafgarland/typescript-vim' Plug 'ledger/vim-ledger' Plug 'LnL7/vim-nix' Plug 'MarcWeber/vim-addon-local-vimrc' Plug 'mxw/vim-jsx' Plug 'neovim/nvim-lspconfig' Plug 'ntpeters/vim-better-whitespace' Plug 'pangloss/vim-javascript' Plug 'preservim/vim-markdown' Plug 'qpkorr/vim-bufkill' Plug 'rust-lang/rust.vim' Plug 'saadparwaiz1/cmp_luasnip' Plug 'scrooloose/nerdtree' Plug 'simrat39/rust-tools.nvim' Plug 'sirtaj/vim-openscad' Plug 'tpope/vim-abolish' Plug 'tpope/vim-bundler' Plug 'tpope/vim-commentary' Plug 'tpope/vim-endwise' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-rails' Plug 'tpope/vim-repeat' Plug 'tpope/vim-surround' Plug 'udalov/kotlin-vim' Plug 'urbit/hoon.vim' Plug 'vim-python/python-syntax' Plug 'vim-ruby/vim-ruby' Plug 'wellle/context.vim' Plug 'williamboman/nvim-lsp-installer', { 'branch': 'main' } call plug#end() set number set hidden colorscheme jdkaplan set expandtab set tabstop=4 set softtabstop=4 set shiftwidth=4 set smartindent set formatoptions=crqnlj set nofoldenable set nojoinspaces set wrap set linebreak set nolist set textwidth=0 set wrapmargin=0 set listchars=tab:>-,extends:>,precedes:<,nbsp:+,trail:- set ignorecase set smartcase set cursorline set splitbelow set splitright set modelines=0 set lazyredraw set updatetime=250 set shortmess+=I set virtualedit= noremap k gk noremap j gj map ; : noremap ;; ; map ; :nohlsearch map ;h :wincmd h map ;j :wincmd j map ;k :wincmd k map ;l :wincmd l map ;" :split map ;% :vsplit map ;0 :close map ;1 :only map ;w :w map ;q :q map ;x :x map ;G :Git set wildignore+=*.swp,*~ map ;b :Buffers map ;f :call fzf#run({'source': 'fd --hidden --type f', 'sink': 'e', 'options': '--multi'}) function! s:escape(path) return substitute(a:path, ' ', '\\ ', 'g') endfunction function! RgHandler(line) let parts = split(a:line, ':') let [fn, lno] = parts[0 : 1] execute 'e '. s:escape(fn) execute lno normal! zz endfunction map ;g :call fzf#run({ \ 'source': 'rg --vimgrep --no-heading --smart-case --hidden --regexp '.shellescape(input('Pattern: ')), \ 'sink': function('RgHandler'), \ 'options': '--multi', \}) map ;* :call fzf#run({ \ 'source': 'rg --vimgrep --no-heading --smart-case --hidden --regexp '.shellescape(expand('')), \ 'sink': function('RgHandler'), \ 'options': '--multi', \}) command ALEOff :let b:ale_fix_on_save = 0 let g:ale_sign_error = '!' let g:ale_sign_warning = '?' let g:ale_echo_msg_format = '[%linter%] %code: %%s' let g:ale_fix_on_save = 1 " Clear the default --enable-all because I disagree with too many linters. let g:ale_go_golangci_lint_options='' " Lint the whole package to reduce noise in dead code linters. let g:ale_go_golangci_lint_package=1 let g:ale_linters_explicit = 1 let g:ale_linters = { \ 'arduino': [ \ 'clang-tidy', \ ], \ 'bash': [ \ 'shellcheck', \ ], \ 'css': [ \ 'stylelint', \ ], \ 'go': [ \ 'golangci-lint', \ ], \ 'javascript': [ \ 'eslint', \ ], \ 'proto': [ \ 'protolint', \ ], \ 'python': [ \ 'flake8', \ 'mypy', \ ], \ 'ruby': [ \ 'rubocop', \ 'sorbet', \ ], \ 'sh': [ \ 'shellcheck', \ ], \ 'typescript': [ \ 'eslint', \ ], \ 'zsh': [ \ 'shellcheck', \ ], \} let g:ale_fixers = { \ 'arduino': [ \ 'clang-format', \ ], \ 'css': [ \ 'prettier', \ ], \ 'elixir': [ \ 'mix_format', \ ], \ 'html': [ \ 'prettier', \ ], \ 'javascript': [ \ 'eslint', \ 'prettier', \ ], \ 'python': [ \ 'black', \ ], \ 'ruby': [ \ 'rubocop', \ ], \ 'scss': [ \ 'prettier', \ ], \ 'typescript': [ \ 'prettier', \ ], \} nmap ;n (ale_next_wrap) nmap ;N (ale_previous_wrap) nmap e :lclose nmap E :lopen let g:better_whitespace_enabled=1 let g:better_whitespace_filetypes_blacklist=['diff'] let g:strip_whitespace_on_save=1 let g:strip_whitespace_confirm=0 let g:better_whitespace_operator='' map t :NERDTreeToggle noremap a :NERDTreeFind noremap m :NERDTreeFind let g:python_highlight_all = 1 " Disable vim-go's gd mapping now that nvim-lspconfig uses it. let g:go_def_mapping_enabled = 0 let g:go_fmt_command = "gopls" let g:go_highlight_build_constraints = 1 let g:go_highlight_interfaces = 1 let g:go_highlight_functions = 1 let g:go_highlight_methods = 1 let g:go_highlight_operators = 1 let g:go_highlight_structs = 1 let g:go_highlight_types = 1 let g:buffergator_viewport_split_policy = 'B' let g:buffergator_autoupdate = 1 let g:buffergator_sort_regime = 'filepath' let g:buffergator_display_regime = 'bufname' let g:buffergator_show_full_directory_path = 0 let g:buffergator_suppress_keymaps = 1 let g:buffergator_autodismiss_on_select = 0 map b :BuffergatorToggle let g:rooter_manual_only = 1 let g:rooter_patterns = ['.root', '.git', '.git/'] noremap cd :execute 'cd' fnameescape(FindRootDirectory()):pwd let g:AutoPairsMultilineClose = 0 let g:AutoPairsShortcutBackInsert = '' let g:AutoPairsShortcutToggle = '' let g:javascript_plugin_flow = 1 let g:ale_javascript_flow_use_respect_pragma = 0 let g:jsx_ext_required = 1 let g:gitgutter_enabled = 0 let g:gitgutter_map_keys = 0 map g :GitGutterToggle nmap ]h (GitGutterNextHunk) nmap [h (GitGutterPrevHunk) command Crosshair :set virtualedit=all cursorcolumn command NoCrosshair :set virtualedit= nocursorcolumn autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType eruby setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType javascript.jsx setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType javascript setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType jinja.html setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType jinja setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType json setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType proto setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType scss setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType typescript.tsx setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType typescript setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType xml setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType markdown setlocal commentstring= autocmd FileType hoon setlocal commentstring=::%s autocmd FileType hurl setlocal commentstring=#%s set secure autocmd FileType markdown setlocal spell autocmd FileType text setlocal spell set spellcapcheck= autocmd BufNewFile,BufRead *.arb set filetype=ruby autocmd BufNewFile,BufRead *.html.erb set filetype=eruby.html autocmd BufNewFile,BufRead *.hurl set filetype=hurl autocmd FileType ledger nmap ' :call ledger#transaction_state_toggle(line('.'), ' !*') nmap ;cc :let @+=expand("%") nmap ;cl :let @+=join([expand("%"), line(".")], ":") nmap ;cg :let @+=join([expand("%"), line(".")], "#L") nmap ;cp :let @+=expand("%:p") " For some reason, (neo)vim sees as , so bind that instead. autocmd FileType html inoremap let g:Unicode_no_default_mappings = 1 imap (UnicodeFuzzy) " https://vim.fandom.com/wiki/Search_for_visually_selected_text vnoremap // y/\V=escape(@",'/\') " CTRL-L usually clears and redraws the screen. Might as well use it to reset " the colorscheme too! fun s:ResetScreen() colorscheme jdkaplan redraw endfun command ResetScreen call s:ResetScreen() nnoremap :ResetScreen let g:vim_markdown_folding_disabled = 1 let g:context_enabled = 0 map cc :ContextToggleWindow map cp :ContextPeek set completeopt=menu,menuone,noselect xmap ga (EasyAlign) nmap ga (EasyAlign) lua < buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local opts = { noremap=true, silent=true } buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', 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', '', 'lua vim.lsp.buf.signature_help()', opts) buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) buf_set_keymap('n', 'R', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) buf_set_keymap('v', 'ca', 'lua vim.lsp.buf.range_code_action()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) buf_set_keymap('n', 'd', 'lua vim.diagnostic.open_float()', opts) buf_set_keymap('n', 'j', 'lua vim.diagnostic.goto_next()', opts) buf_set_keymap('n', 'k', 'lua vim.diagnostic.goto_prev()', opts) buf_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) vim.api.nvim_command [[autocmd BufWritePre lua vim.lsp.buf.format()]] end local lsp_installer = require('nvim-lsp-installer') lsp_installer.setup({}) local lsp_settings = { gopls = {}, pyright = {}, rust_analyzer = { ["rust-analyzer"] = { checkOnSave = { command = "clippy", }, }, }, solargraph = {}, tsserver = {}, } for _, server in ipairs(lsp_installer.get_installed_servers()) do -- rust-analyzer will be configured by rust-tools. if server.name == 'rust_analyzer' then goto continue end nvim_lsp[server.name].setup { on_attach = on_attach, settings = lsp_settings[server.name], capabilities = capabilities, } ::continue:: end require('rust-tools').setup({ tools = { autoSetHints = true, hover_with_actions = false, inlay_hints = { only_current_line = true, -- Parameter hints are more annoying than useful here. Neovim can't show -- virtual text in the middle of the line like other editors do. It would -- mess with grid-based motion anyway. show_parameter_hints = false, parameter_hints_prefix = "", other_hints_prefix = "//", }, }, server = { standalone = false, capabilities = capabilities, on_attach = on_attach, settings = lsp_settings.rust_analyzer, }, }) local luasnip = require 'luasnip' -- Put snippets in ./snippets/.snippets require("luasnip.loaders.from_snipmate").lazy_load() local cmp = require 'cmp' cmp.setup { completion = { autocomplete = false, }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { 'i', 's' }), }), sources = { { name = "nvim_lsp" }, { name = "luasnip" }, }, } LSPCONFIG