From cf3e89c360157ee7a9bc1506d2179ef44596c04f Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Tue, 29 Apr 2025 08:33:54 -0500 Subject: Updates --- nvim/init.vim | 201 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 160 insertions(+), 41 deletions(-) (limited to 'nvim/init.vim') diff --git a/nvim/init.vim b/nvim/init.vim index 5b7dd6d..0e2d81d 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -9,6 +9,11 @@ set list set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:» set noexpandtab +" Kevin's lint +set expandtab +set softtabstop=4 +set shiftwidth=4 + " Set wrap set wrap @@ -31,14 +36,29 @@ Plug 'xuyuanp/nerdtree-git-plugin' Plug 'tpope/vim-fugitive' " " "Fuzzy file search -Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' -" + " "tab completion -Plug 'Shougo/denite.nvim' -Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } -Plug 'Shougo/echodoc.vim' -Plug 'deoplete-plugins/deoplete-jedi' +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 @@ -49,12 +69,12 @@ Plug 'nvim-lua/plenary.nvim' Plug 'chrisbra/csv.vim' " Lua, Moonscript, Teal -Plug 'xolox/vim-misc' -Plug 'xolox/vim-lua-ftplugin' +"Plug 'xolox/vim-misc' +"Plug 'xolox/vim-lua-ftplugin' Plug 'VaiN474/vim-etlua' Plug 'leafo/moonscript-vim' Plug 'teal-language/vim-teal' -Plug 'neovim/nvim-lspconfig' +Plug 'S1M0N38/love2d.nvim' " Treesitter, higlihting Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} @@ -104,39 +124,46 @@ Plug 'nomnivore/ollama.nvim' "Plug 'hashivim/vim-terraform' call plug#end() -colorscheme onedark +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')),16) % len(colorschemes)] +execute('colorscheme ' . cs) "deoplete -let g:deoplete#enable_at_startup = 1 -inoremap pumvisible() ? "\" : check_back_space() ? "\" : deoplete#mappings#manual_complete() -function s:check_back_space() abort "{{{ - let col = col('.') - 1 - return !col || getline('.')[col-1] =~ '\s' -endfunction "}}} -autocmd CompleteDone * if pumvisible() == 0 | silent! pclose | endif +"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 +"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 +"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 nunmap K +"au BufReadPost *.lua let g:lua_complete_omni=1 " GLSL au BufReadPost *.vs,*.fs set ft=glsl @@ -166,9 +193,12 @@ 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 --format "%(refname:short)"'})) -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'})) +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 @@ -187,8 +217,6 @@ else vmap c endif -"Set leader -let mapleader=";" "Shortcut to modify vim config nnoremap ec :tabe $MYVIMRC @@ -282,7 +310,100 @@ if has_key(environ(), "LUNARVIM_BASE_DIR") "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 + + " 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") @@ -301,20 +422,18 @@ lua << EOF -- 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 = "data" + root_dir = "src" }) end, }) EOF + +" love2d help + lua << EOF - require("lspconfig").lua_ls.setup{ - settings={ - Lua={ - runtime={ - version="LuaJIT", - path="data/?.lua" - } - } - } - } + 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 -- cgit v1.2.3-70-g09d2