From c7e652d93a5c764f81afc1a353c8917c88affbc9 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Sat, 8 Apr 2023 22:10:52 +0200 Subject: [PATCH] Completely redid neovim configuration, based on kickstart.nvim --- nvim/.config/nvim/.gitignore | 4 + nvim/.config/nvim/LICENSE.md | 19 + nvim/.config/nvim/README.md | 130 +++++ nvim/.config/nvim/Session.vim | 122 ++++ nvim/.config/nvim/init.lua | 534 ++++++++++++++++++ nvim/.config/nvim/init.vim | 107 ---- nvim/.config/nvim/lazy-lock.json | 47 ++ nvim/.config/nvim/lua/autocmds.lua | 34 ++ .../nvim/lua/constant/symbols/diagnostic.lua | 16 + .../nvim/lua/constant/symbols/file.lua | 6 + .../nvim/lua/constant/symbols/fold.lua | 6 + .../.config/nvim/lua/constant/symbols/git.lua | 15 + .../nvim/lua/constant/symbols/init.lua | 6 + nvim/.config/nvim/lua/keymaps.lua | 19 + nvim/.config/nvim/lua/options.lua | 53 ++ nvim/.config/nvim/lua/plugins.lua | 287 ---------- nvim/.config/nvim/lua/plugins/autopairs.lua | 7 + nvim/.config/nvim/lua/plugins/autotag.lua | 6 + nvim/.config/nvim/lua/plugins/bufdel.lua | 13 + nvim/.config/nvim/lua/plugins/bufferline.lua | 61 ++ nvim/.config/nvim/lua/plugins/colorizer.lua | 29 + nvim/.config/nvim/lua/plugins/comment.lua | 6 + .../.config/nvim/lua/plugins/guess-indent.lua | 12 + nvim/.config/nvim/lua/plugins/neotree.lua | 65 +++ nvim/.config/nvim/lua/plugins/null-ls.lua | 12 + nvim/.config/nvim/lua/plugins/surround.lua | 7 + .../nvim/lua/plugins/symbols-outline.lua | 10 + .../nvim/lua/plugins/tmux-navigation.lua | 18 + .../nvim/lua/plugins/todo-comments.lua | 58 ++ nvim/.config/nvim/lua/plugins/treesj.lua | 13 + nvim/.config/nvim/lua/plugins/trouble.lua | 18 + nvim/.config/nvim/lua/plugins/undotree.lua | 7 + nvim/.config/nvim/lua/plugins/whitespace.lua | 19 + nvim/.config/nvim/lua/themes/gruvbox.lua | 23 + nvim/.config/nvim/plugin/packer_compiled.lua | 257 --------- nvim/.config/nvim/syntax/c.vim | 491 ---------------- nvim/.config/nvim/syntax/cpp.vim | 119 ---- nvim/.config/nvim/syntax/lang.vim | 39 -- 38 files changed, 1395 insertions(+), 1300 deletions(-) create mode 100644 nvim/.config/nvim/.gitignore create mode 100644 nvim/.config/nvim/LICENSE.md create mode 100644 nvim/.config/nvim/README.md create mode 100644 nvim/.config/nvim/Session.vim create mode 100644 nvim/.config/nvim/init.lua delete mode 100644 nvim/.config/nvim/init.vim create mode 100644 nvim/.config/nvim/lazy-lock.json create mode 100644 nvim/.config/nvim/lua/autocmds.lua create mode 100644 nvim/.config/nvim/lua/constant/symbols/diagnostic.lua create mode 100644 nvim/.config/nvim/lua/constant/symbols/file.lua create mode 100644 nvim/.config/nvim/lua/constant/symbols/fold.lua create mode 100644 nvim/.config/nvim/lua/constant/symbols/git.lua create mode 100644 nvim/.config/nvim/lua/constant/symbols/init.lua create mode 100644 nvim/.config/nvim/lua/keymaps.lua create mode 100644 nvim/.config/nvim/lua/options.lua delete mode 100644 nvim/.config/nvim/lua/plugins.lua create mode 100644 nvim/.config/nvim/lua/plugins/autopairs.lua create mode 100644 nvim/.config/nvim/lua/plugins/autotag.lua create mode 100644 nvim/.config/nvim/lua/plugins/bufdel.lua create mode 100644 nvim/.config/nvim/lua/plugins/bufferline.lua create mode 100644 nvim/.config/nvim/lua/plugins/colorizer.lua create mode 100644 nvim/.config/nvim/lua/plugins/comment.lua create mode 100644 nvim/.config/nvim/lua/plugins/guess-indent.lua create mode 100644 nvim/.config/nvim/lua/plugins/neotree.lua create mode 100644 nvim/.config/nvim/lua/plugins/null-ls.lua create mode 100644 nvim/.config/nvim/lua/plugins/surround.lua create mode 100644 nvim/.config/nvim/lua/plugins/symbols-outline.lua create mode 100644 nvim/.config/nvim/lua/plugins/tmux-navigation.lua create mode 100644 nvim/.config/nvim/lua/plugins/todo-comments.lua create mode 100644 nvim/.config/nvim/lua/plugins/treesj.lua create mode 100644 nvim/.config/nvim/lua/plugins/trouble.lua create mode 100644 nvim/.config/nvim/lua/plugins/undotree.lua create mode 100644 nvim/.config/nvim/lua/plugins/whitespace.lua create mode 100644 nvim/.config/nvim/lua/themes/gruvbox.lua delete mode 100644 nvim/.config/nvim/plugin/packer_compiled.lua delete mode 100644 nvim/.config/nvim/syntax/c.vim delete mode 100644 nvim/.config/nvim/syntax/cpp.vim delete mode 100644 nvim/.config/nvim/syntax/lang.vim diff --git a/nvim/.config/nvim/.gitignore b/nvim/.config/nvim/.gitignore new file mode 100644 index 0000000..d699e1d --- /dev/null +++ b/nvim/.config/nvim/.gitignore @@ -0,0 +1,4 @@ +tags +test.sh +.luarc.json +nvim diff --git a/nvim/.config/nvim/LICENSE.md b/nvim/.config/nvim/LICENSE.md new file mode 100644 index 0000000..9cf1062 --- /dev/null +++ b/nvim/.config/nvim/LICENSE.md @@ -0,0 +1,19 @@ +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/nvim/.config/nvim/README.md b/nvim/.config/nvim/README.md new file mode 100644 index 0000000..ce72ebb --- /dev/null +++ b/nvim/.config/nvim/README.md @@ -0,0 +1,130 @@ +# kickstart.nvim + +### Introduction + +A starting point for Neovim that is: + +* Small +* Single-file (with examples of moving to multi-file) +* Documented +* Modular + +This repo is meant to be used as by **YOU** to begin your Neovim journey; remove the things you don't use and add what you miss. + +Distribution Alternatives: +- [LazyVim](https://www.lazyvim.org/): A delightful distribution maintained by @folke (the author of lazy.nvim, the package manager used here) + +### Installation + +Kickstart.nvim targets *only* the latest ['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest ['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. If you are experiencing issues, please make sure you have the latest versions. + +* Backup your previous configuration +* (Recommended) Fork this repo (so that you have your own copy that you can modify). +* Clone the kickstart repo into `$HOME/.config/nvim/` (Linux/Mac) or `~/AppData/Local/nvim/` (Windows) + * If you don't want to include it as a git repo, you can just clone it and then move the files to this location +* Start Neovim (`nvim`) and allow `lazy.nvim` to complete installation. +* Restart Neovim +* **You're ready to go!** + +Additional system requirements: +- Make sure to review the readmes of the plugins if you are experiencing errors. In particular: + - [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers. +- See as well [Windows Installation](#Windows-Installation) + +### Configuration And Extension + +* Inside of your fork, feel free to modify any file you like! It's your fork! +* Then there are two primary configuration options available: + * Include the `lua/kickstart/plugins/*` files in your configuration. + * Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim` + * NOTE: To enable this, you need to uncomment `{ import = 'custom.plugins' }` in your `init.lua` + +You can also merge updates/changes from the repo back into your fork, to keep up-to-date with any changes for the default configuration + +#### Example: Adding an autopairs plugin + +In the file: `lua/custom/plugins/autopairs.lua`, add: + +```lua +-- File: lua/custom/plugins/autopairs.lua + +return { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup {} + end, +} +``` + + +This will automatically install `nvim-autopairs` and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). + +#### Example: Adding a file tree plugin + +In the file: `lua/custom/plugins/filetree.lua`, add: + +```lua +-- Unless you are still migrating, remove the deprecated commands from v1.x +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + +return { + "nvim-neo-tree/neo-tree.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function () + require('neo-tree').setup {} + end, +} +``` + +This will install the tree plugin and add the command `:NeoTree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. + +#### Example: Adding a file to change default options + +To change default options, you can add a file in the `/after/plugin/` folder (see `:help load-plugins`) to include your own options, keymaps, autogroups, and more. The following is an example `defaults.lua` file (located at `$HOME/.config/nvim/after/plugin/defaults.lua`). + +```lua +vim.opt.relativenumber = true + +vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) +``` + +### Contribution + +Pull-requests are welcome. The goal of this repo is not to create a Neovim configuration framework, but to offer a starting template that shows, by example, available features in Neovim. Some things that will not be included: + +* Custom language server configuration (null-ls templates) +* Theming beyond a default colorscheme necessary for LSP highlight groups + +Each PR, especially those which increase the line count, should have a description as to why the PR is necessary. + +### FAQ + +* What should I do if I already have a pre-existing neovim configuration? + * You should back it up, then delete all files associated with it. + * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` + * You may also want to look at the [migration guide for lazy.nvim](https://github.com/folke/lazy.nvim#-migration-guide) +* What if I want to "uninstall" this configuration: + * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information +* Are there any cool videos about this plugin? + * Current iteration of kickstart (coming soon) + * Here is one about the previous iteration of kickstart: [video introduction to Kickstart.nvim](https://youtu.be/stqUbv-5u2s). + +### Windows Installation + +Installation may require installing build tools, and updating the run command for `telescope-fzf-native` + +See `telescope-fzf-native` documention for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) + +This requires: + +- Install CMake, and the Microsoft C++ Build Tools on Windows + +```lua +{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } +``` + diff --git a/nvim/.config/nvim/Session.vim b/nvim/.config/nvim/Session.vim new file mode 100644 index 0000000..02bcc01 --- /dev/null +++ b/nvim/.config/nvim/Session.vim @@ -0,0 +1,122 @@ +let SessionLoad = 1 +let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1 +let v:this_session=expand(":p") +silent only +silent tabonly +cd ~/.dotfiles/nvim/.config/nvim +if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == '' + let s:wipebuf = bufnr('%') +endif +let s:shortmess_save = &shortmess +if &shortmess =~ 'A' + set shortmess=aoOA +else + set shortmess=aoO +endif +badd +379 init.lua +badd +18 lua/plugins/trouble.lua +badd +5 lua/plugins/undotree.lua +badd +1 lua/themes/gruvbox.lua +badd +3 lua/plugins/todo-comments.lua +badd +9 lua/options.lua +badd +17 lua/keymaps.lua +badd +15 lua/autocmds.lua +badd +1 lua/plugins/autopairs.lua +badd +1 lua/plugins/autotag.lua +badd +4 lua/plugins/bufdel.lua +badd +1 lua/plugins/bufferline.lua +badd +1 lua/plugins/colorizer.lua +badd +1 lua/plugins/comment.lua +badd +9 lua/plugins/diffview.lua +badd +1 lua/plugins/guess-indent.lua +badd +1 lua/plugins/neotree.lua +badd +7 lua/plugins/surround.lua +badd +1 lua/plugins/tmux-navigation.lua +badd +1 lua/plugins/whitespace.lua +badd +22 lua/kickstart/plugins/autoformat.lua +badd +39 ~/Projects/rust/automation_rs/src/main.rs +badd +13 lua/plugins/treesj.lua +badd +10 ~/.dotfiles/nvim/.config/nvim/lua/plugins/symbols-outline.lua +badd +3 lua/plugins/null-ls.lua +argglobal +%argdel +edit init.lua +let s:save_splitbelow = &splitbelow +let s:save_splitright = &splitright +set splitbelow splitright +wincmd _ | wincmd | +vsplit +1wincmd h +wincmd w +let &splitbelow = s:save_splitbelow +let &splitright = s:save_splitright +wincmd t +let s:save_winminheight = &winminheight +let s:save_winminwidth = &winminwidth +set winminheight=0 +set winheight=1 +set winminwidth=0 +set winwidth=1 +exe 'vert 1resize ' . ((&columns * 142 + 142) / 284) +exe 'vert 2resize ' . ((&columns * 141 + 142) / 284) +argglobal +balt lua/options.lua +setlocal fdm=manual +setlocal fde=0 +setlocal fmr={{{,}}} +setlocal fdi=# +setlocal fdl=0 +setlocal fml=1 +setlocal fdn=20 +setlocal fen +silent! normal! zE +let &fdl = &fdl +let s:l = 379 - ((53 * winheight(0) + 35) / 70) +if s:l < 1 | let s:l = 1 | endif +keepjumps exe s:l +normal! zt +keepjumps 379 +normal! 045| +wincmd w +argglobal +if bufexists(fnamemodify("lua/plugins/null-ls.lua", ":p")) | buffer lua/plugins/null-ls.lua | else | edit lua/plugins/null-ls.lua | endif +if &buftype ==# 'terminal' + silent file lua/plugins/null-ls.lua +endif +balt lua/keymaps.lua +setlocal fdm=manual +setlocal fde=0 +setlocal fmr={{{,}}} +setlocal fdi=# +setlocal fdl=0 +setlocal fml=1 +setlocal fdn=20 +setlocal fen +silent! normal! zE +let &fdl = &fdl +let s:l = 3 - ((2 * winheight(0) + 35) / 70) +if s:l < 1 | let s:l = 1 | endif +keepjumps exe s:l +normal! zt +keepjumps 3 +normal! 024| +wincmd w +exe 'vert 1resize ' . ((&columns * 142 + 142) / 284) +exe 'vert 2resize ' . ((&columns * 141 + 142) / 284) +tabnext 1 +if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal' + silent exe 'bwipe ' . s:wipebuf +endif +unlet! s:wipebuf +set winheight=1 winwidth=20 +let &shortmess = s:shortmess_save +let &winminheight = s:save_winminheight +let &winminwidth = s:save_winminwidth +let s:sx = expand(":p:r")."x.vim" +if filereadable(s:sx) + exe "source " . fnameescape(s:sx) +endif +let &g:so = s:so_save | let &g:siso = s:siso_save +doautoall SessionLoadPost +unlet SessionLoad +" vim: set ft=vim : diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..942026a --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,534 @@ +--[[ + +===================================================================== +==================== READ THIS BEFORE CONTINUING ==================== +===================================================================== + +Kickstart.nvim is *not* a distribution. + +Kickstart.nvim is a template for your own configuration. + The goal is that you can read every line of code, top-to-bottom, and understand + what your configuration is doing. + + Once you've done that, you should start exploring, configuring and tinkering to + explore Neovim! + + If you don't know anything about Lua, I recommend taking some time to read through + a guide. One possible example: + - https://learnxinyminutes.com/docs/lua/ + + And then you can explore or search through `:help lua-guide` + + +Kickstart Guide: + +I have left several `:help X` comments throughout the init.lua +You should run that command and read that help section for more information. + +In addition, I have some `NOTE:` items throughout the file. +These are for you, the reader to help understand what is happening. Feel free to delete +them once you know what you're doing, but they should serve as a guide for when you +are first encountering a few different constructs in your nvim config. + +I hope you enjoy your Neovim journey, +- TJ + +P.S. You can delete this when you're done too. It's your config now :) +--]] + +-- Set as the leader key +-- See `:help mapleader` +-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- Install package manager +-- https://github.com/folke/lazy.nvim +-- `:help lazy.nvim.txt` for more info +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + } +end +vim.opt.rtp:prepend(lazypath) + +local symbols = require('constant.symbols'); + +-- NOTE: Here is where you install your plugins. +-- You can configure plugins using the `config` key. +-- +-- You can also configure plugins after the setup call, +-- as they will be available in your neovim runtime. +require('lazy').setup({ + + -- NOTE: This is where your plugins related to LSP can be installed. + -- The configuration is done below. Search for lspconfig to find it below. + { -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + + -- Add document color + 'mrshmllow/document-color.nvim', + + -- Rename with immediate visual feedback + { + 'smjonas/inc-rename.nvim', + config = function() + require('inc_rename').setup { + preview_empty_name = true, + } + end + }, + }, + }, + + { + 'ray-x/lsp_signature.nvim', + dependencies = { + 'neovim/nvim-lspconfig', + }, + opts = { + bind = true, -- This is mandatory, otherwise border config won't get registered. + hint_enable = false, + handler_opts = { + -- TODO: Setup borders for other lsp stuff (Maybe using noice?) + border = "single" + }} + }, + + { -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-path', 'onsails/lspkind-nvim', }, + }, + + -- Useful plugin to show you pending keybinds. + { 'folke/which-key.nvim', opts = {} }, + { -- Adds git releated signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, + }, + + { -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = true, + theme = 'gruvbox', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + }, + sections = { + lualine_b = { + 'branch', + 'diff', + { 'diagnostics', symbols = {error = '', warn = '', info = '', hint = ''} }, + }, + lualine_c = { + { 'filename', + path = 1, + symbols = { + modified = symbols.file.modified, + readonly = symbols.file.readonly, + } + }, + }, + lualine_x = { + 'encoding', { 'fileformat', icons_enabled = false }, 'filetype', + }, + }, + inactive_sections = { + lualine_c = { + { 'filename', path = 1 }, + }, + }, + }, + }, + + { -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help indent_blankline.txt` + opts = { + char = '¦', + show_trailing_blankline_indent = false, + }, + }, + + + -- Fuzzy Finder (files, lsp, etc) + { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope-ui-select.nvim' } }, + + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + + { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + 'nvim-treesitter/nvim-treesitter-context', + }, + config = function() + pcall(require('nvim-treesitter.install').update { with_sync = true }) + end, + }, + + require 'themes.gruvbox', + { import = 'plugins' }, +}, { + install = { + colorscheme = { + 'gruvbox', + } + } +}) + +require('options') +require('keymaps') +require('autocmds') + +-- [[ Configure Telescope ]] +-- See `:help telescope` and `:help telescope.setup()` +require('telescope').setup { + pickers = { + find_files = { + hidden = true, + }, + }, + defaults = { + file_ignore_patterns = { + ".git/", + }, + mappings = { + n = { + [''] = "delete_buffer", + [''] = "move_selection_next", + [''] = "move_selection_previous", + }, + i = { + [''] = "delete_buffer", + [''] = "move_selection_next", + [''] = "move_selection_previous", + }, + }, + }, + extensions = { + ["ui-select"] = { + require('telescope.themes').get_dropdown {} + } + } +} + +-- Enable telescope fzf native, if installed +pcall(require('telescope').load_extension, 'fzf') +pcall(require('telescope').load_extension, 'ui-select') + +-- See `:help telescope.builtin` +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '/', function() + require('telescope.builtin').current_buffer_fuzzy_find({ + -- Show matches in the order they appear in the document + sorting_strategy = "ascending", + }) +end, { desc = '[/] Fuzzily search in current buffer' }) + +vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', 'sw', function() + require('telescope.builtin').grep_string({ + -- Show matches in the order they appear in the document + sorting_strategy = "ascending", + }) +end, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + +-- [[ Configure Treesitter ]] +-- See `:help nvim-treesitter` +require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = true, + + highlight = { enable = true }, + -- Disabled because it caueses issues with nvim-autopair + indent = { enable = false, disable = { 'python' } }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, +} + +-- LSP settings. +-- Set the diagnostic symbols (Also used by Neo-tree) +local signs = { Error = symbols.diagnostic.error, Warn = symbols.diagnostic.warning, Hint = symbols.diagnostic.hint, Info = symbols.diagnostic.info } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) +end + +-- This function gets run when an LSP connects to a particular buffer. +local on_attach = function(client, bufnr) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + vim.keymap.set('n', 'rn', function() + return ':IncRename ' .. vim.fn.expand('') + end, { expr = true, desc = '[R]e[n]ame' }) + + -- nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + -- Should allow code actions in visual mode + vim.keymap.set({'v', 'n'}, 'ca', vim.lsp.buf.code_action, { buffer = bufnr, desc = 'LSP: [C]ode [A]ction', remap=true }) + -- nmap('ca', require('telescope.builtin')., '[C]ode [A]ction') + + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) + + -- Attach document colour support + if client.server_capabilities.colorProvider then + require("document-color").buf_attach(bufnr) + end +end + +-- Enable the following language servers +-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. +-- +-- Add any additional override configuration in the following tables. They will be passed to +-- the `settings` field of the server config. You must look up that documentation yourself. +local servers = { + clangd = {}, + -- gopls = {}, + -- pyright = {}, + rust_analyzer = { + -- enable clippy on save + ["rust-analyzer"] = { + checkOnSave = { + command = "clippy", + }, + check = { + allTargets = false, + }, + }, + }, + tsserver = {}, + tailwindcss = {}, + -- cssls = {}, + + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, +} + +-- Setup neovim lua configuration +require('neodev').setup() + +-- nvim-cmp supports additional completion capabilities, so broadcast that to servers +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) +capabilities.textDocument.colorProvider = { + dynamicRegistration = true +} + +-- Setup mason so it can manage external tooling +require('mason').setup() + +-- Ensure the servers above are installed +local mason_lspconfig = require 'mason-lspconfig' + +mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), +} + +mason_lspconfig.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + } + end, +} + +-- nvim-cmp setup +local cmp = require 'cmp' +local luasnip = require 'luasnip' +local lspkind = require 'lspkind' + +luasnip.config.setup {} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + -- Include the source of the cmp entry + formatting = { + format = lspkind.cmp_format({ + mode = "text", + menu = { + nvim_lsp = "[LSP]", + luasnip = "[LuaSnip]", + path = "[Path]", + }, + }), + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, +} + +-- The line beneath this is called `modeline`. See `:help modeline` +-- vim: ts=2 sts=2 sw=2 et diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim deleted file mode 100644 index 61b606e..0000000 --- a/nvim/.config/nvim/init.vim +++ /dev/null @@ -1,107 +0,0 @@ -let g:nvim_tree_show_icons = { - \ 'git': 0, - \ 'folders': 1, - \ 'files': 0, - \ 'folder_arrows': 0, - \ } -let g:nvim_tree_icons = { - \ 'folder': { - \ 'arrow_open': "", - \ 'arrow_closed': "", - \ 'default': "", - \ 'open': "", - \ 'empty': "", - \ 'empty_open': "", - \ 'symlink': "", - \ 'symlink_open': "", - \ } - \ } -lua require('plugins') - -" Load vim config in current directory -silent! so .vimlocal - -" DelimitMate -let delimitMate_expand_cr = 1 -let delimitMate_expand_space = 1 -let delimitMate_balance_matchpairs = 1 - -" Theme -colorscheme gruvbox -set t_Co=256 -set t_ZH= -set t_ZR= -set background=dark - -" Ident -" set list lcs=tab:┃\ ,trail:· -set list lcs=tab:¦\ ,trail:· - -" Airline -let g:airline_powerline_fonts = 1 -let g:airline#extensions#tabline#enabled = 1 -let g:airline_theme='gruvbox' -" let g:airline_theme='codedark' -let g:airline_section_z = '%3p%% %#__accent_bold#%4l%#__restore__#%#__accent_bold#/%L%#__restore__# :%3v' -let g:airline_section_warning = '' - -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif - -let g:airline_symbols.dirty = " ±" -let g:airline_symbols.notexists = " " - -" Preferences -syntax on -filetype plugin indent on -set smartindent -set number -set laststatus=2 -set softtabstop=4 -set tabstop=4 -set shiftwidth=4 -set noexpandtab -set mouse=n -set hidden -set updatetime=300 -set noshowmode - -set foldmethod=expr -set foldexpr=nvim_treesitter#foldexpr() -set foldnestmax=1 -set foldlevel=20 - -" Keybindings -nnoremap NvimTreeToggle -nnoremap TmuxNavigateLeft -nnoremap TmuxNavigateDown -nnoremap TmuxNavigateUp -nnoremap TmuxNavigateRight -nnoremap bn -nnoremap bp -nnoremap Bdelete -nnoremap TroubleToggle workspace_diagnostics -nnoremap call ToggleQuickfixList() -nnoremap noh -map 10j -map 10k - -nnoremap ff Telescope find_files -nnoremap fg Telescope live_grep -nnoremap fb Telescope buffers -nnoremap ls Telescope lsp_document_symbols -nnoremap ln lua vim.lsp.diagnostic.goto_next() -nnoremap lp lua vim.lsp.diagnostic.goto_prev() -nnoremap ll :lua vim.lsp.buf. -nnoremap lc lua vim.lsp.buf.code_action() -nnoremap lh lua vim.lsp.buf.hover() -nnoremap lf lua vim.lsp.buf.formatting() - -highlight! CmpItemAbbrMatch ctermfg=Cyan -highlight! CmpItemAbbrMatchFuzzy ctermfg=Cyan -highlight! NvimTreeFolderName ctermfg=Blue -highlight! NvimTreeOpenedFolderName ctermfg=Blue cterm=bold -highlight! NvimTreeEmptyFolderName ctermfg=Blue - -autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..4027ec4 --- /dev/null +++ b/nvim/.config/nvim/lazy-lock.json @@ -0,0 +1,47 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "8d3aa5c22c2d45e788c7a5fe13ad77368b783c20" }, + "LuaSnip": { "branch": "master", "commit": "bc8ec05022743d3f08bda7a76c6bb5e9a9024581" }, + "bufferline.nvim": { "branch": "main", "commit": "eb4e95be22c55890b90fc01a8223e0c0ea4a0862" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "document-color.nvim": { "branch": "main", "commit": "74c487f0e5accfaae033755451b9e367220693fd" }, + "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, + "gitsigns.nvim": { "branch": "main", "commit": "372d5cb485f2062ac74abc5b33054abac21d8b58" }, + "gruvbox.nvim": { "branch": "main", "commit": "53bfb95b1ed1d87f6a276abdd322b267be0b5adf" }, + "guess-indent.nvim": { "branch": "main", "commit": "b8ae749fce17aa4c267eec80a6984130b94f80b2" }, + "inc-rename.nvim": { "branch": "main", "commit": "fb1b7468f27d874feb209eac46be5205e20b7fd3" }, + "indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" }, + "lazy.nvim": { "branch": "main", "commit": "57cce98dfdb2f2dd05a0567d89811e6d0505e13b" }, + "lsp_signature.nvim": { "branch": "master", "commit": "1882019270be445a8cad4353f1530574f2b2d02d" }, + "lspkind-nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, + "lualine.nvim": { "branch": "master", "commit": "c28a7427c3fb29322db136f0564ec58807b26747" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a5ca8b03972b347b74b2ad2f7f23f120a514593b" }, + "mason.nvim": { "branch": "main", "commit": "84af7a1fa1dbdb0f201849be7993d999a05d973b" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "2b2f74828eeb02cf29d6b21aa32eedadadc94ca7" }, + "neodev.nvim": { "branch": "main", "commit": "864b35006d3de24c60e44b566de8018f919b13e6" }, + "nui.nvim": { "branch": "main", "commit": "1f43b13d133eb4b4f53a4485379d9afa58808389" }, + "null-ls.nvim": { "branch": "main", "commit": "5855128178fa78293acdfb5b4e41ef046779240b" }, + "nvim-autopairs": { "branch": "master", "commit": "0fd6519d44eac3a6736aafdb3fe9da916c3701d4" }, + "nvim-bufdel": { "branch": "main", "commit": "9f1ed6ef6594df9a74762a86f469d12036584976" }, + "nvim-cmp": { "branch": "main", "commit": "777450fd0ae289463a14481673e26246b5e38bf2" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, + "nvim-lspconfig": { "branch": "master", "commit": "1ec6f5cbf6ffc44c84783d70039df5295ca22b4e" }, + "nvim-surround": { "branch": "main", "commit": "e6047128e57c1aff1566fb9f627521d2887fc77a" }, + "nvim-tmux-navigation": { "branch": "main", "commit": "543f090a45cef28156162883d2412fffecb6b750" }, + "nvim-treesitter": { "branch": "master", "commit": "584ccea56e2d37b31ba292da2b539e1a4bb411ca" }, + "nvim-treesitter-context": { "branch": "master", "commit": "38203f5e6c62617b3c07662dc71ce3047ecd90d3" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "b55fe6175f0001347a433c9df358c8cbf8a4e90f" }, + "nvim-ts-autotag": { "branch": "main", "commit": "25698e4033cd6cd3745454bfc837dd670eba0480" }, + "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" }, + "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" }, + "telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" }, + "todo-comments.nvim": { "branch": "main", "commit": "a736bbe08c8eff370dfa60701f1e669816d4e3c8" }, + "treesj": { "branch": "main", "commit": "56958f35592b8439dd5014220fc0f3a6e5b01ded" }, + "trouble.nvim": { "branch": "main", "commit": "2ae7237c2917d661f458443c9a88680f8ca2d7b2" }, + "undotree": { "branch": "master", "commit": "485f01efde4e22cb1ce547b9e8c9238f36566f21" }, + "which-key.nvim": { "branch": "main", "commit": "4b73390eec680b4c061ea175eb32c0ff3412271d" }, + "whitespace.nvim": { "branch": "master", "commit": "525f67b3f01910c73f07f0848839aab0b7ab9f42" } +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/autocmds.lua b/nvim/.config/nvim/lua/autocmds.lua new file mode 100644 index 0000000..3d053e4 --- /dev/null +++ b/nvim/.config/nvim/lua/autocmds.lua @@ -0,0 +1,34 @@ +-- Highlight on yank +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank({ higroup = 'YankHighlight'}) + end, + group = highlight_group, + pattern = '*', +}) + +-- show cursor line only in active window +local cursor_group = vim.api.nvim_create_augroup('ActiveCursor', { clear = true }) +vim.api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, { + callback = function() + local ok, cl = pcall(vim.api.nvim_win_get_var, 0, "auto-cursorline") + if ok and cl then + vim.wo.cursorline = true + vim.api.nvim_win_del_var(0, "auto-cursorline") + end + end, + group = cursor_group, + pattern = '*', +}) +vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, { + callback = function() + local cl = vim.wo.cursorline + if cl then + vim.api.nvim_win_set_var(0, "auto-cursorline", cl) + vim.wo.cursorline = false + end + end, + group = cursor_group, + pattern = '*', +}) diff --git a/nvim/.config/nvim/lua/constant/symbols/diagnostic.lua b/nvim/.config/nvim/lua/constant/symbols/diagnostic.lua new file mode 100644 index 0000000..95053f3 --- /dev/null +++ b/nvim/.config/nvim/lua/constant/symbols/diagnostic.lua @@ -0,0 +1,16 @@ +-- Symbols to use for diagnostics +return { + -- LSP Status symbols + error = "", + warning = "", + info = "", + hint = "", + + -- Comment type symbols + bug = "", + todo = "", + hack = "", + performance = "", + note = "", + test = "", +} diff --git a/nvim/.config/nvim/lua/constant/symbols/file.lua b/nvim/.config/nvim/lua/constant/symbols/file.lua new file mode 100644 index 0000000..0a5b007 --- /dev/null +++ b/nvim/.config/nvim/lua/constant/symbols/file.lua @@ -0,0 +1,6 @@ +-- Symbols to use for files +return { + icon = '', + modified = '●', + readonly = '' +} diff --git a/nvim/.config/nvim/lua/constant/symbols/fold.lua b/nvim/.config/nvim/lua/constant/symbols/fold.lua new file mode 100644 index 0000000..29dc09e --- /dev/null +++ b/nvim/.config/nvim/lua/constant/symbols/fold.lua @@ -0,0 +1,6 @@ +-- Symbols to use for folds +return { + open = '', + closed = '', + empty = '' +} diff --git a/nvim/.config/nvim/lua/constant/symbols/git.lua b/nvim/.config/nvim/lua/constant/symbols/git.lua new file mode 100644 index 0000000..f00e4c2 --- /dev/null +++ b/nvim/.config/nvim/lua/constant/symbols/git.lua @@ -0,0 +1,15 @@ +-- Symbols to use for git +return { + -- Change type + added = '✚', + modified = '●', + deleted = '✖', + renamed = '', + + -- Status type + untracked = '', + ignored = '', + unstaged = '', + staged = '', + conflict = '', +} diff --git a/nvim/.config/nvim/lua/constant/symbols/init.lua b/nvim/.config/nvim/lua/constant/symbols/init.lua new file mode 100644 index 0000000..842f8ca --- /dev/null +++ b/nvim/.config/nvim/lua/constant/symbols/init.lua @@ -0,0 +1,6 @@ +return { + diagnostic = require("constant.symbols.diagnostic"), + fold = require("constant.symbols.fold"), + file = require("constant.symbols.file"), + git = require("constant.symbols.git"), +} diff --git a/nvim/.config/nvim/lua/keymaps.lua b/nvim/.config/nvim/lua/keymaps.lua new file mode 100644 index 0000000..2482fd1 --- /dev/null +++ b/nvim/.config/nvim/lua/keymaps.lua @@ -0,0 +1,19 @@ +-- See `:help vim.keymap.set()` +vim.keymap.set({ 'n', 'v' }, '', '', { noremap = true, silent = true }) + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +-- Keybinds for resizing windows +vim.keymap.set("n", "", "resize +2") +vim.keymap.set("n", "", "resize -2") +vim.keymap.set("n", "", "vertical resize -2") +vim.keymap.set("n", "", "vertical resize +2") + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) +-- Disabled in favor of using Trouble () +-- vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) diff --git a/nvim/.config/nvim/lua/options.lua b/nvim/.config/nvim/lua/options.lua new file mode 100644 index 0000000..3d1d7ea --- /dev/null +++ b/nvim/.config/nvim/lua/options.lua @@ -0,0 +1,53 @@ +-- See `:help vim.o` +-- Set highlight on search +vim.o.hlsearch = false + +-- Make line numbers default +vim.wo.number = true + +-- Enable mouse mode +vim.o.mouse = 'a' + +-- Sync clipboard between OS and Neovim. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.o.clipboard = 'unnamedplus' + +-- Enable break indent +vim.o.breakindent = true + +-- Save undo history +vim.o.undofile = true + +-- Case insensitive searching UNLESS /C or capital in search +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Keep signcolumn on by default +vim.wo.signcolumn = 'yes' + +-- Decrease update time +vim.o.updatetime = 250 +vim.o.timeout = true +vim.o.timeoutlen = 300 + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- NOTE: You should make sure your terminal supports this +vim.o.termguicolors = true + +-- Default tab settings +-- Tab settings are automatically detected by vim-sleuth +-- Can be overriden by .editorconfig and modeline +vim.o.tabstop = 4 +vim.o.softtabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = false +vim.o.smarttab = true + +-- Ask for confirmation instead of failing +vim.o.confirm = true + +-- Turn on cursorline +vim.o.cursorline = true diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua deleted file mode 100644 index 936dfd7..0000000 --- a/nvim/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,287 +0,0 @@ -local fn = vim.fn -local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' -if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) -end - -require('packer').startup(function() - use 'antoinemadec/FixCursorHold.nvim' - use 'wbthomason/packer.nvim' - - use 'gruvbox-community/gruvbox' - use 'tomasiser/vim-code-dark' - use 'vim-airline/vim-airline' - - use 'Raimondi/delimitMate' - -- use 'scrooloose/nerdtree' - use { - 'kyazdani42/nvim-tree.lua', - requires = { - }, - } - use 'tpope/vim-commentary' - use 'tpope/vim-surround' - use 'christoomey/vim-tmux-navigator' - use 'tpope/vim-dispatch' - use 'milkypostman/vim-togglelist' - use 'moll/vim-bbye' - use { - 'nvim-telescope/telescope.nvim', - requires = { {'nvim-lua/plenary.nvim'} } - } - use {'nvim-telescope/telescope-ui-select.nvim' } - use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } - - use 'neovim/nvim-lspconfig' - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/cmp-buffer' - use 'hrsh7th/cmp-path' - use 'hrsh7th/cmp-cmdline' - use 'hrsh7th/nvim-cmp' - use 'onsails/lspkind-nvim' - use 'ray-x/lsp_signature.nvim' - use { - "folke/trouble.nvim", - config = function() - require("trouble").setup { - signs = { - -- icons / text used for a diagnostic - error = "error", - warning = "warn", - hint = "hint", - information = "info" - }, - } - end - } - - use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - use 'windwp/nvim-ts-autotag' - use 'JoosepAlviste/nvim-ts-context-commentstring' - - use 'hrsh7th/cmp-vsnip' - use 'hrsh7th/vim-vsnip' - use "rafamadriz/friendly-snippets" - - use 'leafgarland/typescript-vim' - use 'peitalin/vim-jsx-typescript' -end) - ---Remap for dealing with word wrap -vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { noremap = true, expr = true, silent = true }) -vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { noremap = true, expr = true, silent = true }) - -require('telescope').setup { - defaults = { - }, - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown { - } - }, - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case", -- or "ignore_case" or "respect_case" - -- the default case_mode is "smart_case" - } - } -} --- To get fzf loaded and working with telescope, you need to call --- load_extension, somewhere after setup function: -require('telescope').load_extension('fzf') -require("telescope").load_extension("ui-select") - -require "lsp_signature".setup({ - hint_enable = false, - handler_opts = { - border = "none" -- double, rounded, single, shadow, none - }, - padding = ' ', -}) - -require'nvim-tree'.setup() - --- nvim-cmp setup -local cmp = require 'cmp' - -local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil -end - -local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) -end - -cmp.setup { - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - mapping = { - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif vim.fn["vsnip#available"](1) == 1 then - feedkey("(vsnip-expand-or-jump)", "") - elseif has_words_before() then - cmp.complete() - else - fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if cmp.visible() then - cmp.select_prev_item() - elseif vim.fn["vsnip#jumpable"](-1) == 1 then - feedkey("(vsnip-jump-prev)", "") - end - end, { "i", "s" }), - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'vsnip' }, -- For vsnip users. - }, { - { name = 'buffer' }, - }) -} - --- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } - } -}) - --- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) -}) - -cmp.setup({ - enabled = function() - -- disable completion in comments - local context = require 'cmp.config.context' - -- keep command mode completion enabled when cursor is in a comment - if vim.api.nvim_get_mode().mode == 'c' then - return true - else - return not context.in_syntax_group("Comment") - end - end -}) - --- lsp setup -local nvim_lsp = require('lspconfig') - -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = { - spacing = 8, - }, - signs = true, - update_in_insert = false - } -) - -vim.o.updatetime = 100 - --- Taken from: https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/lsp.lua --- Makes it so the diagnostic popup does not keep overwriting other popups -vim.diagnostic.config({ - virtual_text = false, - float = { - focusable = false, -- See neovim#16425 - }, -}) -_G.LspDiagnosticsShowPopup = function() - return vim.diagnostic.open_float(0, {scope="cursor"}) -end - --- Show diagnostics in a pop-up window on hover -_G.LspDiagnosticsPopupHandler = function() - local current_cursor = vim.api.nvim_win_get_cursor(0) - local last_popup_cursor = vim.w.lsp_diagnostics_last_cursor or {nil, nil} - - -- Show the popup diagnostics window, - -- but only once for the current cursor location (unless moved afterwards). - if not (current_cursor[1] == last_popup_cursor[1] and current_cursor[2] == last_popup_cursor[2]) then - vim.w.lsp_diagnostics_last_cursor = current_cursor - local _, winnr = _G.LspDiagnosticsShowPopup() - end -end -vim.cmd [[ -augroup LSPDiagnosticsOnHover - autocmd! - autocmd CursorHold * lua _G.LspDiagnosticsPopupHandler() -augroup END -]] - --- Enable some language servers with the additional completion capabilities offered by nvim-cmp -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) -capabilities.textDocument.completion.completionItem.snippetSupport = true - -local servers = { 'clangd', 'tsserver', 'gopls', 'pylsp' } -for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - -- on_attach = my_custom_on_attach, - capabilities = capabilities - } -end - -nvim_lsp.cssls.setup { - capabilities = capabilities, - cmd = {"vscode-css-languageserver", "--stdio"} -} - -local lspkind = require('lspkind') -cmp.setup { - formatting = { - format = lspkind.cmp_format({ - with_text = true, - mode = "text", - menu = ({ - buffer = "[Buffer]", - nvim_lsp = "[LSP]", - luasnip = "[LuaSnip]", - nvim_lua = "[Lua]", - latex_symbols = "[Latex]", - }) - }), - }, - experimental = { - ghost_text = true - } -} - -require'nvim-treesitter.configs'.setup { - ensure_installed = "all", -} -require('nvim-ts-autotag').setup() -require'nvim-treesitter.configs'.setup { - context_commentstring = { - enable = true - } -} - -local signs = { Error = "", Warn = "", Hint = "", Info = "" } -for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) -end - --- Set completeopt to have a better completion experience --- vim.o.completeopt = 'menuone,noselect' diff --git a/nvim/.config/nvim/lua/plugins/autopairs.lua b/nvim/.config/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..f09cd0d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,7 @@ +-- vim: ts=4 sts=4 sw=4 noet +-- https://github.com/windwp/nvim-autopairs +return { + 'windwp/nvim-autopairs', + event = "VeryLazy", + opts = {}, +} diff --git a/nvim/.config/nvim/lua/plugins/autotag.lua b/nvim/.config/nvim/lua/plugins/autotag.lua new file mode 100644 index 0000000..3e9a0c1 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/autotag.lua @@ -0,0 +1,6 @@ +-- https://github.com/windwp/nvim-ts-autotag +return { + 'windwp/nvim-ts-autotag', + event = "VeryLazy", + opts = {}, +} diff --git a/nvim/.config/nvim/lua/plugins/bufdel.lua b/nvim/.config/nvim/lua/plugins/bufdel.lua new file mode 100644 index 0000000..aeae32a --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/bufdel.lua @@ -0,0 +1,13 @@ +-- https://github.com/ojroques/nvim-bufdel +return { + 'ojroques/nvim-bufdel', + cmd = { "BufDel", "BuffDelOthers" }, + keys = { + { 'bd', function() + require('bufdel').delete_buffer_expr(nil, false) + end, silent = true, desc = '[B]uffer [d]elete' }, + { 'bD', function() + require('bufdel').delete_buffer_others(false) + end, silent = true, desc = '[B]uffer [D]elete others' }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/bufferline.lua b/nvim/.config/nvim/lua/plugins/bufferline.lua new file mode 100644 index 0000000..b31bf56 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/bufferline.lua @@ -0,0 +1,61 @@ +-- https://github.com/akinsho/bufferline.nvim +return { + 'akinsho/bufferline.nvim', + version = "v3.*", + dependencies = { + 'ojroques/nvim-bufdel', + }, + config = function() + -- Enable mousemoveevent if possible + vim.o.mousemoveevent = true; + + local bufferline = require('bufferline'); + + -- Setup keybinds to move between buffers + vim.keymap.set('n', '', function() + bufferline.cycle(1) + end, { silent = true, desc = 'Goto next buffer' }) + vim.keymap.set('n', '', function() + bufferline.cycle(-1) + end, { silent = true, desc = 'Goto previous buffer' }) + + -- Setup keybinds to move buffers around + vim.keymap.set('n', 'b[', function() + bufferline.move(-1) + end, { silent = true, desc = '[B]uffer to the [ left' }) + vim.keymap.set('n', 'b]', function() + bufferline.move(1) + end, { silent = true, desc = '[B]uffer to the ] right' }) + + local symbols = require('constant.symbols'); + + bufferline.setup { + options = { + show_buffer_icons = false, + show_buffer_close_icons = true, + diagnostics = "nvim_lsp", + close_command = "BufDel %d", + right_mouse_command = "BufDel %d", + separator_style = "thick", + left_trunc_marker = '', + right_trunc_marker = '', + sort_by = "insert_at_end", + indicator = { + style = 'none', + }, + modified_icon = symbols.file.modified, + ---@diagnostic disable-next-line: unused-local + diagnostics_indicator = function(count, level, diagnostics_dict, context) + local s = " " + for e, n in pairs(diagnostics_dict) do + local sym = e == "error" and symbols.diagnostic.error .. ' ' + or (e == "warning" and symbols.diagnostic.warning .. ' ') + or (e == "info" and symbols.diagnostic.info .. ' ' or symbols.diagnostic.hint .. ' ' ) + s = s .. n .. sym + end + return s + end + }, + } + end +} diff --git a/nvim/.config/nvim/lua/plugins/colorizer.lua b/nvim/.config/nvim/lua/plugins/colorizer.lua new file mode 100644 index 0000000..35966e8 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/colorizer.lua @@ -0,0 +1,29 @@ +-- https://github.com/NvChad/nvim-colorizer.lua +return { + 'NvChad/nvim-colorizer.lua', + event = "VeryLazy", + opts = { + filetypes = { + '*', -- Enable color highlighting for all files + '!neo-tree', -- Exclude neo-tree + }, + buftypes = { + "*", + "!prompt", + "!popup", + }, + always_update = true, + }, + -- Fix lazy loading: https://github.com/NvChad/nvim-colorizer.lua + config = function(_, opts) + local colorizer = require('colorizer'); + colorizer.setup(opts) + + -- nvim-colorizer doesn't work on the initial buffer if we lazy load, so force it to attach + -- on load. + local bufnr = vim.api.nvim_get_current_buf() + if bufnr and not colorizer.is_buffer_attached(bufnr) then + colorizer.attach_to_buffer(bufnr) + end + end +} diff --git a/nvim/.config/nvim/lua/plugins/comment.lua b/nvim/.config/nvim/lua/plugins/comment.lua new file mode 100644 index 0000000..6dcb165 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/comment.lua @@ -0,0 +1,6 @@ +-- https://github.com/numToStr/Comment.nvim +return { + 'numToStr/Comment.nvim', + event = "VeryLazy", + opts = {}, +} diff --git a/nvim/.config/nvim/lua/plugins/guess-indent.lua b/nvim/.config/nvim/lua/plugins/guess-indent.lua new file mode 100644 index 0000000..cd6eee2 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/guess-indent.lua @@ -0,0 +1,12 @@ +-- https://github.com/NMAC427/guess-indent.nvim +return { + -- Adds a command to automatically detect the identation settings + -- Prefer to use .editorconfig for projects and modeline for files + 'NMAC427/guess-indent.nvim', + keys = { + { "gi", "GuessIndent", desc = "[G]uess [I]ndentation" }, + }, + opts = { + auto_cmd = false, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/neotree.lua b/nvim/.config/nvim/lua/plugins/neotree.lua new file mode 100644 index 0000000..7aca6ee --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/neotree.lua @@ -0,0 +1,65 @@ +-- https://github.com/nvim-neo-tree/neo-tree.nvim +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) +return { + 'nvim-neo-tree/neo-tree.nvim', + version = "v2.x", + dependencies = { + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + }, + cmd = { 'Neotree' }, + keys = { + { '', 'Neotree toggle reveal filesystem float', desc = 'Open floating Neo-tree window' }, + }, + config = function () + local symbols = require('constant.symbols'); + + require('neo-tree').setup { + close_if_last_window = true, + enable_diagnostics = true, + source_selector = { + winbar = true, + }, + default_component_configs = { + icon = { + folder_closed = symbols.fold.closed, + folder_open = symbols.fold.open, + folder_empty = symbols.fold.empty, + default = symbols.file.icon, + }, + modified = { + symbol = symbols.file.modified, + }, + name = { + use_git_status_colors = false, + }, + git_status = { + symbols = symbols.git, + } + }, + filesystem = { + filtered_items = { + hide_dotfiles = false, + hide_by_name = { + ".git" + } + }, + use_libuv_file_watcher = true, + }, + window = { + mappings = { + [""] = "close_window", + [""] = "close_window", + }, + }, + buffers = { + window = { + mappings = { + ["bd"] = nil, + [""] = "buffer_delete", + }, + }, + }, + } + end, +} diff --git a/nvim/.config/nvim/lua/plugins/null-ls.lua b/nvim/.config/nvim/lua/plugins/null-ls.lua new file mode 100644 index 0000000..690f473 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/null-ls.lua @@ -0,0 +1,12 @@ +return { + 'jose-elias-alvarez/null-ls.nvim', + config = function () + local null_ls = require('null-ls') + + null_ls.setup { + sources = { + null_ls.builtins.code_actions.gitsigns, + } + } + end, +} diff --git a/nvim/.config/nvim/lua/plugins/surround.lua b/nvim/.config/nvim/lua/plugins/surround.lua new file mode 100644 index 0000000..d1821d7 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/surround.lua @@ -0,0 +1,7 @@ +-- https://github.com/kylechui/nvim-surround +return { + 'kylechui/nvim-surround', + version = '*', -- Use for stability; omit to use `main` branch for the latest features + event = 'VeryLazy', + config = true, +} diff --git a/nvim/.config/nvim/lua/plugins/symbols-outline.lua b/nvim/.config/nvim/lua/plugins/symbols-outline.lua new file mode 100644 index 0000000..243dd37 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/symbols-outline.lua @@ -0,0 +1,10 @@ +-- https://github.com/simrat39/symbols-outline.nvim +return { + 'simrat39/symbols-outline.nvim', + keys = { + { '', function() + require('symbols-outline').toggle_outline() + end, desc = 'Toggle symbols outline' }, + }, + opts = {}, +} diff --git a/nvim/.config/nvim/lua/plugins/tmux-navigation.lua b/nvim/.config/nvim/lua/plugins/tmux-navigation.lua new file mode 100644 index 0000000..d8ec342 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/tmux-navigation.lua @@ -0,0 +1,18 @@ +-- https://github.com/alexghergh/nvim-tmux-navigation +return { + 'alexghergh/nvim-tmux-navigation', + event = "VeryLazy", + config = function() + local nvim_tmux_nav = require('nvim-tmux-navigation') + + nvim_tmux_nav.setup { + disable_when_zoomed = true, + keybindings = { + left = '', + down = '', + up = '', + right = '', + }, + } + end +} diff --git a/nvim/.config/nvim/lua/plugins/todo-comments.lua b/nvim/.config/nvim/lua/plugins/todo-comments.lua new file mode 100644 index 0000000..58aa7a0 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/todo-comments.lua @@ -0,0 +1,58 @@ +-- https://github.com/folke/todo-comments.nvim +return { + -- NOTE: Using a fork for the time being upstream does not support authors + -- 'folke/todo-comments.nvim', + 'doongjohn/todo-comments.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + config = function() + local symbols = require('constant.symbols') + + vim.keymap.set("n", "]t", function() + require("todo-comments").jump_next() + end, { desc = "Next todo comment" }) + + vim.keymap.set("n", "[t", function() + require("todo-comments").jump_prev() + end, { desc = "Previous todo comment" }) + + if pcall(require, "trouble") then + -- TODO: Use cwd to only show todo's in the current file + -- vim.keymap.set("n", "", "TroubleToggle todo cwd=%", { desc = "Next todo comment" }) + vim.keymap.set("n", "", "TroubleToggle todo", { desc = "Next todo comment" }) + end + if pcall(require, "telescope") then + vim.keymap.set('n', 'st', 'TodoTelescope', { desc = '[S]earch [T]odo' }) + end + + require('todo-comments').setup { + keywords = { + FIX = { icon = symbols.diagnostic.bug }, + TODO = { icon = symbols.diagnostic.todo }, + HACK = { icon = symbols.diagnostic.hack }, + WARN = { icon = symbols.diagnostic.warning }, + PERF = { icon = symbols.diagnostic.performance }, + NOTE = { icon = symbols.diagnostic.note }, + TEST = { icon = symbols.diagnostic.test }, + }, + highlight = { + -- TODO: Have multiline, but end when %p (punctuation) is at the end of a line + multiline = false, + before = "fg", + pattern = [[(KEYWORDS)\s*(\([^\)]*\))?:?]], + }, + search = { + pattern = [[\b(KEYWORDS)(\(.*\))?:?]] + }, + colors = { + error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, + warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, + info = { "Todo", "#2563EB" }, + hint = { "DiagnosticHint", "#10B981" }, + default = { "Identifier", "#7C3AED" }, + test = { "Identifier", "#FF00FF" } + }, + } + end, +} diff --git a/nvim/.config/nvim/lua/plugins/treesj.lua b/nvim/.config/nvim/lua/plugins/treesj.lua new file mode 100644 index 0000000..6e2a491 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/treesj.lua @@ -0,0 +1,13 @@ +-- https://github.com/Wansmer/treesj +return { + 'Wansmer/treesj', + keys = { + { 'm', function() + require('treesj').toggle() + end, desc = "Split or Join code block" }, + }, + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + opts = { + use_default_keymaps = false, + } +} diff --git a/nvim/.config/nvim/lua/plugins/trouble.lua b/nvim/.config/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..bd29362 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/trouble.lua @@ -0,0 +1,18 @@ +-- https://github.com/folke/trouble.nvim +return { + 'folke/trouble.nvim', + cmd = { 'Trouble', 'TroubleToggle', }, + keys = { + { '', 'TroubleToggle workspace_diagnostics', desc = 'Goto previous buffer' }, + }, + config = function () + local symbols = require('constant.symbols'); + require('trouble').setup { + icons = false, + auto_close = true, + fold_open = symbols.fold.open, -- icon used for open folds + fold_closed = symbols.fold.close, -- icon used for closed folds + use_diagnostic_signs = true, + } + end +} diff --git a/nvim/.config/nvim/lua/plugins/undotree.lua b/nvim/.config/nvim/lua/plugins/undotree.lua new file mode 100644 index 0000000..9ea925b --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/undotree.lua @@ -0,0 +1,7 @@ +-- https://github.com/mbbill/undotree +return { + 'mbbill/undotree', + keys = { + { '', vim.cmd.UndotreeToggle, desc = 'Toggle undotree' }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/whitespace.lua b/nvim/.config/nvim/lua/plugins/whitespace.lua new file mode 100644 index 0000000..ff7d1b7 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/whitespace.lua @@ -0,0 +1,19 @@ +return { + 'johnfrankmorgan/whitespace.nvim', + config = function () + require('whitespace-nvim').setup({ + -- configuration options and their defaults + + -- `highlight` configures which highlight is used to display + -- trailing whitespace + highlight = 'CursorLine', + + -- `ignored_filetypes` configures which filetypes to ignore when + -- displaying trailing whitespace + ignored_filetypes = { 'TelescopePrompt', 'Trouble', 'help' }, + }) + + -- remove trailing whitespace with a keybinding + vim.keymap.set('n', 't', require('whitespace-nvim').trim, { desc = "Remove trailing whitespace" }) + end +} diff --git a/nvim/.config/nvim/lua/themes/gruvbox.lua b/nvim/.config/nvim/lua/themes/gruvbox.lua new file mode 100644 index 0000000..41d2f06 --- /dev/null +++ b/nvim/.config/nvim/lua/themes/gruvbox.lua @@ -0,0 +1,23 @@ +-- https://github.com/ellisonleao/gruvbox.nvim +return { + 'ellisonleao/gruvbox.nvim', + priority = 1000, + config = function() + local config = require("gruvbox").config + local colors = require("gruvbox.palette").get_base_colors(vim.o.background, config.contrast) + + require('gruvbox').setup { + background = "dark", + italic = { + strings = false, + }, + overrides = { + YankHighlight = { fg = colors.blue, bg = colors.bg0, reverse = config.inverse }, + IncSearch = { fg = colors.aqua }, + Search = { fg = colors.aqua }, + } + } + + vim.cmd.colorscheme 'gruvbox' + end, +} diff --git a/nvim/.config/nvim/plugin/packer_compiled.lua b/nvim/.config/nvim/plugin/packer_compiled.lua deleted file mode 100644 index b0f0b04..0000000 --- a/nvim/.config/nvim/plugin/packer_compiled.lua +++ /dev/null @@ -1,257 +0,0 @@ --- Automatically generated packer.nvim plugin loader code - -if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then - vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') - return -end - -vim.api.nvim_command('packadd packer.nvim') - -local no_errors, error_msg = pcall(function() - - local time - local profile_info - local should_profile = false - if should_profile then - local hrtime = vim.loop.hrtime - profile_info = {} - time = function(chunk, start) - if start then - profile_info[chunk] = hrtime() - else - profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 - end - end - else - time = function(chunk, start) end - end - -local function save_profiles(threshold) - local sorted_times = {} - for chunk_name, time_taken in pairs(profile_info) do - sorted_times[#sorted_times + 1] = {chunk_name, time_taken} - end - table.sort(sorted_times, function(a, b) return a[2] > b[2] end) - local results = {} - for i, elem in ipairs(sorted_times) do - if not threshold or threshold and elem[2] > threshold then - results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' - end - end - - _G._packer = _G._packer or {} - _G._packer.profile_output = results -end - -time([[Luarocks path setup]], true) -local package_path_str = "/home/tim/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/tim/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/tim/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/tim/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" -local install_cpath_pattern = "/home/tim/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" -if not string.find(package.path, package_path_str, 1, true) then - package.path = package.path .. ';' .. package_path_str -end - -if not string.find(package.cpath, install_cpath_pattern, 1, true) then - package.cpath = package.cpath .. ';' .. install_cpath_pattern -end - -time([[Luarocks path setup]], false) -time([[try_loadstring definition]], true) -local function try_loadstring(s, component, name) - local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) - if not success then - vim.schedule(function() - vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) - end) - end - return result -end - -time([[try_loadstring definition]], false) -time([[Defining packer_plugins]], true) -_G.packer_plugins = { - ["FixCursorHold.nvim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/FixCursorHold.nvim", - url = "https://github.com/antoinemadec/FixCursorHold.nvim" - }, - ["cmp-buffer"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-buffer", - url = "https://github.com/hrsh7th/cmp-buffer" - }, - ["cmp-cmdline"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-cmdline", - url = "https://github.com/hrsh7th/cmp-cmdline" - }, - ["cmp-nvim-lsp"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", - url = "https://github.com/hrsh7th/cmp-nvim-lsp" - }, - ["cmp-path"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-path", - url = "https://github.com/hrsh7th/cmp-path" - }, - ["cmp-vsnip"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-vsnip", - url = "https://github.com/hrsh7th/cmp-vsnip" - }, - delimitMate = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/delimitMate", - url = "https://github.com/Raimondi/delimitMate" - }, - ["friendly-snippets"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/friendly-snippets", - url = "https://github.com/rafamadriz/friendly-snippets" - }, - gruvbox = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/gruvbox", - url = "https://github.com/gruvbox-community/gruvbox" - }, - ["lsp_signature.nvim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/lsp_signature.nvim", - url = "https://github.com/ray-x/lsp_signature.nvim" - }, - ["lspkind-nvim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/lspkind-nvim", - url = "https://github.com/onsails/lspkind-nvim" - }, - ["nvim-cmp"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-cmp", - url = "https://github.com/hrsh7th/nvim-cmp" - }, - ["nvim-lspconfig"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", - url = "https://github.com/neovim/nvim-lspconfig" - }, - ["nvim-tree.lua"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", - url = "https://github.com/kyazdani42/nvim-tree.lua" - }, - ["nvim-treesitter"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-treesitter", - url = "https://github.com/nvim-treesitter/nvim-treesitter" - }, - ["nvim-ts-autotag"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-ts-autotag", - url = "https://github.com/windwp/nvim-ts-autotag" - }, - ["nvim-ts-context-commentstring"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-ts-context-commentstring", - url = "https://github.com/JoosepAlviste/nvim-ts-context-commentstring" - }, - ["packer.nvim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/packer.nvim", - url = "https://github.com/wbthomason/packer.nvim" - }, - ["plenary.nvim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/plenary.nvim", - url = "https://github.com/nvim-lua/plenary.nvim" - }, - ["telescope-fzf-native.nvim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim", - url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" - }, - ["telescope-ui-select.nvim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/telescope-ui-select.nvim", - url = "https://github.com/nvim-telescope/telescope-ui-select.nvim" - }, - ["telescope.nvim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/telescope.nvim", - url = "https://github.com/nvim-telescope/telescope.nvim" - }, - ["trouble.nvim"] = { - config = { "\27LJ\2\n\1\0\0\4\0\6\0\t6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\4\0005\3\3\0=\3\5\2B\0\2\1K\0\1\0\nsigns\1\0\0\1\0\4\nerror\nerror\16information\tinfo\thint\thint\fwarning\twarn\nsetup\ftrouble\frequire\0" }, - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/trouble.nvim", - url = "https://github.com/folke/trouble.nvim" - }, - ["typescript-vim"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/typescript-vim", - url = "https://github.com/leafgarland/typescript-vim" - }, - ["vim-airline"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-airline", - url = "https://github.com/vim-airline/vim-airline" - }, - ["vim-bbye"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-bbye", - url = "https://github.com/moll/vim-bbye" - }, - ["vim-code-dark"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-code-dark", - url = "https://github.com/tomasiser/vim-code-dark" - }, - ["vim-commentary"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-commentary", - url = "https://github.com/tpope/vim-commentary" - }, - ["vim-dispatch"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-dispatch", - url = "https://github.com/tpope/vim-dispatch" - }, - ["vim-jsx-typescript"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-jsx-typescript", - url = "https://github.com/peitalin/vim-jsx-typescript" - }, - ["vim-surround"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-surround", - url = "https://github.com/tpope/vim-surround" - }, - ["vim-tmux-navigator"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-tmux-navigator", - url = "https://github.com/christoomey/vim-tmux-navigator" - }, - ["vim-togglelist"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-togglelist", - url = "https://github.com/milkypostman/vim-togglelist" - }, - ["vim-vsnip"] = { - loaded = true, - path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-vsnip", - url = "https://github.com/hrsh7th/vim-vsnip" - } -} - -time([[Defining packer_plugins]], false) --- Config for: trouble.nvim -time([[Config for trouble.nvim]], true) -try_loadstring("\27LJ\2\n\1\0\0\4\0\6\0\t6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\4\0005\3\3\0=\3\5\2B\0\2\1K\0\1\0\nsigns\1\0\0\1\0\4\nerror\nerror\16information\tinfo\thint\thint\fwarning\twarn\nsetup\ftrouble\frequire\0", "config", "trouble.nvim") -time([[Config for trouble.nvim]], false) -if should_profile then save_profiles() end - -end) - -if not no_errors then - error_msg = error_msg:gsub('"', '\\"') - vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') -end diff --git a/nvim/.config/nvim/syntax/c.vim b/nvim/.config/nvim/syntax/c.vim deleted file mode 100644 index e57c3c2..0000000 --- a/nvim/.config/nvim/syntax/c.vim +++ /dev/null @@ -1,491 +0,0 @@ -" Vim syntax file -" Language: C -" Maintainer: Bram Moolenaar -" Last Change: 2016 Nov 17 - -" Quit when a (custom) syntax file was already loaded -if exists("b:current_syntax") - finish -endif - -let s:cpo_save = &cpo -set cpo&vim - -let s:ft = matchstr(&ft, '^\([^.]\)\+') - -" A bunch of useful C keywords -syn keyword cStatement goto break return continue asm -syn keyword cLabel case default -syn keyword cConditional if else switch -syn keyword cRepeat while for do - -syn keyword cTodo contained TODO FIXME XXX -syn match cTodo contained "@todo" -syn match cTodo contained "@note" - -" It's easy to accidentally add a space after a backslash that was intended -" for line continuation. Some compilers allow it, which makes it -" unpredictable and should be avoided. -syn match cBadContinuation contained "\\\s\+$" - -" cCommentGroup allows adding matches for special things in comments -syn cluster cCommentGroup contains=cTodo,cBadContinuation - -" String and Character constants -" Highlight special characters (those which have a backslash) differently -syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" -if !exists("c_no_utf") - syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)" -endif - -if !exists("c_no_cformat") - " Highlight % items in strings. - if !exists("c_no_c99") " ISO C99 - syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained - else - syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained - endif - syn match cFormat display "%%" contained -endif - -" cCppString: same as cString, but ends at end of line -if s:ft ==# "cpp" && !exists("cpp_no_cpp11") && !exists("c_no_cformat") - " ISO C++11 - syn region cString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend - syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell -elseif s:ft ==# "c" && !exists("c_no_c11") && !exists("c_no_cformat") - " ISO C99 - syn region cString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend - syn region cCppString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell -else - " older C or C++ - syn match cFormat display "%%" contained - syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend - syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell -endif - -syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip - -syn cluster cStringGroup contains=cCppString,cCppSkip - -syn match cCharacter "L\='[^\\]'" -syn match cCharacter "L'[^']*'" contains=cSpecial -if exists("c_gnu") - syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'" - syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'" -else - syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'" - syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'" -endif -syn match cSpecialCharacter display "L\='\\\o\{1,3}'" -syn match cSpecialCharacter display "'\\x\x\{1,2}'" -syn match cSpecialCharacter display "L'\\x\x\+'" - -if (s:ft ==# "c" && !exists("c_no_c11")) || (s:ft ==# "cpp" && !exists("cpp_no_cpp11")) - " ISO C11 or ISO C++ 11 - if exists("c_no_cformat") - syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend - else - syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend - endif - syn match cCharacter "[Uu]'[^\\]'" - syn match cCharacter "[Uu]'[^']*'" contains=cSpecial - if exists("c_gnu") - syn match cSpecialError "[Uu]'\\[^'\"?\\abefnrtv]'" - syn match cSpecialCharacter "[Uu]'\\['\"?\\abefnrtv]'" - else - syn match cSpecialError "[Uu]'\\[^'\"?\\abfnrtv]'" - syn match cSpecialCharacter "[Uu]'\\['\"?\\abfnrtv]'" - endif - syn match cSpecialCharacter display "[Uu]'\\\o\{1,3}'" - syn match cSpecialCharacter display "[Uu]'\\x\x\+'" -endif - -"when wanted, highlight trailing white space -if exists("c_space_errors") - if !exists("c_no_trail_space_error") - syn match cSpaceError display excludenl "\s\+$" - endif - if !exists("c_no_tab_space_error") - syn match cSpaceError display " \+\t"me=e-1 - endif -endif - -" This should be before cErrInParen to avoid problems with #define ({ xxx }) -if exists("c_curly_error") - syn match cCurlyError "}" - syn region cBlock start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell fold -else - syn region cBlock start="{" end="}" transparent fold -endif - -" Catch errors caused by wrong parenthesis and brackets. -" Also accept <% for {, %> for }, <: for [ and :> for ] (C99) -" But avoid matching <::. -syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom -if exists("c_no_curly_error") - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell - syn match cParenError display ")" - syn match cErrInParen display contained "^^<%\|^%>" - else - syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell - syn match cParenError display ")" - syn match cErrInParen display contained "^[{}]\|^<%\|^%>" - endif -elseif exists("c_no_bracket_error") - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell - syn match cParenError display ")" - syn match cErrInParen display contained "<%\|%>" - else - syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell - syn match cParenError display ")" - syn match cErrInParen display contained "[{}]\|<%\|%>" - endif -else - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell - syn match cParenError display "[\])]" - syn match cErrInParen display contained "<%\|%>" - syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell - else - syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell - syn match cParenError display "[\])]" - syn match cErrInParen display contained "[\]{}]\|<%\|%>" - syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell - endif - " cCppBracket: same as cParen but ends at end-of-line; used in cDefine - syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell - syn match cErrInBracket display contained "[);{}]\|<%\|%>" -endif - -if s:ft ==# 'c' || exists("cpp_no_cpp11") - syn region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold -endif - -"integer number, or floating point number without a dot and with "f". -syn case ignore -syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal -" Same, but without octal error (for comments) -syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal -syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" -"hex number -syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" -" Flag the first zero of an octal number as something special -syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero -syn match cOctalZero display contained "\<0" -syn match cFloat display contained "\d\+f" -"floating point number, with dot, optional exponent -syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" -"floating point number, starting with a dot, optional exponent -syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" -"floating point number, without dot, with exponent -syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" -if !exists("c_no_c99") - "hexadecimal floating point number, optional leading digits, with dot, with exponent - syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>" - "hexadecimal floating point number, with leading digits, optional dot, with exponent - syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>" -endif - -" flag an octal number with wrong digits -syn match cOctalError display contained "0\o*[89]\d*" -syn case match - -if exists("c_comment_strings") - " A comment can contain cString, cCharacter and cNumber. - " But a "*/" inside a cString in a cComment DOES end the comment! So we - " need to use a special type of cString: cCommentString, which also ends on - " "*/", and sees a "*" at the start of the line as comment again. - " Unfortunately this doesn't very well work for // type of comments :-( - syn match cCommentSkip contained "^\s*\*\($\|\s\+\)" - syn region cCommentString contained start=+L\=\\\@" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError -syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>" -if !exists("c_no_if0") - syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip - syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold - syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse - if !exists("c_no_if0_fold") - syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold - else - syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell - endif - syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit - syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold - syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit - if !exists("c_no_if0_fold") - syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold - else - syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 - endif - syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell - syn region cCppOutSkip contained start="^\s*\zs\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip - syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc -endif -syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ -syn match cIncluded display contained "<[^>]*>" -syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded -"syn match cLineSkip "\\$" -syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock -syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell -syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell - -" Highlight User Labels -syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString -if s:ft ==# 'c' || exists("cpp_no_cpp11") - syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell,@cStringGroup -endif -" Avoid matching foo::bar() in C++ by requiring that the next char is not ':' -syn cluster cLabelGroup contains=cUserLabel -syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup -syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup -if s:ft ==# 'cpp' - syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup - syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup -else - syn match cUserCont display "^\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup - syn match cUserCont display ";\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup -endif - -syn match cUserLabel display "\I\i*" contained - -" Avoid recognizing most bitfields as labels -syn match cBitField display "^\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType -syn match cBitField display ";\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType - -if exists("c_minlines") - let b:c_minlines = c_minlines -else - if !exists("c_no_if0") - let b:c_minlines = 50 " #if 0 constructs can be long - else - let b:c_minlines = 15 " mostly for () constructs - endif -endif -if exists("c_curly_error") - syn sync fromstart -else - exec "syn sync ccomment cComment minlines=" . b:c_minlines -endif - -" Define the default highlighting. -" Only used when an item doesn't have highlighting yet -hi def link cFormat cSpecial -hi def link cCppString cString -hi def link cCommentL cComment -hi def link cCommentStart cComment -hi def link cLabel Label -hi def link cUserLabel Label -hi def link cConditional Conditional -hi def link cRepeat Repeat -hi def link cCharacter Character -hi def link cSpecialCharacter cSpecial -hi def link cNumber Number -hi def link cOctal Number -hi def link cOctalZero PreProc " link this to Error if you want -hi def link cFloat Float -hi def link cOctalError cError -hi def link cParenError cError -hi def link cErrInParen cError -hi def link cErrInBracket cError -hi def link cCommentError cError -hi def link cCommentStartError cError -hi def link cSpaceError cError -hi def link cSpecialError cError -hi def link cCurlyError cError -hi def link cOperator Operator -hi def link cStructure Structure -hi def link cStorageClass StorageClass -hi def link cInclude Include -hi def link cPreProc PreProc -hi def link cDefine Macro -hi def link cIncluded cString -hi def link cError Error -hi def link cStatement Statement -hi def link cCppInWrapper cCppOutWrapper -hi def link cCppOutWrapper cPreCondit -hi def link cPreConditMatch cPreCondit -hi def link cPreCondit PreCondit -hi def link cType Type -hi def link cConstant Constant -hi def link cCommentString cString -hi def link cComment2String cString -hi def link cCommentSkip cComment -hi def link cString String -hi def link cComment Comment -hi def link cSpecial SpecialChar -hi def link cTodo Todo -hi def link cBadContinuation Error -hi def link cCppOutSkip cCppOutIf2 -hi def link cCppInElse2 cCppOutIf2 -hi def link cCppOutIf2 cCppOut -hi def link cCppOut Comment - -let b:current_syntax = "c" - -unlet s:ft - -let &cpo = s:cpo_save -unlet s:cpo_save -" vim: ts=8 diff --git a/nvim/.config/nvim/syntax/cpp.vim b/nvim/.config/nvim/syntax/cpp.vim deleted file mode 100644 index a1f4170..0000000 --- a/nvim/.config/nvim/syntax/cpp.vim +++ /dev/null @@ -1,119 +0,0 @@ -" Vim syntax file -" Language: C++ -" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) -" Previous Maintainer: Ken Shan -" Last Change: 2015 Nov 10 - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -" Read the C syntax to start with -if version < 600 - so :p:h/c.vim -else - runtime! syntax/c.vim - unlet b:current_syntax -endif - -" C++ extensions -syn keyword cppStatement new delete this friend using -syn keyword cppAccess public protected private -syn keyword cppModifier inline virtual explicit export -syn keyword cppType bool wchar_t -syn keyword cppExceptions throw try catch -syn keyword cppOperator operator typeid -syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq -syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1 -syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$" -syn keyword cppStorageClass mutable -syn keyword cppStructure class typename template namespace -syn keyword cppBoolean true false -syn keyword cppConstant __cplusplus - -" C++ 11 extensions -if !exists("cpp_no_cpp11") - syn keyword cppModifier override final - syn keyword cppType nullptr_t - syn keyword cppExceptions noexcept - syn keyword cppStorageClass constexpr decltype thread_local - syn keyword cppConstant nullptr - syn keyword cppConstant ATOMIC_FLAG_INIT ATOMIC_VAR_INIT - syn keyword cppConstant ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE - syn keyword cppConstant ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE - syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE - syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE - syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE - syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell -endif - -" C++ 14 extensions -if !exists("cpp_no_cpp14") - syn match cppNumber display "\<0b[01]\+\(u\=l\{0,2}\|ll\=u\)\>" -endif - -" The minimum and maximum operators in GNU C++ -syn match cppMinMax "[<>]?" - -" Default highlighting -if version >= 508 || !exists("did_cpp_syntax_inits") - if version < 508 - let did_cpp_syntax_inits = 1 - command -nargs=+ HiLink hi link - else - command -nargs=+ HiLink hi def link - endif - HiLink cppAccess cppStatement - HiLink cppCast cppStatement - HiLink cppExceptions Exception - HiLink cppOperator Operator - HiLink cppStatement Statement - HiLink cppModifier Type - HiLink cppType Type - HiLink cppStorageClass StorageClass - HiLink cppStructure Structure - HiLink cppBoolean Boolean - HiLink cppConstant Constant - HiLink cppRawStringDelimiter Delimiter - HiLink cppRawString String - HiLink cppNumber Number - delcommand HiLink -endif - - -function! RawStringEnableCodeSnip(filetype,start,end,textSnipHl) abort - let ft=toupper(a:filetype) - let group='textGroup'.ft - if exists('b:current_syntax') - let s:current_syntax=b:current_syntax - " Remove current syntax definition, as some syntax files (e.g. cpp.vim) - " do nothing if b:current_syntax is defined. - unlet b:current_syntax - endif - execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim' - try - execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim' - catch - endtry - if exists('s:current_syntax') - let b:current_syntax=s:current_syntax - else - unlet b:current_syntax - endif - execute 'syntax region textSnip'.ft.' - \ matchgroup='.a:textSnipHl.' - \ start=+'.a:start.'+ end=+'.a:end.'+ - \ contains=@'.group -endfunction - - -call RawStringEnableCodeSnip("chaiscript", 'R"chaiscript(', ')chaiscript"', 'cppRawString') -call RawStringEnableCodeSnip("lua", 'R"lua(', ')lua"', 'cppRawString') - -let b:current_syntax = "cpp" - -" vim: ts=8 diff --git a/nvim/.config/nvim/syntax/lang.vim b/nvim/.config/nvim/syntax/lang.vim deleted file mode 100644 index d5285ae..0000000 --- a/nvim/.config/nvim/syntax/lang.vim +++ /dev/null @@ -1,39 +0,0 @@ -" quit when a syntax file was already loaded -if exists("b:current_syntax") - finish -endif -" @todo \ at end of line should continue on next line - -" Hello this is a test to see if it auto wraps the text when the text has been -" going on for way too long - -" syn match langSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" -" We only highlight valid escape characters as for now it just ignores unknown -" thing -syn match langSpecial display contained "\\[abfnrtv]" -syn match langError "^.\+" -syn keyword langTodo contained TODO FIXME XXX NOTE -syn match langTodo contained "@todo" -syn match langTodo contained "@note" -syn region langSection start="^\s*\[" end="\]" -syn match langKey "^.\{-}\ze=" -syn match langValue "[#=]\zs.*$" contains=langSub,langSpecial,langValue -syn match langValue contained "\\\n.\+" contains=langValue -" syn match langSub "{[^}]\+}" " This is for fmt support -syn match langSub "{\d\+}" -syn match langComment "[#;].*$" contains=langTodo - -hi def link langTodo Todo -hi def link langSpecial Special -hi def link langSection Type -hi def link langKey Identifier -hi def link langValue String -hi def link langValue2 String -hi def link langSub Constant -hi def link langComment Comment -hi def link langError Error - - -let b:current_syntax = "lang" - -" vim: sts=2 sw=2 et