diff --git a/vim/.config/nvim/init.lua b/vim/.config/nvim/init.lua index 39eb634..1c425a8 100644 --- a/vim/.config/nvim/init.lua +++ b/vim/.config/nvim/init.lua @@ -2,8 +2,218 @@ -- License: WTFPL -- Description: Personal neovim configuration +local cmd, fn, opt, g = vim.cmd, vim.fn, vim.opt, vim.g +local command = vim.api.nvim_create_user_command + +require('impatient') -- Should be at the top +require('filetypes').config() + +cmd [[packadd packer.nvim]] +local packer = require 'packer' +local use = packer.use + +packer.startup(function() + -- Lua + use { 'wbthomason/packer.nvim', opt = true } + use 'lewis6991/impatient.nvim' + use 'nvim-lua/plenary.nvim' + use { 'shaunsingh/nord.nvim', + config = function() + require('plugins/nord').config() + end, + setup = function() + require('plugins/nord').setup() + end + } + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', + event = { 'BufRead', 'BufNewFile' }, + config = function() + require('plugins/treesitter').config() + end + } + use 'nvim-tree/nvim-tree.lua' + use 'numtostr/comment.nvim' + use 'ellisonleao/glow.nvim' + + use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = fn.executable "make" == 1 } + use { 'nvim-telescope/telescope.nvim', + module = 'telescope', + requires = { 'nvim-lua/plenary.nvim' }, + config = function() + require('plugins/telescope').config() + end, + setup = function() + require('plugins/telescope').setup() + end + } + + use "jose-elias-alvarez/null-ls.nvim" + + + -- Vimscript + use 'junegunn/vim-easy-align' + use 'christoomey/vim-tmux-navigator' + use 'airblade/vim-gitgutter' + + -- tpope + use 'tpope/vim-surround' + use 'tpope/vim-fugitive' + use 'tpope/vim-rails' + use 'tpope/vim-rhubarb' + use 'tpope/vim-repeat' + + -- tests + use 'vim-test/vim-test' + use 'benmills/vimux' + + use 'dyng/ctrlsf.vim' + + use 'AndrewRadev/splitjoin.vim' + + use { + 'VonHeikemen/lsp-zero.nvim', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'saadparwaiz1/cmp_luasnip'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/cmp-nvim-lua'}, + + -- Snippets + {'L3MON4D3/LuaSnip'}, + {'rafamadriz/friendly-snippets'}, + } + } + + use { "dstein64/vim-startuptime", cmd = "StartupTime" } +end) + require('builtins') -require('filetypes') -require('settings') -require('plugins') +require 'plugins/gitgutter' +require 'plugins/lsp' +require 'plugins/nord' +require 'plugins/nvim-tree' +require 'plugins/comment' +require 'plugins/mason' +require 'plugins/null-ls' +require 'plugins/telescope' + +cmd('au TextYankPost * lua vim.highlight.on_yank { timeout = 250 }') + +g.ruby_host_prog = 'asdf exec neovim-ruby-host' + +opt.smartindent = true -- Autoindenting when starting a new line +opt.completeopt = {'menu', 'menuone', 'noselect'} +opt.tabstop = 2 -- Tab counts as 2 columns +opt.shiftwidth = 2 -- Numbers of spaces to (auto)indent +opt.expandtab = true -- Tabs to spaces +opt.clipboard = 'unnamedplus' -- Share clipboard with the OS +opt.number = true -- Display line numbers +opt.fillchars = { + vert = '▕', -- alternatives │ + eob = ' ', -- suppress ~ at EndOfBuffer + msgsep = '‾', + diff = '⣿', + fold = ' ', + foldopen = '▾', + foldsep = '│', + foldclose = '▸', +} +opt.synmaxcol = 500 -- Do not try to highlight lines longer than 500 characters +opt.lazyredraw = true -- Do not redraw while running macros +opt.showmatch = true -- Show matching braces +opt.matchtime = 2 -- Show matching braces for 2 tenths of second +opt.showmode = true -- Shows when you are in insert mode +opt.title = true -- Show title in console status bar +opt.laststatus = 3 -- Single status line +opt.wrap = false -- Dont wrap lines +opt.scrolloff = 5 -- Keep 5 rows on the screen when scrolling +opt.sidescrolloff = 15 -- Horizontal scrolloff +opt.visualbell = false -- No visual bell +opt.backup = false -- No backups +opt.writebackup = false -- No backups +opt.swapfile = false -- No backups +opt.mouse = 'a' -- Support mouse (for proper mouse highlight) +opt.list = true -- List mode +opt.listchars = { trail = '·', tab = '->' } +opt.timeoutlen = 1000 -- Delay for mappings +opt.ttimeoutlen = 0 -- Delay between modes +opt.shellcmdflag = '-ilc' -- Enables aliases from .bashrc in :! commands +opt.termguicolors = true -- 24-bit RGB color + + +if vim.fn.executable('rg') > 0 then + vim.o.grepprg = [[rg --glob "!.git" --no-heading --vimgrep --follow $*]] +end + +-- Use in vertical diff mode, blank lines to keep sides aligned, Ignore whitespace changes +opt.diffopt = vim.opt.diffopt + + { + 'vertical', + 'iwhite', + 'hiddenoff', + 'foldcolumn:0', + 'context:4', + 'algorithm:histogram', + 'indent-heuristic', + } + +opt.shortmess = { + t = true, -- truncate file messages at start + A = true, -- ignore annoying swap file messages + o = true, -- file-read message overwrites previous + O = true, -- file-read message overwrites previous + T = true, -- truncate non-file messages in middle + f = true, -- (file x of x) instead of just (x of x + F = true, -- Don't give file info when editing a file, NOTE: this breaks autocommand messages + s = true, + I = true, -- disable welcome message (:intro) + a = true, -- shortmess for everything + c = true, + W = true, -- Don't show [w] or written when writing +} + +-- ignore when autocompleting +opt.wildignore = { + '*.aux', '*.out', '*.toc', '*.o', '*.obj', + '*.dll', '*.jar', '*.pyc', '*.rbc', '*.class', + '*.gif', '*.ico', '*.jpg', '*.jpeg', '*.png', + '*.avi', '*.wav', '*.*~', '*~ ', '*.swp', + '.lock', '.DS_Store', 'tags.lock' +} + +-- vim-test +g['test#strategy'] = 'neovim' + +-- CtrlSF +g.ctrlsf_ackprg = 'rg' +g.ctrlsf_regex_pattern = 1 +g.ctrlsf_case_sensitive = 'smart' +g.ctrlsf_default_root = 'project' +g.ctrlsf_context = '-B 1 -A 1' +g.ctrlsf_position = 'bottom' +g.ctrlsf_winsize = '40%' +g.ctrlsf_mapping = { + next = 'n', + prev = 'N', +} + +local function trim_trailing_whitespace() + local pos = vim.api.nvim_win_get_cursor(0) + vim.cmd [[silent keepjumps keeppatterns %s/\s\+$//e]] + vim.api.nvim_win_set_cursor(0, pos) +end +command('TrimWhitespace', trim_trailing_whitespace, {}) + +-- vim.cmd("set shell='bash -l'") + require('mappings') diff --git a/vim/.config/nvim/lua/filetypes.lua b/vim/.config/nvim/lua/filetypes.lua index be9002f..73d5488 100644 --- a/vim/.config/nvim/lua/filetypes.lua +++ b/vim/.config/nvim/lua/filetypes.lua @@ -1,23 +1,22 @@ -if not vim.filetype then - return +local M = {} + +function M.config() + vim.filetype.add({ + extension = { + yml = 'yaml', + docker = 'dockerfile', + }, + filename = { + ['.gitignore'] = 'conf', + Podfile = 'ruby', + Brewfile = 'ruby', + Vagrantfile = 'ruby', + }, + pattern = { + ['*.gradle'] = 'groovy', + ['*.env.*'] = 'env', + }, + }) end --- vim.g.did_load_filetypes = 0 -- deactivate vim based filetype detection --- vim.g.do_filetype_lua = 1 -- enable lua ft detection --- --- vim.filetype.add({ --- extension = { --- -- yml = 'yaml', --- docker = 'dockerfile', --- }, --- filename = { --- ['.gitignore'] = 'conf', --- Podfile = 'ruby', --- Brewfile = 'ruby', --- Vagrantfile = 'ruby', --- }, --- pattern = { --- ['*.gradle'] = 'groovy', --- ['*.env.*'] = 'env', --- }, --- }) +return M diff --git a/vim/.config/nvim/lua/mappings.lua b/vim/.config/nvim/lua/mappings.lua index cfe116d..60257ff 100644 --- a/vim/.config/nvim/lua/mappings.lua +++ b/vim/.config/nvim/lua/mappings.lua @@ -30,6 +30,7 @@ nmap('L', '$') nmap('J', 'mzJ`z') nmap('K', '') nmap('gQ', '') +nmap('vv', ':vs') -- Tabs nmap('t', ':tabnew') @@ -48,12 +49,6 @@ map('v', 'K', ':m \'<-2gv=gv') map('v', '<', '', '>gv') --- Telescope -nmap('ff', ':lua require("telescope.builtin").find_files({ hidden = true })') --- TODO: change to Telescope --- nmap('ft', ':Files ~/Tmp') --- nmap('fo', ":call fzf#run(fzf#wrap(fzf#vim#with_preview({ 'source': 'fd . --type f --extension=md --follow --exclude .git ~/Syncthing/Obsidian/Personal' })))", { silent = true }) - -- vim-easy-align map('x', 'ga', ':EasyAlign') -- TODO: this should allow for gaip, but does not map('v', 'ga', ':EasyAlign') @@ -76,8 +71,11 @@ nmap('gb',':Git blame') nmap('a', ':A') -- test -nmap('r', ':TestFile') -nmap('R', ':TestSuite') +-- nmap('r', ':TestFile') +-- nmap('R', ':TestSuite') -- CtrlSF nmap('', 'CtrlSFPrompt') + +-- trim whitespace +nmap('W', ':TrimWhitespace') diff --git a/vim/.config/nvim/lua/plugins/cmp.lua b/vim/.config/nvim/lua/plugins/cmp.lua index 80328bd..de2feee 100644 --- a/vim/.config/nvim/lua/plugins/cmp.lua +++ b/vim/.config/nvim/lua/plugins/cmp.lua @@ -55,7 +55,7 @@ cmp.setup({ -- Set up lspconfig. local capabilities = require('cmp_nvim_lsp').default_capabilities() -require('lspconfig')['solargraph'].setup({ capabilities = capabilities }) +-- require('lspconfig')['solargraph'].setup({ capabilities = capabilities }) -- require("luasnip.loaders.from_lua").lazy_load() diff --git a/vim/.config/nvim/lua/plugins/init.lua b/vim/.config/nvim/lua/plugins/init.lua deleted file mode 100644 index ca6260d..0000000 --- a/vim/.config/nvim/lua/plugins/init.lua +++ /dev/null @@ -1,84 +0,0 @@ -local g = vim.g -- a table to access global variables - -local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' -if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.fn.execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) -end - -require('packer').startup(function() - use 'wbthomason/packer.nvim' - use 'shaunsingh/nord.nvim' - use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - use 'tpope/vim-surround' - use { 'junegunn/fzf', run = 'cd ~/.fzf && ./install --all' } - use 'junegunn/fzf.vim' - use 'junegunn/vim-easy-align' - use 'christoomey/vim-tmux-navigator' - use 'airblade/vim-gitgutter' - use 'tpope/vim-repeat' - use 'nvim-tree/nvim-tree.lua' - use 'numtostr/comment.nvim' - use 'ellisonleao/glow.nvim' - - -- Snippets - use 'L3MON4D3/LuaSnip' - use 'hrsh7th/nvim-cmp' - use 'hrsh7th/cmp-nvim-lsp' - use 'saadparwaiz1/cmp_luasnip' - use "rafamadriz/friendly-snippets" - - use 'neovim/nvim-lspconfig' - - -- tpope - use 'tpope/vim-fugitive' - use 'tpope/vim-rails' - use 'tpope/vim-rhubarb' - - -- tests - use 'vim-test/vim-test' - use 'benmills/vimux' - - use 'dyng/ctrlsf.vim' - - -- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available - use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = vim.fn.executable "make" == 1 } - use { 'nvim-telescope/telescope.nvim', branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } } - - use "williamboman/mason.nvim" - use "WhoIsSethDaniel/mason-tool-installer.nvim" - use "jose-elias-alvarez/null-ls.nvim" - use({ - "williamboman/mason-lspconfig.nvim", - requires = { - "neovim/nvim-lspconfig", - } - }) - use 'AndrewRadev/splitjoin.vim' -end) - -require 'plugins/treesitter' -require 'plugins/gitgutter' -require 'plugins/lsp' -require 'plugins/cmp' -require 'plugins/nord' -require 'plugins/nvim-tree' -require 'plugins/comment' -require 'plugins/mason' -require 'plugins/null-ls' -require 'plugins/telescope' - --- vim-test -g['test#strategy'] = 'vimux' - --- CtrlSF -g.ctrlsf_ackprg = 'rg' -g.ctrlsf_regex_pattern = 1 -g.ctrlsf_case_sensitive = 'smart' -g.ctrlsf_default_root = 'project' -g.ctrlsf_context = '-B 1 -A 1' -g.ctrlsf_position = 'bottom' -g.ctrlsf_winsize = '40%' -g.ctrlsf_mapping = { - next = 'n', - prev = 'N', -} diff --git a/vim/.config/nvim/lua/plugins/lsp.lua b/vim/.config/nvim/lua/plugins/lsp.lua index 9214df8..d21e28e 100644 --- a/vim/.config/nvim/lua/plugins/lsp.lua +++ b/vim/.config/nvim/lua/plugins/lsp.lua @@ -1,47 +1,111 @@ -require("mason-lspconfig").setup() -local lspconfig = require('lspconfig') -lspconfig.ansiblels.setup({}) -lspconfig.bashls.setup({}) -lspconfig.dockerls.setup({}) -lspconfig.gopls.setup({}) -lspconfig.jsonls.setup({}) -lspconfig.solargraph.setup({}) -lspconfig.marksman.setup({}) -lspconfig.terraformls.setup({}) -lspconfig.vimls.setup({}) -lspconfig.pylsp.setup({}) -lspconfig.yamlls.setup({}) +-- local M = {} +-- +-- function M.config() +-- local lspconfig = require('lspconfig') +-- +-- lspconfig.ansiblels.setup({}) +-- lspconfig.bashls.setup({}) +-- lspconfig.dockerls.setup({}) +-- lspconfig.gopls.setup({}) +-- lspconfig.jsonls.setup({}) +-- lspconfig.solargraph.setup({}) +-- +-- -- local capabilities = require('cmp_nvim_lsp').default_capabilities() +-- -- require('lspconfig')['solargraph'].setup({ capabilities = capabilities }) +-- +-- lspconfig.marksman.setup({}) +-- lspconfig.terraformls.setup({}) +-- lspconfig.vimls.setup({}) +-- lspconfig.pylsp.setup({}) +-- lspconfig.yamlls.setup({ +-- settings = { +-- yaml = { +-- format = { +-- enable = true, +-- singleQuote = true +-- } +-- } +-- } +-- }) +-- +-- require("mason").setup({}) +-- require("mason-lspconfig").setup() +-- require("mason-tool-installer").setup({ +-- -- https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md +-- ensure_installed = { "bash-language-server", "black", "dockerfile-language-server", +-- "isort", "json-lsp", "jsonlint", "lua-language-server", "marksman", "prettierd", +-- "python-lsp-server", "rubocop", "shfmt", "solargraph", "terraform-ls", +-- "vim-language-server", "yaml-language-server", +-- }, +-- auto_update = true, +-- run_on_start = true +-- }) +-- +-- -- Provide settings that should only apply to the "sumneko_lua" server +-- local lua_runtime_path = vim.split(package.path, ';') +-- table.insert(lua_runtime_path, "lua/?.lua") +-- table.insert(lua_runtime_path, "lua/?/init.lua") +-- table.insert(lua_runtime_path, vim.fn.stdpath('config') .. "lua/?.lua") +-- +-- lspconfig.sumneko_lua.setup({ +-- settings = { +-- Lua = { +-- runtime = { +-- -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) +-- version = 'LuaJIT', +-- -- Setup your lua path +-- path = lua_runtime_path, +-- }, +-- format = { +-- enable = true, +-- defaultConfig = { +-- keep_one_space_between_table_and_bracket = "false", +-- } +-- }, +-- diagnostics = { +-- -- Get the language server to recognize the `vim` global +-- globals = {'vim'}, +-- ["codestyle-check"] = "Any", +-- }, +-- -- Do not send telemetry data containing a randomized but unique identifier +-- telemetry = { +-- enable = false, +-- }, +-- }, +-- } +-- }) +-- end --- Provide settings that should only apply to the "sumneko_lua" server -local lua_runtime_path = vim.split(package.path, ';') -table.insert(lua_runtime_path, "lua/?.lua") -table.insert(lua_runtime_path, "lua/?/init.lua") -table.insert(lua_runtime_path, vim.fn.stdpath('config') .. "lua/?.lua") -lspconfig.sumneko_lua.setup({ - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = lua_runtime_path, - }, - format = { - enable = true, - defaultConfig = { - keep_one_space_between_table_and_bracket = "false", - } - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = {'vim'}, - ["codestyle-check"] = "Any", - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, + +local lsp = require('lsp-zero') + +-- lsp.preset('recommended') +lsp.set_preferences({ + suggest_lsp_servers = true, + setup_servers_on_start = true, + set_lsp_keymaps = true, + configure_diagnostics = true, + cmp_capabilities = true, + manage_nvim_cmp = true, + call_servers = 'local', + sign_icons = { + error = 'E', + warn = 'W', + hint = 'H', + info = 'I' } }) + +lsp.setup() + +-- should be after setup +vim.diagnostic.config({ + virtual_text = true, + signs = true, + update_in_insert = false, + underline = true, + severity_sort = false, + float = true, +}) + diff --git a/vim/.config/nvim/lua/plugins/mason.lua b/vim/.config/nvim/lua/plugins/mason.lua index d619aec..758b255 100644 --- a/vim/.config/nvim/lua/plugins/mason.lua +++ b/vim/.config/nvim/lua/plugins/mason.lua @@ -1,11 +1,11 @@ -require("mason").setup({}) -require("mason-tool-installer").setup({ - -- https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md - ensure_installed = { "bash-language-server", "black", "dockerfile-language-server", - "isort", "json-lsp", "jsonlint", "lua-language-server", "marksman", "prettierd", - "python-lsp-server", "rubocop", "shfmt", "solargraph", "terraform-ls", - "vim-language-server", "yaml-language-server", - }, - auto_update = true, - run_on_start = true -}) +-- require("mason").setup({}) +-- require("mason-tool-installer").setup({ +-- -- https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md +-- ensure_installed = { "bash-language-server", "black", "dockerfile-language-server", +-- "isort", "json-lsp", "jsonlint", "lua-language-server", "marksman", "prettierd", +-- "python-lsp-server", "rubocop", "shfmt", "solargraph", "terraform-ls", +-- "vim-language-server", "yaml-language-server", +-- }, +-- auto_update = true, +-- run_on_start = true +-- }) diff --git a/vim/.config/nvim/lua/plugins/nord.lua b/vim/.config/nvim/lua/plugins/nord.lua index 5962f04..8624f2e 100644 --- a/vim/.config/nvim/lua/plugins/nord.lua +++ b/vim/.config/nvim/lua/plugins/nord.lua @@ -1,30 +1,37 @@ --- https://github.com/shaunsingh/nord.nvim#%EF%B8%8F-configuration +local M = {} --- Make sidebars and popup menus like nvim-tree and telescope --- have a different background -vim.g.nord_contrast = true +function M.setup() + -- https://github.com/shaunsingh/nord.nvim#%EF%B8%8F-configuration --- Enable the border between verticaly split windows visable -vim.g.nord_borders = true + -- Make sidebars and popup menus like nvim-tree and telescope + -- have a different background + vim.g.nord_contrast = true --- Disable the setting of background color so that NeoVim --- can use your terminal background -vim.g.nord_disable_background = false + -- Enable the border between verticaly split windows visable + vim.g.nord_borders = true --- Set the cursorline transparent/visible -vim.g.nord_cursorline_transparent = false + -- Disable the setting of background color so that NeoVim + -- can use your terminal background + vim.g.nord_disable_background = false --- Re-enables the background of the sidebar if you disabled the background of everything -vim.g.nord_enable_sidebar_background = false + -- Set the cursorline transparent/visible + vim.g.nord_cursorline_transparent = false --- Enables/disables italics -vim.g.nord_italic = true + -- Re-enables the background of the sidebar if you disabled the background of everything + vim.g.nord_enable_sidebar_background = false --- Enables/disables colorful backgrounds when used in diff mode -vim.g.nord_uniform_diff_background = true + -- Enables/disables italics + vim.g.nord_italic = true --- Enables/disables bold -vim.g.nord_bold = false + -- Enables/disables colorful backgrounds when used in diff mode + vim.g.nord_uniform_diff_background = true --- Load the colorscheme -require('nord').set() + -- Enables/disables bold + vim.g.nord_bold = false +end + +function M.config() + require('nord').set() +end + +return M diff --git a/vim/.config/nvim/lua/plugins/telescope.lua b/vim/.config/nvim/lua/plugins/telescope.lua index 1411903..698bb70 100644 --- a/vim/.config/nvim/lua/plugins/telescope.lua +++ b/vim/.config/nvim/lua/plugins/telescope.lua @@ -1,2 +1,54 @@ --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') +local M = {} + +function M.setup() + vim.keymap.set('n', 'ff', function() require('telescope.builtin').find_files({ hidden = true }) end) + vim.keymap.set('n', 'fh', function() require('telescope.builtin').help_tags() end) + -- require('telescope.builtin').find_files({ hidden = true }) +end + +function M.config() + local telescope = require 'telescope' + + telescope.setup { + defaults = { + layout_strategy = 'vertical', + winblend = 7, + set_env = { COLORTERM = 'truecolor' }, + color_devicons = true, + scroll_strategy = 'limit', + }, + pickers = { + live_grep = { + only_sort_text = true, + path_display = { 'shorten' }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.4 }, + }, + git_files = { + path_display = {}, + hidden = true, + show_untracked = true, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65 }, + }, + }, + extensions = { + fzf = { + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', + }, + }, + } + + -- pcall(require('telescope').load_extension, 'fzf') + -- Enable telescope fzf native, if installed + telescope.load_extension('fzf') +end + +-- Telescope +-- TODO: change to Telescope +-- nmap('ft', ':Files ~/Tmp') +-- nmap('fo', ":call fzf#run(fzf#wrap(fzf#vim#with_preview({ 'source': 'fd . --type f --extension=md --follow --exclude .git ~/Syncthing/Obsidian/Personal' })))", { silent = true }) + +return M diff --git a/vim/.config/nvim/lua/plugins/treesitter.lua b/vim/.config/nvim/lua/plugins/treesitter.lua index db9561e..8238bcd 100644 --- a/vim/.config/nvim/lua/plugins/treesitter.lua +++ b/vim/.config/nvim/lua/plugins/treesitter.lua @@ -1,27 +1,32 @@ --- Tree-sitter -require('nvim-treesitter.configs').setup { - -- one of "all", "maintained" (parsers with maintainers), or a list of languages - ensure_installed = { 'bash', 'c', 'cpp', 'c_sharp', 'clojure', 'cmake', 'comment', 'commonlisp', - 'css', 'dockerfile', 'elixir', 'erlang', 'fish', 'go', 'html', 'http', 'java', - 'javascript', 'json', 'kotlin', 'latex', 'lua', 'make', 'markdown', 'perl', 'php', - 'python', 'ruby', 'rust', 'scss', 'swift', 'toml', 'tsx', 'vim', 'vue', 'yaml' }, - -- ignore_install = { 'norg' }, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - context_commentstring = { - enable = true, - enable_autocmd = false, - }, - rainbow = { - enable = true, - disable = { "html" }, - extended_mode = false, - max_file_lines = nil, - }, - indent = { enable = false }, - autopairs = { enable = true }, - autotag = { enable = true }, - incremental_selection = { enable = true }, -} +local M = {} + +function M.config() + require('nvim-treesitter.configs').setup { + -- one of "all", "maintained" (parsers with maintainers), or a list of languages + ensure_installed = { 'bash', 'c', 'cpp', 'c_sharp', 'clojure', 'cmake', 'comment', 'commonlisp', + 'css', 'dockerfile', 'elixir', 'erlang', 'fish', 'go', 'html', 'http', 'java', + 'javascript', 'json', 'kotlin', 'latex', 'lua', 'make', 'markdown', 'perl', 'php', + 'python', 'ruby', 'rust', 'scss', 'swift', 'toml', 'tsx', 'vim', 'vue', 'yaml' }, + -- ignore_install = { 'norg' }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + context_commentstring = { + enable = true, + enable_autocmd = false, + }, + rainbow = { + enable = true, + disable = { "html" }, + extended_mode = false, + max_file_lines = nil, + }, + indent = { enable = false }, + autopairs = { enable = true }, + autotag = { enable = true }, + incremental_selection = { enable = true }, + } +end + +return M diff --git a/vim/.config/nvim/lua/settings.lua b/vim/.config/nvim/lua/settings.lua deleted file mode 100644 index 7ec0f8d..0000000 --- a/vim/.config/nvim/lua/settings.lua +++ /dev/null @@ -1,92 +0,0 @@ --- TODO: --- " Conceal mostly for markdown TODO :h conceallevel --- set conceallevel=2 --- " Highlight VCS conflict markers TODO: translate to LUA --- match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' - --- local g = vim.g -- a table to access global variables -local opt = vim.opt -- to set options -local cmd = vim.cmd -- to set options - -cmd('au TextYankPost * lua vim.highlight.on_yank { timeout = 250 }') -cmd('colorscheme nord') - -opt.smartindent = true -- Autoindenting when starting a new line -opt.completeopt = {'menu', 'menuone', 'noselect'} -opt.tabstop = 2 -- Tab counts as 2 columns -opt.shiftwidth = 2 -- Numbers of spaces to (auto)indent -opt.expandtab = true -- Tabs to spaces -opt.clipboard = 'unnamedplus' -- Share clipboard with the OS -opt.number = true -- Display line numbers -opt.fillchars = { - vert = '▕', -- alternatives │ - eob = ' ', -- suppress ~ at EndOfBuffer - msgsep = '‾', - diff = '⣿', - fold = ' ', - foldopen = '▾', - foldsep = '│', - foldclose = '▸', -} -opt.synmaxcol = 500 -- Do not try to highlight lines longer than 500 characters -opt.lazyredraw = true -- Do not redraw while running macros -opt.showmatch = true -- Show matching braces -opt.matchtime = 2 -- Show matching braces for 2 tenths of second -opt.showmode = true -- Shows when you are in insert mode -opt.title = true -- Show title in console status bar -opt.laststatus = 3 -- Single status line -opt.wrap = false -- Dont wrap lines -opt.scrolloff = 5 -- Keep 5 rows on the screen when scrolling -opt.sidescrolloff = 15 -- Horizontal scrolloff -opt.visualbell = false -- No visual bell -opt.backup = false -- No backups -opt.writebackup = false -- No backups -opt.swapfile = false -- No backups -opt.mouse = 'a' -- Support mouse (for proper mouse highlight) -opt.list = true -- List mode -opt.listchars = { trail = '·', tab = '->' } -opt.timeoutlen = 1000 -- Delay for mappings -opt.ttimeoutlen = 0 -- Delay between modes -opt.shellcmdflag = '-ic' -- Enables aliases from .bashrc in :! commands -opt.termguicolors = true -- 24-bit RGB color - - -if vim.fn.executable('rg') > 0 then - vim.o.grepprg = [[rg --glob "!.git" --no-heading --vimgrep --follow $*]] -end - --- Use in vertical diff mode, blank lines to keep sides aligned, Ignore whitespace changes -opt.diffopt = vim.opt.diffopt - + { - 'vertical', - 'iwhite', - 'hiddenoff', - 'foldcolumn:0', - 'context:4', - 'algorithm:histogram', - 'indent-heuristic', - } - -opt.shortmess = { - t = true, -- truncate file messages at start - A = true, -- ignore annoying swap file messages - o = true, -- file-read message overwrites previous - O = true, -- file-read message overwrites previous - T = true, -- truncate non-file messages in middle - f = true, -- (file x of x) instead of just (x of x - F = true, -- Don't give file info when editing a file, NOTE: this breaks autocommand messages - s = true, - I = true, -- disable welcome message (:intro) - a = true, -- shortmess for everything - c = true, - W = true, -- Don't show [w] or written when writing -} - --- ignore when autocompleting -opt.wildignore = { - '*.aux', '*.out', '*.toc', '*.o', '*.obj', - '*.dll', '*.jar', '*.pyc', '*.rbc', '*.class', - '*.gif', '*.ico', '*.jpg', '*.jpeg', '*.png', - '*.avi', '*.wav', '*.*~', '*~ ', '*.swp', - '.lock', '.DS_Store', 'tags.lock' -} diff --git a/vim/.config/nvim/plugin/packer_compiled.lua b/vim/.config/nvim/plugin/packer_compiled.lua index 331dbe5..ce7bfff 100644 --- a/vim/.config/nvim/plugin/packer_compiled.lua +++ b/vim/.config/nvim/plugin/packer_compiled.lua @@ -79,11 +79,26 @@ _G.packer_plugins = { path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/LuaSnip", url = "https://github.com/L3MON4D3/LuaSnip" }, + ["cmp-buffer"] = { + loaded = true, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, ["cmp-nvim-lsp"] = { loaded = true, path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", url = "https://github.com/hrsh7th/cmp-nvim-lsp" }, + ["cmp-nvim-lua"] = { + loaded = true, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua", + url = "https://github.com/hrsh7th/cmp-nvim-lua" + }, + ["cmp-path"] = { + loaded = true, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, cmp_luasnip = { loaded = true, path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp_luasnip", @@ -104,39 +119,36 @@ _G.packer_plugins = { path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/friendly-snippets", url = "https://github.com/rafamadriz/friendly-snippets" }, - fzf = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/fzf", - url = "https://github.com/junegunn/fzf" - }, - ["fzf.vim"] = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/fzf.vim", - url = "https://github.com/junegunn/fzf.vim" - }, ["glow.nvim"] = { loaded = true, path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/glow.nvim", url = "https://github.com/ellisonleao/glow.nvim" }, + ["impatient.nvim"] = { + loaded = true, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/impatient.nvim", + url = "https://github.com/lewis6991/impatient.nvim" + }, + ["lsp-zero.nvim"] = { + loaded = true, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim", + url = "https://github.com/VonHeikemen/lsp-zero.nvim" + }, ["mason-lspconfig.nvim"] = { loaded = true, path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", url = "https://github.com/williamboman/mason-lspconfig.nvim" }, - ["mason-tool-installer.nvim"] = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/mason-tool-installer.nvim", - url = "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" - }, ["mason.nvim"] = { loaded = true, path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/mason.nvim", url = "https://github.com/williamboman/mason.nvim" }, ["nord.nvim"] = { + config = { "\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\17plugins/nord\frequire\0" }, loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/nord.nvim", + needs_bufread = false, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nord.nvim", url = "https://github.com/shaunsingh/nord.nvim" }, ["null-ls.nvim"] = { @@ -160,13 +172,17 @@ _G.packer_plugins = { url = "https://github.com/nvim-tree/nvim-tree.lua" }, ["nvim-treesitter"] = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + config = { "\27LJ\2\nA\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\23plugins/treesitter\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-treesitter", url = "https://github.com/nvim-treesitter/nvim-treesitter" }, ["packer.nvim"] = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/packer.nvim", + loaded = false, + needs_bufread = false, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/packer.nvim", url = "https://github.com/wbthomason/packer.nvim" }, ["plenary.nvim"] = { @@ -188,8 +204,11 @@ _G.packer_plugins = { url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" }, ["telescope.nvim"] = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/telescope.nvim", + config = { "\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\22plugins/telescope\frequire\0" }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/telescope.nvim", url = "https://github.com/nvim-telescope/telescope.nvim" }, ["vim-easy-align"] = { @@ -222,6 +241,14 @@ _G.packer_plugins = { path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-rhubarb", url = "https://github.com/tpope/vim-rhubarb" }, + ["vim-startuptime"] = { + commands = { "StartupTime" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/vim-startuptime", + url = "https://github.com/dstein64/vim-startuptime" + }, ["vim-surround"] = { loaded = true, path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-surround", @@ -245,11 +272,74 @@ _G.packer_plugins = { } time([[Defining packer_plugins]], false) +local module_lazy_loads = { + ["^telescope"] = "telescope.nvim" +} +local lazy_load_called = {['packer.load'] = true} +local function lazy_load_module(module_name) + local to_load = {} + if lazy_load_called[module_name] then return nil end + lazy_load_called[module_name] = true + for module_pat, plugin_name in pairs(module_lazy_loads) do + if not _G.packer_plugins[plugin_name].loaded and string.match(module_name, module_pat) then + to_load[#to_load + 1] = plugin_name + end + end + + if #to_load > 0 then + require('packer.load')(to_load, {module = module_name}, _G.packer_plugins) + local loaded_mod = package.loaded[module_name] + if loaded_mod then + return function(modname) return loaded_mod end + end + end +end + +if not vim.g.packer_custom_loader_enabled then + table.insert(package.loaders, 1, lazy_load_module) + vim.g.packer_custom_loader_enabled = true +end + +-- Setup for: telescope.nvim +time([[Setup for telescope.nvim]], true) +try_loadstring("\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\22plugins/telescope\frequire\0", "setup", "telescope.nvim") +time([[Setup for telescope.nvim]], false) +-- Setup for: nord.nvim +time([[Setup for nord.nvim]], true) +try_loadstring("\27LJ\2\n:\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\17plugins/nord\frequire\0", "setup", "nord.nvim") +time([[Setup for nord.nvim]], false) +time([[packadd for nord.nvim]], true) +vim.cmd [[packadd nord.nvim]] +time([[packadd for nord.nvim]], false) +-- Config for: nord.nvim +time([[Config for nord.nvim]], true) +try_loadstring("\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\17plugins/nord\frequire\0", "config", "nord.nvim") +time([[Config for nord.nvim]], false) -- Conditional loads time([[Conditional loading of telescope-fzf-native.nvim]], true) require("packer.load")({"telescope-fzf-native.nvim"}, {}, _G.packer_plugins) time([[Conditional loading of telescope-fzf-native.nvim]], false) +-- Command lazy-loads +time([[Defining lazy-load commands]], true) +pcall(vim.api.nvim_create_user_command, 'StartupTime', function(cmdargs) + require('packer.load')({'vim-startuptime'}, { cmd = 'StartupTime', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins) + end, + {nargs = '*', range = true, bang = true, complete = function() + require('packer.load')({'vim-startuptime'}, { cmd = 'StartupTime' }, _G.packer_plugins) + return vim.fn.getcompletion('StartupTime ', 'cmdline') + end}) +time([[Defining lazy-load commands]], false) + +vim.cmd [[augroup packer_load_aucmds]] +vim.cmd [[au!]] + -- Event lazy-loads +time([[Defining lazy-load event autocommands]], true) +vim.cmd [[au BufRead * ++once lua require("packer.load")({'nvim-treesitter'}, { event = "BufRead *" }, _G.packer_plugins)]] +vim.cmd [[au BufNewFile * ++once lua require("packer.load")({'nvim-treesitter'}, { event = "BufNewFile *" }, _G.packer_plugins)]] +time([[Defining lazy-load event autocommands]], false) +vim.cmd("augroup END") + _G._packer.inside_compile = false if _G._packer.needs_bufread == true then vim.cmd("doautocmd BufRead")