dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 82292e09fcc3b4d0b893ecf5bf424968f5d93bf8
parent 319e3f42810cb701c1d2a9b306fcf71a423073e7
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Sat, 19 Nov 2022 19:24:59 +0100

nvim: config

Diffstat:
Mnvim/init.lua | 34++++++++++++++++++++++++++++++++++
Anvim/lua/plugins.lua | 31+++++++++++++++++++++++++++++++
Anvim/plugin/packer_compiled.lua | 104+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mvim/vimrc | 48+++++++++++++++++++++++++++---------------------
4 files changed, 196 insertions(+), 21 deletions(-)

diff --git a/nvim/init.lua b/nvim/init.lua @@ -4,6 +4,9 @@ let &packpath = &runtimepath source ~/.vim/vimrc ]]) +-- neovim plugins +require('plugins') + local custom_lsp_attach = function(client) -- See `:help nvim_buf_set_keymap()` for more information vim.api.nvim_buf_set_keymap(0, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', {noremap = true}) @@ -22,3 +25,34 @@ end require'lspconfig'.rust_analyzer.setup({ on_attach = custom_lsp_attach }) +require'lspconfig'.pyright.setup{} + +require'nvim-treesitter.configs'.setup { + -- Automatically install missing parsers when entering buffer + auto_install = true, + -- Consistent syntax highlighting + highlight = { + enable = true, + -- 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, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + indent = { + enable = true + } +} +vim.cmd([[ +set foldmethod=expr +set foldexpr=nvim_treesitter#foldexpr() +]]) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua @@ -0,0 +1,31 @@ +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) + vim.cmd [[packadd packer.nvim]] + return true + end + return false +end + +local packer_bootstrap = ensure_packer() + +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + use 'neovim/nvim-lspconfig' + use { + 'nvim-treesitter/nvim-treesitter', + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end, + } + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if packer_bootstrap then + require('packer').sync() + end +end) diff --git a/nvim/plugin/packer_compiled.lua b/nvim/plugin/packer_compiled.lua @@ -0,0 +1,104 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + +_G._packer = _G._packer or {} +_G._packer.inside_compile = true + +local time +local profile_info +local should_profile = false +if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end +else + time = function(chunk, start) end +end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + if threshold then + table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') + end + + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/Users/alex/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/alex/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/alex/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/alex/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/Users/alex/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + ["nvim-lspconfig"] = { + loaded = true, + path = "/Users/alex/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["packer.nvim"] = { + loaded = true, + path = "/Users/alex/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + } +} + +time([[Defining packer_plugins]], false) + +_G._packer.inside_compile = false +if _G._packer.needs_bufread == true then + vim.cmd("doautocmd BufRead") +end +_G._packer.needs_bufread = false + +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end diff --git a/vim/vimrc b/vim/vimrc @@ -58,7 +58,7 @@ Plug 'junegunn/goyo.vim' Plug 'junegunn/limelight.vim' " Better CSV editing -Plug 'chrisbra/csv.vim' +Plug 'mechatroner/rainbow_csv' " Display ANSI color codes Plug 'vim-scripts/AnsiEsc.vim' @@ -91,9 +91,6 @@ Plug 'airblade/vim-gitgutter' " Bracket bindings for filetypes Plug 'arp242/jumpy.vim' -" Substitute preview -Plug 'markonm/traces.vim' - " Omnifuncs Plug 'myhere/vim-nodejs-complete' Plug 'othree/html5.vim' @@ -164,16 +161,21 @@ Plug 'rust-lang/rust.vim', { 'for': 'rust' } " Show context Plug 'wellle/context.vim' -if has('nvim') - Plug 'neovim/nvim-lspconfig' +" Vim-only +if !has('nvim') + " Substitute preview + Plug 'markonm/traces.vim' endif + call plug#end() " quickfix filtering packadd cfilter -" matchit.vim is default, why not enable it -packadd matchit +if !has('nvim') + " matchit.vim is default, why not enable it + packadd matchit +endif " }}}2 " Config {{{2 @@ -536,6 +538,7 @@ set dictionary+=/usr/share/dict/words " thesaurus file set thesaurus=~/.vim/words/thesaurus/mthesaur.txt +if !has('nvim') " same with :Man " I'm lazy-loading this because it really affects my startup time. " I'm not the only one: https://www.reddit.com/r/vim/comments/emx856/lazy_loading_man_page_plugin/ @@ -543,6 +546,7 @@ silent! command! -bar -nargs=* Man \ delcommand Man | \ runtime ftplugin/man.vim | \ Man <args> +endif " For editing binaries set binary @@ -957,19 +961,21 @@ nnoremap gV `[v`] " Save in insert mode inoremap <C-Z> <C-o>:w<CR> -" Config edit mappings -" Why :drop? It uses the file if it's already open. -" Also have to map c-c to no-op first, otherwise doesn't work -nnoremap <C-c> <nop> -nnoremap <leader><C-E><C-V> :DropToFoldedVimrc<CR>zXgg -nnoremap <leader><C-E><C-A> :DropToFoldedVimrc<CR>zXgg/^" Autocommands {{<CR>:noh<CR>za -nnoremap <leader><C-E><C-C> :DropToFoldedVimrc<CR>zXgg/Commands {{<CR>:noh<CR>za -nnoremap <leader><C-E><C-E> :DropToFoldedVimrc<CR>zXgg/Editor {{<CR>:noh<CR>za -nnoremap <leader><C-E><C-G> :DropToFoldedVimrc<CR>zXgg/General {{<CR>:noh<CR>za -nnoremap <leader><C-E><C-M> :DropToFoldedVimrc<CR>zXgg/Mappings {{<CR>:noh<CR>za -nnoremap <leader><C-E><C-P><C-I> :DropToFoldedVimrc<CR>zXgg/Plugins {{<CR>:noh<CR>za/Installation {{<CR>:noh<CR>za -nnoremap <leader><C-E><C-P><C-C> :DropToFoldedVimrc<CR>zXgg/Plugins {{<CR>:noh<CR>za/Config {{<CR>:noh<CR>za -nnoremap <leader><C-E><C-U> :UltiSnipsEdit<CR> +if !has('nvim') + " Config edit mappings + " Why :drop? It uses the file if it's already open. + " Also have to map c-c to no-op first, otherwise doesn't work + nnoremap <C-c> <nop> + nnoremap <leader><C-E><C-V> :DropToFoldedVimrc<CR>zXgg + nnoremap <leader><C-E><C-A> :DropToFoldedVimrc<CR>zXgg/^" Autocommands {{<CR>:noh<CR>za + nnoremap <leader><C-E><C-C> :DropToFoldedVimrc<CR>zXgg/Commands {{<CR>:noh<CR>za + nnoremap <leader><C-E><C-E> :DropToFoldedVimrc<CR>zXgg/Editor {{<CR>:noh<CR>za + nnoremap <leader><C-E><C-G> :DropToFoldedVimrc<CR>zXgg/General {{<CR>:noh<CR>za + nnoremap <leader><C-E><C-M> :DropToFoldedVimrc<CR>zXgg/Mappings {{<CR>:noh<CR>za + nnoremap <leader><C-E><C-P><C-I> :DropToFoldedVimrc<CR>zXgg/Plugins {{<CR>:noh<CR>za/Installation {{<CR>:noh<CR>za + nnoremap <leader><C-E><C-P><C-C> :DropToFoldedVimrc<CR>zXgg/Plugins {{<CR>:noh<CR>za/Config {{<CR>:noh<CR>za + nnoremap <leader><C-E><C-U> :UltiSnipsEdit<CR> +endif " Yank to clipboard nnoremap <leader>d "+d