From 08422a8fe8367f10179cb27115cc40d4032e0999 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 18 May 2024 17:03:43 -0400 Subject: nvim: Switch to a lua-based config --- .gitignore | 1 + nvim/.config/nvim/after/ftplugin/lua.lua | 3 + nvim/.config/nvim/coc-settings.json | 89 ------------ nvim/.config/nvim/coc.vim | 160 ---------------------- nvim/.config/nvim/fzf.vim | 5 - nvim/.config/nvim/init.lua | 42 ++++++ nvim/.config/nvim/init.vim | 7 - nvim/.config/nvim/lua/lazy-plugins.lua | 65 +++++++++ nvim/.config/nvim/lua/lazy-plugins/ccls.lua | 24 ++++ nvim/.config/nvim/lua/lazy-plugins/completion.lua | 65 +++++++++ nvim/.config/nvim/lua/lazy-plugins/git.lua | 6 + nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua | 65 +++++++++ nvim/.config/nvim/lua/lazy-plugins/telescope.lua | 137 ++++++++++++++++++ nvim/.config/nvim/lua/lazy-plugins/treesitter.lua | 47 +++++++ nvim/.config/nvim/lua/options.lua | 59 ++++++++ nvim/.config/nvim/markdown-preview.vim | 98 ------------- nvim/.config/nvim/plugins.vim | 23 ---- nvim/.vimrc | 13 -- 18 files changed, 514 insertions(+), 395 deletions(-) create mode 100644 nvim/.config/nvim/after/ftplugin/lua.lua delete mode 100644 nvim/.config/nvim/coc-settings.json delete mode 100644 nvim/.config/nvim/coc.vim delete mode 100644 nvim/.config/nvim/fzf.vim create mode 100644 nvim/.config/nvim/init.lua delete mode 100644 nvim/.config/nvim/init.vim create mode 100644 nvim/.config/nvim/lua/lazy-plugins.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/ccls.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/completion.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/git.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/telescope.lua create mode 100644 nvim/.config/nvim/lua/lazy-plugins/treesitter.lua create mode 100644 nvim/.config/nvim/lua/options.lua delete mode 100644 nvim/.config/nvim/markdown-preview.vim delete mode 100644 nvim/.config/nvim/plugins.vim delete mode 100644 nvim/.vimrc diff --git a/.gitignore b/.gitignore index a4db410..ac71995 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ mpv/.mpv/cache/ +nvim/.config/nvim/lazy-lock.json diff --git a/nvim/.config/nvim/after/ftplugin/lua.lua b/nvim/.config/nvim/after/ftplugin/lua.lua new file mode 100644 index 0000000..cbbe688 --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/lua.lua @@ -0,0 +1,3 @@ +vim.opt_local.expandtab = true +vim.opt_local.softtabstop = 2 +vim.opt_local.shiftwidth = 2 diff --git a/nvim/.config/nvim/coc-settings.json b/nvim/.config/nvim/coc-settings.json deleted file mode 100644 index 18223ed..0000000 --- a/nvim/.config/nvim/coc-settings.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "python.linting.pylintEnabled": true, - "python.linting.flake8Enabled": false, - "python.linting.enabled": true, - "python.pythonPath": "/usr/bin/python", - - "languageserver": { - "ccls": { - "command": "ccls", - "filetypes": ["c", "cpp", "cuda", "objc", "objcpp"], - "rootPatterns": [".ccls-root", ".git/"], - "initializationOptions": { - "highlight": { - "lsRanges": true - }, - "cache": { - "directory": ".ccls-cache" - } - } - }, - "python": { - "command": "python", - "args": [ - "-mpylsp", - "-vv", - "--log-file", - "/tmp/lsp_python.log" - ], - "trace.server": "verbose", - "filetypes": [ - "python" - ], - "settings": { - "pyls": { - "enable": true, - "trace": { - "server": "verbose" - }, - "commandPath": "", - "configurationSources": [ - "pycodestyle" - ], - "plugins": { - "jedi_completion": { - "enabled": true - }, - "jedi_hover": { - "enabled": true - }, - "jedi_references": { - "enabled": true - }, - "jedi_signature_help": { - "enabled": true - }, - "jedi_symbols": { - "enabled": true, - "all_scopes": true - }, - "mccabe": { - "enabled": true, - "threshold": 15 - }, - "preload": { - "enabled": true - }, - "pycodestyle": { - "enabled": true - }, - "pydocstyle": { - "enabled": false, - "match": "(?!test_).*\\.py", - "matchDir": "[^\\.].*" - }, - "pyflakes": { - "enabled": true - }, - "rope_completion": { - "enabled": true - }, - "yapf": { - "enabled": true - } - } - } - } - } - } -} diff --git a/nvim/.config/nvim/coc.vim b/nvim/.config/nvim/coc.vim deleted file mode 100644 index abfdffd..0000000 --- a/nvim/.config/nvim/coc.vim +++ /dev/null @@ -1,160 +0,0 @@ -" May need for Vim (not Neovim) since coc.nvim calculates byte offset by count -" utf-8 byte sequence -set encoding=utf-8 -" Some servers have issues with backup files, see #649 -set nobackup -set nowritebackup - -" Having longer updatetime (default is 4000 ms = 4s) leads to noticeable -" delays and poor user experience -set updatetime=300 - -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved -set signcolumn=yes - -" Use tab for trigger completion with characters ahead and navigate -" NOTE: There's always complete item selected by default, you may want to enable -" no select by `"suggest.noselect": true` in your configuration file -" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by -" other plugin before putting this into your config -inoremap - \ coc#pum#visible() ? coc#pum#next(1) : - \ CheckBackspace() ? "\" : - \ coc#refresh() -inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" - -" Make to accept selected completion item or notify coc.nvim to format -" u breaks current undo, please make your own choice -inoremap coc#pum#visible() ? coc#pum#confirm() - \: "\u\\=coc#on_enter()\" - -function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -" Use to trigger completion -if has('nvim') - inoremap coc#refresh() -else - inoremap coc#refresh() -endif - -" Use `[g` and `]g` to navigate diagnostics -" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - -" GoTo code navigation -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -" Use K to show documentation in preview window -nnoremap K :call ShowDocumentation() - -function! ShowDocumentation() - if CocAction('hasProvider', 'hover') - call CocActionAsync('doHover') - else - call feedkeys('K', 'in') - endif -endfunction - -" Highlight the symbol and its references when holding the cursor -autocmd CursorHold * silent call CocActionAsync('highlight') - -" Symbol renaming -nmap rn (coc-rename) - -" Formatting selected code -xmap f (coc-format-selected) -nmap f (coc-format-selected) - -augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s) - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') -augroup end - -" Applying code actions to the selected code block -" Example: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) - -" Remap keys for applying code actions at the cursor position -nmap ac (coc-codeaction-cursor) -" Remap keys for apply code actions affect whole buffer -nmap as (coc-codeaction-source) -" Apply the most preferred quickfix action to fix diagnostic on the current line -nmap qf (coc-fix-current) - -" Remap keys for applying refactor code actions -nmap re (coc-codeaction-refactor) -xmap r (coc-codeaction-refactor-selected) -nmap r (coc-codeaction-refactor-selected) - -" Run the Code Lens action on the current line -nmap cl (coc-codelens-action) - -" Map function and class text objects -" NOTE: Requires 'textDocument.documentSymbol' support from the language server -xmap if (coc-funcobj-i) -omap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap af (coc-funcobj-a) -xmap ic (coc-classobj-i) -omap ic (coc-classobj-i) -xmap ac (coc-classobj-a) -omap ac (coc-classobj-a) - -" Remap and to scroll float windows/popups -if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" -endif - -" Use CTRL-S for selections ranges -" Requires 'textDocument/selectionRange' support of language server -nmap (coc-range-select) -xmap (coc-range-select) - -" Add `:Format` command to format current buffer -command! -nargs=0 Format :call CocActionAsync('format') - -" Add `:Fold` command to fold current buffer -command! -nargs=? Fold :call CocAction('fold', ) - -" Add `:OR` command for organize imports of the current buffer -command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') - -" Add (Neo)Vim's native statusline support -" NOTE: Please see `:h coc-status` for integrations with external plugins that -" provide custom statusline: lightline.vim, vim-airline -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} - -" Mappings for CoCList -" Show all diagnostics -nnoremap a :CocList diagnostics -" Manage extensions -nnoremap e :CocList extensions -" Show commands -nnoremap c :CocList commands -" Find symbol of current document -nnoremap o :CocList outline -" Search workspace symbols -nnoremap s :CocList -I symbols -" Do default action for next item -nnoremap j :CocNext -" Do default action for previous item -nnoremap k :CocPrev -" Resume latest coc list -nnoremap p :CocListResume diff --git a/nvim/.config/nvim/fzf.vim b/nvim/.config/nvim/fzf.vim deleted file mode 100644 index cef3936..0000000 --- a/nvim/.config/nvim/fzf.vim +++ /dev/null @@ -1,5 +0,0 @@ -map b :Buffers - -nnoremap gr :Rg -nnoremap gg :GFiles -nnoremap gf :Files diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..da14476 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,42 @@ +vim.g.loaded_ruby_provider = 0 +vim.g.loaded_node_provider = 0 +vim.g.loaded_perl_provider = 0 + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + -- bootstrap lazy.nvim + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", + lazypath }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +require("lazy").setup({ + spec = { + { import = "lazy-plugins" }, + }, + defaults = { + -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. + -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + lazy = false, + version = "*", -- try installing the latest stable version for plugins that support semver + }, + install = { colorscheme = { "tokyonight", "habamax" } }, + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) + +require('options') diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim deleted file mode 100644 index 1c4cc70..0000000 --- a/nvim/.config/nvim/init.vim +++ /dev/null @@ -1,7 +0,0 @@ -set runtimepath^=~/.vim runtimepath+=~/.vim/after -let &packpath = &runtimepath -source ~/.vimrc -source ~/.config/nvim/coc.vim -source ~/.config/nvim/fzf.vim -source ~/.config/nvim/markdown-preview.vim -source ~/.config/nvim/plugins.vim diff --git a/nvim/.config/nvim/lua/lazy-plugins.lua b/nvim/.config/nvim/lua/lazy-plugins.lua new file mode 100644 index 0000000..602146f --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins.lua @@ -0,0 +1,65 @@ +vim.g.table_mode_corner = "|" + +-- Put simply configured plugins here. +return { + { "lukas-reineke/indent-blankline.nvim", version = "v3.5.4", main = "ibl", opts = {} }, + { + "Mofiqul/adwaita.nvim", + lazy = false, + priority = 1000, + config = function() + vim.g.adwaita_darker = true + vim.cmd("colorscheme adwaita") + end + }, + { "norcalli/nvim-terminal.lua", opts = {} }, + "dhruvasagar/vim-table-mode", + { + "ibhagwan/fzf-lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, + { + "kylechui/nvim-surround", + event = "VeryLazy", + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end + }, + "tpope/vim-eunuch", + "vim-scripts/git_patch_tags.vim", + { + "nvim-lualine/lualine.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons" + }, + }, + { + 'numToStr/Comment.nvim', + opts = { + -- add any options here + }, + lazy = false, + }, + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = true + }, + { + "rktjmp/paperplanes.nvim", + opts = { + register = "+", + provider = "sprunge.us", + provider_options = { insecure = true, }, + notifier = vim.notify or print, + }, + }, + { + "j-hui/fidget.nvim", + tag = "legacy", + event = "LspAttach", + opts = {}, + }, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/ccls.lua b/nvim/.config/nvim/lua/lazy-plugins/ccls.lua new file mode 100644 index 0000000..1ae961c --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/ccls.lua @@ -0,0 +1,24 @@ +local M = { + "ranjithshegde/ccls.nvim", + dependencies = { "neovim/nvim-lspconfig" }, +} + +M.config = function() + local ccls = require("ccls") + ccls.setup({ + lsp = { + -- check :help vim.lsp.start for config options + server = { + name = "ccls", --String name + cmd = {"/usr/bin/ccls"}, -- point to your binary, has to be a table + args = {--[[Any args table]] }, + offset_encoding = "utf-32", -- default value set by plugin + root_dir = vim.fs.dirname(vim.fs.find({ "compile_commands.json", ".git" }, { upward = true })[1]), -- or some other function that returns a string + --on_attach = your_func, + --capabilites = your_table/func + }, + }, + }) +end + +return M diff --git a/nvim/.config/nvim/lua/lazy-plugins/completion.lua b/nvim/.config/nvim/lua/lazy-plugins/completion.lua new file mode 100644 index 0000000..01fc0d8 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/completion.lua @@ -0,0 +1,65 @@ +local M = { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", + { + "L3MON4D3/LuaSnip", + tag = "v2.1.1", + }, + }, +} + +M.config = function() + local cmp = require("cmp") + vim.opt.completeopt = { "menu", "menuone", "noselect" } + + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({}), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "luasnip" }, -- For luasnip users. + -- { name = "orgmode" }, + }, { + { name = "buffer" }, + { name = "path" }, + }), + }) + + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) +end + +return M diff --git a/nvim/.config/nvim/lua/lazy-plugins/git.lua b/nvim/.config/nvim/lua/lazy-plugins/git.lua new file mode 100644 index 0000000..dfd6e63 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/git.lua @@ -0,0 +1,6 @@ +return { + { + "tpope/vim-fugitive", + cmd = "Git", + } +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua b/nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua new file mode 100644 index 0000000..75537c0 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua @@ -0,0 +1,65 @@ +return { + { + "neovim/nvim-lspconfig", + name = "lspconfig", + lazy = false, + dependencies = { + { "williamboman/mason-lspconfig.nvim", name = "mason-lspconfig" }, + { "williamboman/mason.nvim", name = "mason" }, + }, + config = function() + local lspconfig = require("lspconfig") + local mason = require("mason") + local mason_lspconfig = require("mason-lspconfig") + local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) + local servers = { "lua_ls", "marksman", "pylsp" } +-- local options = { noremap = true, silent = true } + + mason.setup({}) + + mason_lspconfig.setup({ ensure_installed = servers }) + + mason_lspconfig.setup_handlers({ + function(server_name) + lspconfig[server_name].setup({ + capabilities = capabilities, + }) + end, + ["lua_ls"] = function() + lspconfig.lua_ls.setup { + settings = { + Lua = { + runtime = { version = 'LuaJIT', }, + diagnostics = { + globals = { + 'vim', + 'require', + }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + telemetry = { enable = false }, + }, + }, + } + end, + ["pylsp"] = function() + lspconfig.pylsp.setup { + settings = { + pylsp = { + plugins = { + pycodestyle = { + ignore = {'W391'}, + maxLineLength = 100, + } + }, + }, + }, + } + end + }) + end + }, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/telescope.lua b/nvim/.config/nvim/lua/lazy-plugins/telescope.lua new file mode 100644 index 0000000..cf3f151 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/telescope.lua @@ -0,0 +1,137 @@ +return { + { + "nvim-telescope/telescope.nvim", + lazy = true, + dependencies = { + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }, + "nvim-tree/nvim-web-devicons", + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-symbols.nvim", + }, + cmd = "Telescope", + keys = { + { "gr", function() require('telescope.builtin').lsp_references() end }, + { "fr", function() require('telescope.builtin').lsp_references() end }, + { "ff", "Telescope find_files" }, + { "fo", "Telescope oldfiles" }, + { "fg", "Telescope live_grep" }, + { "fb", "Telescope buffers" }, + { "fh", "Telescope help_tags" }, + { "fs", "Telescope grep_string" }, + }, + config = function() + local always_ignore_these = { + "yarn.lock", -- nodejs + "package%-lock.json", -- nodejs + "node_modules/.*", -- nodejs + "vendor/*", -- golang + "%.git/.*", + "%.png", + "%.jpeg", + "%.jpg", + "%.ico", + "%.webp", + "%.avif", + "%.heic", + "%.mp3", + "%.mp4", + "%.mkv", + "%.mov", + "%.wav", + "%.flv", + "%.avi", + "%.webm", + "%.db", + } + + require("telescope").setup({ + defaults = { + mappings = { + i = { + -- don't go into normal mode, just close + [""] = require("telescope.actions").close, + -- scroll the list with and + [""] = require("telescope.actions").move_selection_next, + [""] = require("telescope.actions").move_selection_previous, + -- move the preview window up and down + [""] = require("telescope.actions").preview_scrolling_up, + [""] = require("telescope.actions").preview_scrolling_down, + }, + }, + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + "--trim", + }, + layout_strategy = "flex", + layout_config = { + prompt_position = "top", + horizontal = { + mirror = true, + preview_cutoff = 100, + preview_width = 0.5, + }, + vertical = { + mirror = true, + preview_cutoff = 0.4, + }, + flex = { + flip_columns = 110, + }, + height = 0.94, + width = 0.86, + }, + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "ascending", + file_sorter = require("telescope.sorters").get_fuzzy_file, + file_ignore_patterns = always_ignore_these, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + path_display = { "truncate" }, + winblend = 0, + border = {}, + borderchars = { + "─", + "│", + "─", + "│", + "╭", + "╮", + "╯", + "╰", + }, + color_devicons = true, + use_less = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + }, + pickers = { + find_files = { + find_command = { "fd", "--type", "f", "--strip-cwd-prefix" }, + hidden = true, + }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + }, + }) + end + }, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/treesitter.lua b/nvim/.config/nvim/lua/lazy-plugins/treesitter.lua new file mode 100644 index 0000000..c1b9cf2 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/treesitter.lua @@ -0,0 +1,47 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = function() + pcall(require("nvim-treesitter.install").update({ with_sync = true })) + end, + event = "BufReadPost", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + opts = { + highlight = { enable = true }, + indent = { enable = true }, + context_commentstring = { enable = true, enable_autocmd = false }, + ensure_installed = { + "bash", + "c", + "cmake", + "cpp", + "dockerfile", + "git_config", + "gitattributes", + "gitcommit", + "gitignore", + "go", + "ini", + "javascript", + "jsdoc", + "json", + "json5", + "lua", + "make", + "markdown", + "meson", + "ninja", + "python", + "rust", + "toml", + "vim", + "yaml", + }, + }, + config = function(plugin, opts) + require("nvim-treesitter.configs").setup(opts) + end, + }, +} diff --git a/nvim/.config/nvim/lua/options.lua b/nvim/.config/nvim/lua/options.lua new file mode 100644 index 0000000..681fa71 --- /dev/null +++ b/nvim/.config/nvim/lua/options.lua @@ -0,0 +1,59 @@ +-- show line numbers +vim.opt.number = true +vim.opt.relativenumber = true + +-- Color the colum to the right of the limit +vim.opt.colorcolumn = "+1" + +-- Options for completions. Move this at some point. +-- have a fixed column for the diagnostics to appear in this removes the jitter when warnings/errors flow in +vim.wo.signcolumn = "yes" +vim.cmd([[autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })]]) + +--Set completeopt to have a better completion experience +-- :help completeopt +-- menuone: popup even when there's only one match +-- noinsert: Do not insert text until a selection is made +-- noselect: Do not select, force to select one from the menu +-- shortness: avoid showing extra messages when using completion +-- updatetime: set updatetime for CursorHold +vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} +vim.opt.shortmess = vim.opt.shortmess + { c = true} +vim.api.nvim_set_option('updatetime', 300) + +vim.keymap.set('n', 'gr', ':FzfLua grep_project', { noremap = true, silent = true }) +vim.keymap.set('n', 'gg', ':FzfLua git_files', { noremap = true, silent = true }) +vim.keymap.set('n', 'gf', ':FzfLua files', { noremap = true, silent = true }) + +vim.keymap.set('n', 'e', vim.diagnostic.open_float) +vim.keymap.set('n', 'E', vim.diagnostic.setloclist) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local options = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, options) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, options) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, options) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, options) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, options) + vim.keymap.set('n', 'c', vim.lsp.buf.incoming_calls, options) + vim.keymap.set({'n', 'v'}, 'ca', vim.lsp.buf.code_action, options) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, options) + vim.keymap.set('n', 'g', vim.lsp.buf.references, options) + vim.keymap.set('n', 'f', function () + vim.lsp.buf.format{ async = true } + end, options) + end, +}) + +vim.o.termguicolors = true diff --git a/nvim/.config/nvim/markdown-preview.vim b/nvim/.config/nvim/markdown-preview.vim deleted file mode 100644 index e83515e..0000000 --- a/nvim/.config/nvim/markdown-preview.vim +++ /dev/null @@ -1,98 +0,0 @@ -" set to 1, nvim will open the preview window after entering the markdown buffer -" default: 0 -let g:mkdp_auto_start = 0 - -" set to 1, the nvim will auto close current preview window when change -" from markdown buffer to another buffer -" default: 1 -let g:mkdp_auto_close = 1 - -" set to 1, the vim will refresh markdown when save the buffer or -" leave from insert mode, default 0 is auto refresh markdown as you edit or -" move the cursor -" default: 0 -let g:mkdp_refresh_slow = 0 - -" set to 1, the MarkdownPreview command can be use for all files, -" by default it can be use in markdown file -" default: 0 -let g:mkdp_command_for_global = 0 - -" set to 1, preview server available to others in your network -" by default, the server listens on localhost (127.0.0.1) -" default: 0 -let g:mkdp_open_to_the_world = 0 - -" use custom IP to open preview page -" useful when you work in remote vim and preview on local browser -" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9 -" default empty -let g:mkdp_open_ip = '' - -" specify browser to open preview page -" for path with space -" valid: `/path/with\ space/xxx` -" invalid: `/path/with\\ space/xxx` -" default: '' -let g:mkdp_browser = '/usr/bin/firefox' - -" set to 1, echo preview page url in command line when open preview page -" default is 0 -let g:mkdp_echo_preview_url = 0 - -" a custom vim function name to open preview page -" this function will receive url as param -" default is empty -let g:mkdp_browserfunc = '' - -" options for markdown render -" mkit: markdown-it options for render -" katex: katex options for math -" uml: markdown-it-plantuml options -" maid: mermaid options -" disable_sync_scroll: if disable sync scroll, default 0 -" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle' -" middle: mean the cursor position alway show at the middle of the preview page -" top: mean the vim top viewport alway show at the top of the preview page -" relative: mean the cursor position alway show at the relative positon of the preview page -" hide_yaml_meta: if hide yaml metadata, default is 1 -" sequence_diagrams: js-sequence-diagrams options -" content_editable: if enable content editable for preview page, default: v:false -" disable_filename: if disable filename header for preview page, default: 0 -let g:mkdp_preview_options = { - \ 'mkit': {}, - \ 'katex': {}, - \ 'uml': {}, - \ 'maid': {}, - \ 'disable_sync_scroll': 0, - \ 'sync_scroll_type': 'middle', - \ 'hide_yaml_meta': 1, - \ 'sequence_diagrams': {}, - \ 'flowchart_diagrams': {}, - \ 'content_editable': v:false, - \ 'disable_filename': 0, - \ 'toc': {} - \ } - -" use a custom markdown style must be absolute path -" like '/Users/username/markdown.css' or expand('~/markdown.css') -let g:mkdp_markdown_css = '' - -" use a custom highlight style must absolute path -" like '/Users/username/highlight.css' or expand('~/highlight.css') -let g:mkdp_highlight_css = '' - -" use a custom port to start server or empty for random -let g:mkdp_port = '' - -" preview page title -" ${name} will be replace with the file name -let g:mkdp_page_title = '「${name}」' - -" recognized filetypes -" these filetypes will have MarkdownPreview... commands -let g:mkdp_filetypes = ['markdown'] - -" set default theme (dark or light) -" By default the theme is define according to the preferences of the system -let g:mkdp_theme = 'dark' diff --git a/nvim/.config/nvim/plugins.vim b/nvim/.config/nvim/plugins.vim deleted file mode 100644 index 779e970..0000000 --- a/nvim/.config/nvim/plugins.vim +++ /dev/null @@ -1,23 +0,0 @@ -call plug#begin() -Plug 'airblade/vim-rooter' -Plug 'bogado/file-line' -Plug 'editorconfig/editorconfig-vim' -Plug 'google/vim-searchindex' -Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } -Plug 'igankevich/mesonic' -Plug 'jackguo380/vim-lsp-cxx-highlight' -Plug 'jamessan/vim-gnupg' -Plug 'javier-lopez/sprunge.vim' -Plug 'junegunn/fzf.vim' -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'preservim/nerdcommenter' -Plug 'preservim/nerdtree' -Plug 'saltstack/salt-vim' -Plug 'tmsvg/pear-tree' -Plug 'tpope/vim-eunuch' -Plug 'tpope/vim-fugitive' -Plug 'tpope/vim-surround' -Plug 'vim-scripts/AnsiEsc.vim' -Plug 'vim-scripts/git_patch_tags.vim' -Plug 'Yggdroot/indentLine' -call plug#end() diff --git a/nvim/.vimrc b/nvim/.vimrc deleted file mode 100644 index 3aa7046..0000000 --- a/nvim/.vimrc +++ /dev/null @@ -1,13 +0,0 @@ -autocmd BufNewFile,BufRead *.frag,*.vert,*.fp,*.vp,*.glsl,*.shader_test set syntax=glsl - -autocmd BufNewFile,BufRead /home/mattst88/projects/mesa/* set expandtab tabstop=8 softtabstop=3 shiftwidth=3 -autocmd BufNewFile,BufRead /home/mattst88/projects/piglit/* set noexpandtab tabstop=8 softtabstop=8 shiftwidth=8 -autocmd BufNewFile,BufRead Makefile* set noexpandtab tabstop=8 softtabstop=8 shiftwidth=8 -autocmd BufNewFile,BufRead *.mk set noexpandtab tabstop=8 softtabstop=8 shiftwidth=8 - -autocmd BufNewFile,BufRead *.py set tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab - -set bg=dark -set modeline -set number relativenumber -set colorcolumn=+0 -- cgit v1.2.3