"line numbers set nu "unix newlines set ff=unix "set the highlight column at 80 set colorcolumn=80 " displace spaces, tabs, and newlines set list set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:» set noexpandtab " Kevin's lint set expandtab set softtabstop=4 set shiftwidth=4 " Clipboard set clipboard+=unnamedplus " Set wrap set wrap "2 lines of cmd, needed for echodoc set cmdheight=2 if has('win32') source $VIMRUNTIME/mswin.vim endif if has('mac') let g:neovide_input_macos_option_key_is_meta = 'only_left' endif let g:python3_host_prog='python3' call plug#begin('~/.vim/plugged') "Formatting and navigation Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'scrooloose/nerdcommenter' Plug 'godlygeek/tabular' " " "Git Plug 'xuyuanp/nerdtree-git-plugin' Plug 'tpope/vim-fugitive' " " "Fuzzy file search Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' " "tab completion Plug 'williamboman/mason.nvim' Plug 'williamboman/mason-lspconfig.nvim' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/nvim-cmp' "Plug 'Shougo/denite.nvim' "Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } "Plug 'Shougo/echodoc.vim' "Plug 'deoplete-plugins/deoplete-jedi' Plug 'neovim/nvim-lspconfig' "Plug 'deoplete-plugins/deoplete-lsp' " Snippits Plug 'hrsh7th/cmp-vsnip' Plug 'hrsh7th/vim-vsnip' " Python Plug 'raimon49/requirements.txt.vim' " Scala tab completion Plug 'nvim-lua/plenary.nvim' "Plug 'scalameta/nvim-metals' " CSV formatting Plug 'chrisbra/csv.vim' " Lua, Moonscript, Teal "Plug 'xolox/vim-misc' "Plug 'xolox/vim-lua-ftplugin' Plug 'VaiN474/vim-etlua' Plug 'leafo/moonscript-vim' Plug 'teal-language/vim-teal' Plug 'S1M0N38/love2d.nvim' " Treesitter, higlihting Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Coq Plug 'whonore/Coqtail' " GLSL Plug 'tikhomirov/vim-glsl' " Supercollider Plug 'davidgranstrom/scnvim' "Color schemes Plug 'mhartington/oceanic-next' Plug 'vim-scripts/Wombat' Plug 'zeis/vim-kolor' Plug 'alessandroyorba/despacio' Plug 'alessandroyorba/alduin' Plug 'tomasr/molokai' Plug 'sainnhe/vim-color-forest-night' Plug 'sts10/vim-pink-moon' Plug 'severij/vadelma' Plug 'kkpmw/sacredforest-vim' Plug 'jsit/toast.vim' Plug 'henrynewcomer/vim-theme-papaya' Plug 'sainnhe/edge' Plug 'kjssad/quantum.vim' Plug 'kyoz/purify' Plug 'jonathanfilip/vim-lucius' Plug 'joshdick/onedark.vim' Plug 'cocopon/iceberg.vim' Plug 'wolf-dog/sceaduhelm.vim' Plug 'danilo-augusto/vim-afterglow' Plug 'kamwitsta/mythos' Plug 'softmotions/vim-dark-frost-theme' Plug 'ghifarit53/tokyonight-vim' "Icons, requires a nerd font Plug 'ryanoasis/vim-devicons' "AI, requires ollama, curl, and plenary "on Plug 'nomnivore/ollama.nvim' Plug 'nvim-lualine/lualine.nvim' " Terraform "Plug 'hashivim/vim-terraform' call plug#end() let colorschemes = ['OceanicNext', 'afterglow', 'alduin', 'darkforest', 'edge', 'desert', 'despacio', 'onedark', 'evening', 'everforest', 'habamax', 'iceberg', 'kolor', 'lucius', 'lunaperche', 'molokai', 'moon', 'mythos', 'default', 'orange-moon', 'papaya', 'papaya_original', 'pink-moon', 'quantum', 'retrobox', 'sceaduhelm', 'slate', 'sorbet', 'toast', 'tokyonight', 'vadelma', 'yellow-moon', 'zaibatsu'] let cs = colorschemes[str2nr(sha256(execute('pwd'))[1:5],16) % len(colorschemes)] execute('colorscheme ' . cs) "deoplete "let g:deoplete#enable_at_startup = 1 "call deoplete#custom#option("min_pattern_length", 1) "call deoplete#custom#option("smart_case", 1) imap pumvisible() ? "\" : "\" imap pumvisible() ? "\\AutoPairsReturn" : "\" "imap pumvisible() ? "\" : "\" "imap pumvisible() ? deoplete#close_popup() : "\\AutoPairsReturn" " echodoc "let g:echodoc#enable_at_startup=1 "let g:echodoc#type="floating" "highlight link EchoDocFloat Pmenu "python "let g:deoplete#sources#jedi#python_path='python3' "let g:deoplete#sources#jedi#enable_short_types=1 "let g:deoplete#sources#jedi#show_docstring=1 "call deoplete#custom#source('jedi','max_info_width',0) "set completeopt-=preview "lua let g:lua_compiler_name='lua' "let g:lua_compiler_name='lua' let g:lua_complete_dynamic=1 let g:lua_complete_keywords=0 "let g:deoplete#lsp#handler_enabled=1 "let g:deoplete#lsp#use_icons_for_candidates=1 au BufReadPost *.busted set syntax=lua au BufReadPost *.spec set syntax=lua au BufReadPost *.etlua set syntax=html "Overwrite xolox:ftplugin's "Help" with shift-k "au BufReadPost *.lua nunmap K "au BufReadPost *.lua let g:lua_complete_omni=1 " GLSL au BufReadPost *.vs,*.fs set ft=glsl "scala augroup lsp au! au FileType java,scala,sbt lua m=require("metals"); mc=m.bare_config(); mc.init_options.statusBarProvider="on"; m.initialize_or_attach(mc) augroup end "NERDTree config autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | \ quit | endif nnoremap :NERDTreeToggle nnoremap :NERDTreeFind let NERDTreeMapHelp='y' let NERDTreeMapJumpLastChild='y' let NERDTreeMapJumpFirstChild='y' "NERDCommenter config "nnoremap :call nerdcommenter#Comment('x', 'toggle') "vnoremap :call nerdcommenter#Comment('x', 'toggle') "Fuzzy file search let g:fzf_layout = { 'window': {'width': 0.9, 'height': 0.6} } noremap :call fzf#run(fzf#wrap({'sink': 'tabe', 'left': '20%', 'source': 'git ls-files'})) noremap :call fzf#run(fzf#wrap({'sink': 'vsplit', 'left': '50%', 'source': 'git ls-files'})) "Set leader let mapleader=";" "Fuzzy git checkout branch noremap c :call fzf#run(fzf#wrap({'sink': 'Git checkout', 'left':'20%', 'source': 'git branch \| tr -d " "' })) noremap a :call fzf#run(fzf#wrap({'sink': 'git checkout', 'left':'50%', 'source': 'ag --nogroup --column --color --', 'preview-window':'up','preview':expand(':p:h:h:h').'/bin/preview.sh'})) "Fuzzy sbt function! s:VTerm(command) vsplit termopen(a:command) endfunction "ctrl+s saves nmap :w "For some reason this is different between linux and windows if has('win32') vmap c else vmap c endif "Shortcut to modify vim config nnoremap ec :tabe $MYVIMRC "Move around quickly nnoremap J 5j nnoremap K 5k nnoremap H 5h nnoremap L 5l vnoremap J 5j vnoremap K 5k vnoremap H 5h vnoremap L 5l "Navigate splits tnoremap h tnoremap j tnoremap k tnoremap l nnoremap h nnoremap j nnoremap k nnoremap l "Resize splits "noremap :vertical resize -5 "noremap :vertical resize +5 "noremap :res +5 "noremap :res -5 function! s:HasNeighbor(direction) return winnr() != winnr(a:direction) endfunction function! s:PushResize(direction, amount) if a:direction == 'l' || a:direction == 'h' let l:cmd = 'vertical resize' else let l:cmd = 'resize' endif if s:HasNeighbor(a:direction) let l:amount = '+'.a:amount else let l:amount = '-'.a:amount endif echo l:cmd . ' ' . l:amount execute l:cmd . ' ' . l:amount set cmdheight=2 endfunction nnoremap :call PushResize('h',5) nnoremap :call PushResize('j',5) nnoremap :call PushResize('k',5) nnoremap :call PushResize('l',5) "Navigate tabs noremap gt noremap gT "Add a semicolon at the end of the line vnoremap :'<,'>s/\([^;]\)$/\1;/g "Vertical split and make noremap :vsplit term://make all "Start a terminal noremap :vsplit:terminal "Find and open in a new tab noremap :Ag "Restart vim (alt+1) noremap :source $MYVIMRC \| :PlugInstall filetype plugin indent on syntax enable "Unmap a bunch of stuff set by lunarvim if has_key(environ(), "LUNARVIM_BASE_DIR") lua if lvim then lvim.builtin.which_key.mappings.e = nil end lua if lvim then lvim.lsp.buffer_mappings.normal_mode.K = nil end lua if lvim then lvim.builtin.bufferline.active = false end let $MYVIMRC=$LUNARVIM_BASE_DIR . "\\vimrc.vim" "nmap :NvimTreeToggle "vunmap "vmap :call nerdcommenter#NERDComment('x', 'toggle') "nnoremap :call nerdcommenter#Comment('x', 'toggle') endif " mason.nvim - lsp running lua require("mason").setup() "lua require("mason-lspconfig").setup({ensure_installed = {"lua_ls","harper-ls"}}) lua << EOF local cmp = require("cmp") local function has_words_before() local unpack = unpack or table.unpack local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end local function feedkey(key, mode) vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) end cmp.setup({ snippet= { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.confirm({select=true}), [""] = cmp.mapping.abort(), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif vim.fn["vsnip#available"](1) == 1 then feedkey("(vsnip-expand-or-jump)", "") elseif has_words_before() then cmp.complete() else fallback() end end, {"i","s"}), [""] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item() elseif vim.fn["vsnip#available"](1) == 1 then feedkey("(vsnip-jump-prev)", "") end end, {"i","s"}), }), sources = cmp.config.sources({ {name = "nvim_lsp"}, {name = "vsnip" }, },{ {name = "buffer" }, }), }) local capabilities = require("cmp_nvim_lsp").default_capabilities() vim.api.nvim_create_autocmd("LspAttach", { desc = "LSP actions", callback = function(event) local opts = {buffer = event.buf} vim.keymap.set("n", "", "lua vim.lsp.buf.hover()", opts) end, }) require("lspconfig").lua_ls.setup{ settings={ Lua={ runtime={ version="LuaJIT", path="src/?.lua;src/?/init.lua;lib/3rd/?/init.lua;lib/3rd/?.lua" }, completion = {enable = true, callSnippet = "Replace"}, diagnostics = { enable=true, }, workspace = { "${3rd}/love2d/library", "${3rd}/busted/library", } } } } require('lspconfig').harper_ls.setup { settings = { ["harper-ls"] = { linters = { SentenceCapitalization = false, SpellCheck = false } } } } EOF lua << EOF -- ollama.nvim integration do local function ollama_loaded() return package.loaded.ollama and require("ollama").status ~= nil end local ollama_status = { IDLE = "🦙", WORKING = "🤖" } local function get_status_icon() return ollama_status[require("ollama").status()] end require("lualine").setup({sections = {lualine_x = {get_status_icon, ollama_loaded}}}) require("ollama").config.prompts.fgen = { prompt = [[ Generate $ftype code that keeps all comments and follows this code: ``` $before ``` and could go before this code ``` $after ``` Respond EXACTLY in this format: ```$ftype ``` ]], action = "display_insert" } require("ollama").config.prompts.extend= { prompt = [[ Change this $ftype code to $input, keep any comments: $sel Respond EXACTLY in this format: ```$ftype ``` ]], action = "display_replace" } end EOF " ollama.nvim - ai code assist lua require("ollama").config.model = "codestral" vnoremap gg :lua require("ollama").prompt("fgen") vnoremap gh :lua require("ollama").prompt("Explain_Code") vnoremap gG :lua require("ollama").prompt("extend") nnoremap gt :lua require("ollama").prompt("Raw") lua << EOF vim.api.nvim_create_autocmd('FileType', { -- This handler will fire when the buffer's 'filetype' is "lua" pattern = 'lua', callback = function(ev) vim.lsp.start({ name = 'lua-lsp', cmd = {'lua-language-server'}, -- Set the "root directory" to the parent directory of the file in the -- current buffer (`ev.buf`) that contains either a "setup.py" or a -- "pyproject.toml" file. Files that share a root directory will reuse -- the connection to the same LSP server. root_dir = "src" }) end, }) EOF " love2d help lua << EOF require("love2d").setup{ path_to_love_bin = "love", path_to_love_library = vim.fn.globpath(vim.o.runtimepath, "love2d/library"), restart_on_save = false, } EOF " Acrisure " Sqlfluf leader+sql "nnoremap sql :let cfile=expand('%'):vsplit:terminalisqlfluff