diff options
author | Matt Turner <mattst88@gmail.com> | 2024-05-18 17:03:43 -0400 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2024-05-18 17:13:39 -0400 |
commit | 08422a8fe8367f10179cb27115cc40d4032e0999 (patch) | |
tree | 2c0bab7f4dbea1ce4337e11f2b6a56dae75210db | |
parent | 7e96b2e1ae4a22f300a0b08c6dfacaa862e16742 (diff) |
nvim: Switch to a lua-based config
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | nvim/.config/nvim/after/ftplugin/lua.lua | 3 | ||||
-rw-r--r-- | nvim/.config/nvim/coc-settings.json | 89 | ||||
-rw-r--r-- | nvim/.config/nvim/coc.vim | 160 | ||||
-rw-r--r-- | nvim/.config/nvim/fzf.vim | 5 | ||||
-rw-r--r-- | nvim/.config/nvim/init.lua | 42 | ||||
-rw-r--r-- | nvim/.config/nvim/init.vim | 7 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins.lua | 65 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/ccls.lua | 24 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/completion.lua | 65 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/git.lua | 6 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua | 65 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/telescope.lua | 137 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/treesitter.lua | 47 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/options.lua | 59 | ||||
-rw-r--r-- | nvim/.config/nvim/markdown-preview.vim | 98 | ||||
-rw-r--r-- | nvim/.config/nvim/plugins.vim | 23 | ||||
-rw-r--r-- | nvim/.vimrc | 13 |
18 files changed, 514 insertions, 395 deletions
@@ -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 <tab>' to make sure tab is not mapped by -" other plugin before putting this into your config -inoremap <silent><expr> <TAB> - \ coc#pum#visible() ? coc#pum#next(1) : - \ CheckBackspace() ? "\<Tab>" : - \ coc#refresh() -inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" - -" Make <CR> to accept selected completion item or notify coc.nvim to format -" <C-g>u breaks current undo, please make your own choice -inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() - \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" - -function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -" Use <c-space> to trigger completion -if has('nvim') - inoremap <silent><expr> <c-space> coc#refresh() -else - inoremap <silent><expr> <c-@> coc#refresh() -endif - -" Use `[g` and `]g` to navigate diagnostics -" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list -nmap <silent> [g <Plug>(coc-diagnostic-prev) -nmap <silent> ]g <Plug>(coc-diagnostic-next) - -" GoTo code navigation -nmap <silent> gd <Plug>(coc-definition) -nmap <silent> gy <Plug>(coc-type-definition) -nmap <silent> gi <Plug>(coc-implementation) -nmap <silent> gr <Plug>(coc-references) - -" Use K to show documentation in preview window -nnoremap <silent> K :call ShowDocumentation()<CR> - -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 <leader>rn <Plug>(coc-rename) - -" Formatting selected code -xmap <leader>f <Plug>(coc-format-selected) -nmap <leader>f <Plug>(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: `<leader>aap` for current paragraph -xmap <leader>a <Plug>(coc-codeaction-selected) -nmap <leader>a <Plug>(coc-codeaction-selected) - -" Remap keys for applying code actions at the cursor position -nmap <leader>ac <Plug>(coc-codeaction-cursor) -" Remap keys for apply code actions affect whole buffer -nmap <leader>as <Plug>(coc-codeaction-source) -" Apply the most preferred quickfix action to fix diagnostic on the current line -nmap <leader>qf <Plug>(coc-fix-current) - -" Remap keys for applying refactor code actions -nmap <silent> <leader>re <Plug>(coc-codeaction-refactor) -xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) -nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) - -" Run the Code Lens action on the current line -nmap <leader>cl <Plug>(coc-codelens-action) - -" Map function and class text objects -" NOTE: Requires 'textDocument.documentSymbol' support from the language server -xmap if <Plug>(coc-funcobj-i) -omap if <Plug>(coc-funcobj-i) -xmap af <Plug>(coc-funcobj-a) -omap af <Plug>(coc-funcobj-a) -xmap ic <Plug>(coc-classobj-i) -omap ic <Plug>(coc-classobj-i) -xmap ac <Plug>(coc-classobj-a) -omap ac <Plug>(coc-classobj-a) - -" Remap <C-f> and <C-b> to scroll float windows/popups -if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" - nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" - inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" - inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" - vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" - vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" -endif - -" Use CTRL-S for selections ranges -" Requires 'textDocument/selectionRange' support of language server -nmap <silent> <C-s> <Plug>(coc-range-select) -xmap <silent> <C-s> <Plug>(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', <f-args>) - -" 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 <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> -" Manage extensions -nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> -" Show commands -nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> -" Find symbol of current document -nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> -" Search workspace symbols -nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> -" Do default action for next item -nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> -" Do default action for previous item -nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> -" Resume latest coc list -nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR> 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 <leader>b :Buffers<cr> - -nnoremap <silent> <Leader>gr :Rg<CR> -nnoremap <silent> <Leader>gg :GFiles<CR> -nnoremap <silent> <Leader>gf :Files<CR> 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({ + ["<Tab>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + ["<S-Tab>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + ["<C-e>"] = cmp.mapping.abort(), + ["<CR>"] = cmp.mapping.confirm({}), + ["<S-CR>"] = 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 }, + { "<leader>fr", function() require('telescope.builtin').lsp_references() end }, + { "<leader>ff", "<cmd>Telescope find_files<cr>" }, + { "<leader>fo", "<cmd>Telescope oldfiles<cr>" }, + { "<leader>fg", "<cmd>Telescope live_grep<cr>" }, + { "<leader>fb", "<cmd>Telescope buffers<cr>" }, + { "<leader>fh", "<cmd>Telescope help_tags<cr>" }, + { "<leader>fs", "<cmd>Telescope grep_string<cr>" }, + }, + 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 + ["<Esc>"] = require("telescope.actions").close, + -- scroll the list with <c-j> and <c-k> + ["<C-j>"] = require("telescope.actions").move_selection_next, + ["<C-k>"] = require("telescope.actions").move_selection_previous, + -- move the preview window up and down + ["<C-u>"] = require("telescope.actions").preview_scrolling_up, + ["<C-d>"] = 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', '<Leader>gr', ':FzfLua grep_project<cr>', { noremap = true, silent = true }) +vim.keymap.set('n', '<Leader>gg', ':FzfLua git_files<cr>', { noremap = true, silent = true }) +vim.keymap.set('n', '<Leader>gf', ':FzfLua files<cr>', { noremap = true, silent = true }) + +vim.keymap.set('n', '<Leader>e', vim.diagnostic.open_float) +vim.keymap.set('n', '<Leader>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 <c-x><c-o> + 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', '<C-k>', vim.lsp.buf.signature_help, options) + vim.keymap.set('n', '<c-\\>c', vim.lsp.buf.incoming_calls, options) + vim.keymap.set({'n', 'v'}, '<Leader>ca', vim.lsp.buf.code_action, options) + vim.keymap.set('n', '<Leader>rn', vim.lsp.buf.rename, options) + vim.keymap.set('n', '<c-\\>g', vim.lsp.buf.references, options) + vim.keymap.set('n', '<space>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 |