Initial Commit
authorGeorgios Atheridis <georgios@atheridis.org>
Sun, 10 Mar 2024 04:40:04 +0000 (04:40 +0000)
committerGeorgios Atheridis <georgios@atheridis.org>
Sun, 10 Mar 2024 04:40:04 +0000 (04:40 +0000)
16 files changed:
colors/marked.lua [new file with mode: 0644]
init.lua [new file with mode: 0644]
lazy-lock.json [new file with mode: 0644]
lua/autopairs.lua [new file with mode: 0644]
lua/git.lua [new file with mode: 0644]
lua/keymaps.lua [new file with mode: 0644]
lua/lsp.lua [new file with mode: 0644]
lua/options.lua [new file with mode: 0644]
lua/plugins.lua [new file with mode: 0644]
lua/rainbow.lua [new file with mode: 0644]
lua/syntax-surf.lua [new file with mode: 0644]
lua/terminal.lua [new file with mode: 0644]
lua/treesitter.lua [new file with mode: 0644]
lua/undotree.lua [new file with mode: 0644]
queries/c/highlights.scm [new file with mode: 0644]
queries/python/highlights.scm [new file with mode: 0644]

diff --git a/colors/marked.lua b/colors/marked.lua
new file mode 100644 (file)
index 0000000..bdf5263
--- /dev/null
@@ -0,0 +1,377 @@
+vim.opt["background"] = "light"
+vim.g.VM_theme = "marked"
+
+-- vim.g.rainbow_delimiters = { fill = { fill = false } }
+-- vim.g.rainbow_delimiters = { fill = true }
+local rain = require 'rainbow-delimiters'
+vim.g.rainbow_delimiters = {
+       priority = {
+               [''] = 10,
+       },
+       fill = {
+               [''] = true,
+       },
+}
+
+-- local use_rainbow = true
+
+-- TODO:
+-- Add todo colors to comments
+-- Add Rainbow bracket colouring with full background
+-- Complete scm files for syntactic highlighting
+
+
+
+local p = {
+       black = "#000000",
+       white = "#ffffff",
+
+       background = "#ffffea",
+       float_background = "#eeeeda",
+       secondary_background = "#aeeeee",
+       selection = "#eeee9e",
+
+       comments = "#dddddd",
+
+       green = "#c0f0b0",
+       blue = "#b0c0f0",
+       red = "#f0c0b0",
+
+       -- Only use for special cases
+       magenta = "#f0f0b0",
+       yellow = "#f0b0f0",
+       cyan = "#b0f0f0",
+       gray = "#d0d0d0",
+
+       errors = "#a0342f",
+       warnings = "#f0ad4e",
+       hints = "#777777",
+       infos = "#3060a0",
+
+       diff_remove = "#a0342f",
+       diff_change = "#f0ad4e",
+       diff_add = "#30a060",
+
+}
+
+local colors = {
+       default = { fg = p.black, },
+
+       bgSecondary = { bg = p.secondary_background, },
+       selected = { fg = p.black, bg = p.selection, },
+
+       buffBG = { bg = p.secondary_background, },
+       buffSelected = { fg = p.secondary_background, },
+
+       diffAdd = { fg = p.white, bg = p.diff_add, },
+       diffChange = { fg = p.black, bg = p.diff_change, },
+       diffRemove = { fg = p.white, bg = p.diff_remove, },
+
+       errorMsg = { fg = p.errors, bg = p.white, bold = true, },
+       warnMsg = { fg = p.warnings, bg = p.white, bold = true, },
+       hintMsg = { fg = p.hints, bg = p.white, bold = true, },
+       infoMsg = { fg = p.infos, bg = p.white, bold = true, },
+
+       comment = { fg = p.black, bg = p.comments, },
+       nums = { fg = p.black, bg = p.blue, },
+       bool = { fg = p.black, bg = p.blue, },
+       char = { fg = p.black, bg = p.blue, },
+       const = { fg = p.black, },
+       string = { fg = p.black, bg = p.green, },
+       operator = { fg = p.black, },
+       keyword = { fg = p.black, },
+       identifier = { fg = p.black, },
+       func = { fg = p.black, },
+       include = { fg = p.black, },
+       type = { fg = p.black, bg = p.red },
+
+       error = { fg = p.white, bg = p.errors, bold = true, },
+       warn = { fg = p.black, bg = p.warnings, bold = true, },
+       hint = { fg = p.white, bg = p.hints, bold = true, },
+       info = { fg = p.white, bg = p.infos, bold = true, },
+
+       uri = { underline = true, },
+       tag = { fg = p.black, bg = p.red, },
+
+
+       -- Control Flow
+       branch = { fg = p.black, bg = p.green, },
+       loop = { fg = p.black, bg = p.red, },
+       goto_ = { fg = p.black, bg = p.blue, },
+
+       -- Brackets
+       b_green = { fg = p.black, bg = p.green, },
+       b_red = { fg = p.black, bg = p.red, },
+       b_blue = { fg = p.black, bg = p.blue, },
+       b_magenta = { fg = p.black, bg = p.magenta, },
+       b_yellow = { fg = p.black, bg = p.yellow, },
+       b_cyan = { fg = p.black, bg = p.cyan, },
+       b_gray = { fg = p.black, bg = p.gray, },
+}
+
+local marked = {
+       -- Unchanged
+       Normal = { fg = p.black, bg = p.background },
+       NormalFloat = { fg = p.black, bg = p.float_background },
+       CursorColumn = colors.bgSecondary,
+       CursorLine = colors.bgSecondary,
+
+       Comment = colors.comment,
+
+       DiffAdd = colors.diffAdd,
+       DiffChange = colors.diffChange,
+       DiffDelete = colors.diffRemove,
+
+       ErrorMsg = colors.errorMsg,
+       VertSplit = colors.default,
+
+       Search = colors.selected,
+       IncSearch = colors.selected,
+
+       MatchParen = colors.selected,
+
+       NonText = { fg = "#2080a0" },
+
+       -- Popup Menu
+       Pmenu = { link = "NormalFloat" },
+       PmenuSel = colors.selected,
+       PmenuThumb = colors.bgSecondary,
+
+       Visual = colors.selected,
+       VisualNOS = colors.selected,
+
+       WinSeparator = colors.bgSecondary,
+
+       -- Rainbow Brackets
+       RainbowDelimiterRed = colors.b_green,
+       RainbowDelimiterYellow = colors.b_red,
+       RainbowDelimiterBlue = colors.b_blue,
+       RainbowDelimiterOrange = colors.b_magenta,
+       RainbowDelimiterGreen = colors.b_yellow,
+       RainbowDelimiterViolet = colors.b_cyan,
+       RainbowDelimiterCyan = colors.b_gray,
+
+
+       -- Diff
+       diffAdded = colors.diffAdd,
+       diffRemoved = colors.diffRemove,
+       diffNewFile = colors.diffAdd,
+       diffOldFile = colors.diffRemove,
+       gitcommitSelectedType = colors.diffChange,
+       gitcommitFile = colors.string,
+       gitcommitBranch = colors.string,
+       gitcommitHeader = colors.comment,
+       diffIndexLine = colors.nums,
+
+       -- Git Signs
+       GitSignsAdd = colors.diffAdd,
+       GitSignsChange = colors.diffChange,
+       GitSignsDelete = colors.diffRemove,
+       GitSignsCurrentLineBlame = colors.comment,
+
+       -- -- LSP
+       DiagnosticError = colors.errorMsg,
+       DiagnosticWarn = colors.warnMsg,
+       DiagnosticHint = colors.hintMsg,
+       DiagnosticInfo = colors.infoMsg,
+       DiagnosticSignError = colors.error,
+       DiagnosticSignWarn = colors.warn,
+       DiagnosticSignHint = colors.hint,
+       DiagnosticSignInfo = colors.info,
+       DiagnosticUnderlineError = colors.error,
+       DiagnosticUnderlineWarn = colors.warn,
+       DiagnosticUnderlineHint = colors.hint,
+       DiagnosticUnderlineInfo = colors.info,
+
+       -- Leap
+       LeapLabelPrimary = colors.info,
+
+       -- Nvim Tree
+       NvimTreeWinSeparator = colors.bgSecondary,
+       NvimTreeRootFolder = colors.default,
+       NvimTreeFolderName = colors.nums,
+       NvimTreeExecFile = colors.string,
+       NvimTreeSpecialFile = colors.string,
+       NvimTreeSymlink = colors.uri,
+       NvimTreeGitNew = colors.diffAdd,
+       nvimTreeGitDirty = colors.diffChange,
+       NvimTreeGitDeleted = colors.diffRemove,
+       NvimTreeGitRenamed = colors.diffChange,
+
+
+       -- Removed
+       Operator = colors.default,
+       Keyword = colors.default,
+       Keywords = colors.default,
+       Identifier = colors.default,
+       Function = colors.default,
+       Statement = colors.default,
+       Conditional = colors.default,
+       Repeat = colors.default,
+       Label = colors.default,
+       Exception = colors.default,
+       PreProc = colors.default,
+       Include = colors.default,
+       Define = colors.default,
+       Title = colors.default,
+       Macro = colors.default,
+       PreCondit = colors.default,
+       StorageClass = colors.default,
+       Structure = colors.default,
+       Special = colors.default,
+       SpecialComment = colors.default,
+
+       SignColumn = colors.default,
+       Conceal = colors.default,
+       CursorLineNr = colors.default,
+       ColorColumn = colors.default,
+       StatusLine = colors.default,
+       StatusLineNC = colors.default,
+       StatusLineTerm = colors.default,
+       StatusLineTermNC = colors.default,
+       Directory = colors.default,
+       MoreMsg = colors.default,
+       ModeMsg = colors.default,
+
+       LineNr = colors.default,
+
+       ["@text.uri"] = colors.uri,
+       ["@container"] = colors.string,
+
+       --- Temporary Bug Fixes
+       -- markdownError = colors.default,
+}
+
+local disable = {
+       -- Enable
+       String = colors.default,
+       Constant = colors.default,
+       Character = colors.default,
+       Number = colors.default,
+       Boolean = colors.default,
+       Float = colors.default,
+       Type = colors.default,
+       TypeDef = colors.default,
+
+       ["@string.escape"] = colors.default,
+       ["@tag"] = colors.default,
+       ["@tag.attribute"] = colors.default,
+
+       -- Disable
+       ["@branch"] = colors.default,
+       ["@loop"] = colors.default,
+       ["@goto"] = colors.default,
+}
+
+local default = {
+       -- Enable
+       String = colors.string,
+       Constant = colors.const,
+       Character = colors.char,
+       Number = colors.nums,
+       Boolean = colors.bool,
+       Float = colors.nums,
+       Type = colors.type,
+       TypeDef = colors.type,
+
+       ["@string.escape"] = colors.nums,
+       ["@tag"] = colors.tag,
+       ["@tag.attribute"] = colors.nums,
+
+       -- Disable
+       ["@branch"] = colors.default,
+       ["@loop"] = colors.default,
+       ["@goto"] = colors.default,
+}
+
+local control_flow = {
+       -- Enable
+       ["@branch"] = colors.branch,
+       ["@loop"] = colors.loop,
+       ["@goto"] = colors.goto_,
+
+       -- Disable
+       String = colors.default,
+       Constant = colors.default,
+       Character = colors.default,
+       Number = colors.default,
+       Boolean = colors.default,
+       Float = colors.default,
+       Type = colors.default,
+       TypeDef = colors.default,
+
+       ["@string.escape"] = colors.default,
+       ["@tag"] = colors.default,
+       ["@tag.attribute"] = colors.default,
+}
+
+-- - `RainbowDelimiterRed`
+-- - `RainbowDelimiterYellow`
+-- - `RainbowDelimiterBlue`
+-- - `RainbowDelimiterOrange`
+-- - `RainbowDelimiterGreen`
+-- - `RainbowDelimiterViolet`
+-- - `RainbowDelimiterCyan`
+
+
+for c_name, color in pairs(marked) do
+       vim.api.nvim_set_hl(0, c_name, color)
+end
+for c_name, color in pairs(default) do
+       vim.api.nvim_set_hl(0, c_name, color)
+end
+
+local modes = {
+       normal = {
+               a = colors.bgSecondary,
+               b = colors.bgSecondary,
+               c = colors.bgSecondary,
+       },
+}
+require('lualine').setup { options = { theme = modes } }
+
+local set_default = function()
+       rain.disable(0)
+       for c_name, color in pairs(default) do
+               vim.api.nvim_set_hl(0, c_name, color)
+       end
+       -- use_rainbow = false
+end
+
+local set_control_flow = function()
+       rain.disable(0)
+       for c_name, color in pairs(control_flow) do
+               vim.api.nvim_set_hl(0, c_name, color)
+       end
+       -- use_rainbow = false
+end
+local set_brackets = function()
+       -- use_rainbow = true
+       rain.enable(0)
+       for c_name, color in pairs(marked) do
+               vim.api.nvim_set_hl(0, c_name, color)
+       end
+       for c_name, color in pairs(disable) do
+               vim.api.nvim_set_hl(0, c_name, color)
+       end
+end
+vim.keymap.set("n", "<F1>", set_default, {})
+vim.keymap.set("n", "<F2>", set_control_flow, {})
+vim.keymap.set("n", "<F3>", set_brackets, {})
+
+
+vim.api.nvim_create_autocmd("BufNew", {
+       callback = function(opts)
+               rain.disable(opts.buf)
+       end
+})
+vim.api.nvim_create_autocmd("BufEnter", {
+       callback = function(opts)
+               rain.disable(opts.buf)
+       end
+})
+vim.api.nvim_create_autocmd("BufAdd", {
+       callback = function(opts)
+               rain.disable(opts.buf)
+       end
+})
diff --git a/init.lua b/init.lua
new file mode 100644 (file)
index 0000000..9cea789
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,38 @@
+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)
+
+require("plugins")
+
+
+require("keymaps")
+require("options")
+require("lsp")
+require("autopairs")
+require("undotree")
+require("terminal")
+require("git")
+require("Comment").setup()
+require('lualine').setup()
+require("nvim-surround").setup()
+require('nvim-ts-autotag').setup()
+require('leap').add_default_mappings()
+require("nvim-tree").setup({
+        git = {
+                enable = true,
+        },
+        filters = {
+                git_ignored = true,
+        }
+})
+require("telescope").load_extension("frecency")
+vim.cmd [[colorscheme marked]]
diff --git a/lazy-lock.json b/lazy-lock.json
new file mode 100644 (file)
index 0000000..4681a0f
--- /dev/null
@@ -0,0 +1,41 @@
+{
+  "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
+  "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
+  "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
+  "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
+  "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
+  "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
+  "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" },
+  "dashboard-nvim": { "branch": "master", "commit": "04a48b2e230bc5e50dd099d839443703023b0472" },
+  "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" },
+  "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" },
+  "leap-ast.nvim": { "branch": "main", "commit": "1a21b70505ebb868a1e196c0d63797e1426b53a5" },
+  "leap.nvim": { "branch": "main", "commit": "e285f3c9a3fb11367f859faf553d28f332da0a2c" },
+  "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" },
+  "mason-lspconfig.nvim": { "branch": "main", "commit": "0954d7730e749d606ddf8d7ae8846848be435d53" },
+  "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
+  "neovim-project": { "branch": "main", "commit": "e7868b38f402be94e859d479002df1418bc1e954" },
+  "neovim-session-manager": { "branch": "master", "commit": "07bb62583769abd9d32f88f428ea58248730ac7a" },
+  "none-ls.nvim": { "branch": "main", "commit": "c10b7be7751aee820a02f2d1fafe76bc316fe223" },
+  "nvim-autopairs": { "branch": "master", "commit": "096d0baecc34f6c5d8a6dd25851e9d5ad338209b" },
+  "nvim-bufsurf": { "branch": "master", "commit": "7f3ee99a7605dd0a06496fb0ceb3125492190aa0" },
+  "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" },
+  "nvim-lspconfig": { "branch": "master", "commit": "0a1a2aa549da0d2294e072e2d725f02cca32f64e" },
+  "nvim-surround": { "branch": "main", "commit": "f81bbef3da28bd2a7d5a736575c71f3f953d49f9" },
+  "nvim-tree.lua": { "branch": "master", "commit": "8cbb1db8e90b62fc56f379992e622e9f919792ce" },
+  "nvim-treesitter": { "branch": "master", "commit": "5973b617a9a48212e40c5c0a0727ad7c91b27484" },
+  "nvim-treesitter-context": { "branch": "master", "commit": "9c06b115abc57c99cf0aa81dc29490f5001f57a1" },
+  "nvim-treesitter-textobjects": { "branch": "master", "commit": "8edd5a6d96936bdff23333d3bc177481388839e5" },
+  "nvim-ts-autotag": { "branch": "main", "commit": "a65b202cfd08e0e69e531eab737205ff5bc082a4" },
+  "nvim-web-devicons": { "branch": "master", "commit": "313d9e7193354c5de7cdb1724f9e2d3f442780b0" },
+  "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
+  "rainbow-delimiters": { "branch": "feature/fill", "commit": "d32ad456a9d736987e603d6631b7c9af7f19659f" },
+  "syntax-tree-surfer": { "branch": "master", "commit": "732ea6d0f868bcccd2f526be73afa46997d5a2fb" },
+  "telescope-frecency.nvim": { "branch": "master", "commit": "a61ede8740643f09e1a7706fbb49b152e8f25d42" },
+  "telescope.nvim": { "branch": "master", "commit": "236083884cfe6c874e03e6cb4e7cb08809c1333c" },
+  "toggleterm.nvim": { "branch": "main", "commit": "b49df5cdce67a8964d1b027dae94bde212092b51" },
+  "undotree": { "branch": "master", "commit": "7df3be7a261ea31b528aa442b494fcb458f3d968" },
+  "vim-visual-multi": { "branch": "master", "commit": "e67f7fa011c98fc5426352d3bb06362a0f70af3c" },
+  "vim-vsnip": { "branch": "master", "commit": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9" },
+  "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
+}
\ No newline at end of file
diff --git a/lua/autopairs.lua b/lua/autopairs.lua
new file mode 100644 (file)
index 0000000..5212e39
--- /dev/null
@@ -0,0 +1,43 @@
+local status_ok, npairs = pcall(require, "nvim-autopairs")
+if not status_ok then
+        vim.notify("Error with autopairs")
+        return
+end
+
+local Rule = require("nvim-autopairs.rule")
+
+npairs.setup()
+
+--Add spaces between brackets
+npairs.add_rules({
+        Rule("{%", "%"),
+        Rule("{% ", " "),
+        Rule(" ", " "):with_pair(function(opts)
+                local pair = opts.line:sub(opts.col - 1, opts.col)
+                return vim.tbl_contains({ "()", "[]", "{}" }, pair)
+        end),
+        Rule("( ", " )")
+            :with_pair(function()
+                    return false
+            end)
+            :with_move(function(opts)
+                    return opts.prev_char:match(".%)") ~= nil
+            end)
+            :use_key(")"),
+        Rule("{ ", " }")
+            :with_pair(function()
+                    return false
+            end)
+            :with_move(function(opts)
+                    return opts.prev_char:match(".%}") ~= nil
+            end)
+            :use_key("}"),
+        Rule("[ ", " ]")
+            :with_pair(function()
+                    return false
+            end)
+            :with_move(function(opts)
+                    return opts.prev_char:match(".%]") ~= nil
+            end)
+            :use_key("]"),
+})
diff --git a/lua/git.lua b/lua/git.lua
new file mode 100644 (file)
index 0000000..e3f9d0d
--- /dev/null
@@ -0,0 +1,20 @@
+require('gitsigns').setup({
+        signs                   = {
+                add          = { text = ' ' },
+                change       = { text = ' ' },
+                delete       = { text = 'â–‚' },
+                topdelete    = { text = 'â–”' },
+                changedelete = { text = ' ' },
+                untracked    = { text = 'â–’' },
+        },
+       signcolumn = true,
+        current_line_blame_opts = {
+                virt_text = true,
+                virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
+                delay = 0,
+                ignore_whitespace = false,
+                virt_text_priority = 100,
+        },
+        numhl                   = false,
+        linehl                  = false,
+})
diff --git a/lua/keymaps.lua b/lua/keymaps.lua
new file mode 100644 (file)
index 0000000..1dbac26
--- /dev/null
@@ -0,0 +1,165 @@
+local opts = { noremap = true, silent = true }
+
+local function nnoremap(shortcut, command)
+       vim.keymap.set("n", shortcut, command, opts)
+end
+local function inoremap(shortcut, command)
+       vim.keymap.set("i", shortcut, command, opts)
+end
+local function vnoremap(shortcut, command)
+       vim.keymap.set("v", shortcut, command, opts)
+end
+local function xnoremap(shortcut, command)
+       vim.keymap.set("x", shortcut, command, opts)
+end
+local function tnoremap(shortcut, command)
+       vim.keymap.set("t", shortcut, command, opts)
+end
+
+local telescope = require("telescope.builtin")
+
+-- Map Leader
+vim.g.mapleader = "\\"
+vim.g.maplocalleader = "\\"
+
+
+-- Normal Y behaviour
+nnoremap("Y", "y$")
+
+-- Window navigation
+nnoremap("<C-h>", "<C-w>h")
+nnoremap("<C-j>", "<C-w>j")
+nnoremap("<C-k>", "<C-w>k")
+nnoremap("<C-l>", "<C-w>l")
+
+-- Window resize
+nnoremap("<M-h>", "<CMD>vertical resize -2<CR>")
+nnoremap("<M-j>", "<CMD>resize +2<CR>")
+nnoremap("<M-k>", "<CMD>resize -2<CR>")
+nnoremap("<M-l>", "<CMD>vertical resize +2<CR>")
+
+-- Buffer navigation
+nnoremap("<C-s>", "<CMD>Telescope live_grep theme=ivy<CR>")
+nnoremap("<C-b>", "<CMD>Telescope buffers theme=ivy<CR>")
+nnoremap("<C-f>", "<CMD>Telescope frecency workspace=CWD theme=ivy<CR>")
+nnoremap("L", "<CMD>BufSurfForward<CR>")
+nnoremap("H", "<CMD>BufSurfBack<CR>")
+
+-- Navigation
+nnoremap("`", "<CMD>Telescope marks theme=ivy<CR>")
+nnoremap("<M-r>", "<CMD>Telescope lsp_references theme=ivy<CR>")
+nnoremap("<M-b>", "<CMD>Telescope current_buffer_fuzzy_find theme=ivy<CR>")
+nnoremap("<M-d>", "<CMD>Telescope treesitter theme=ivy<CR>")
+
+-- Project Management
+local create_project = function ()
+       local project_name = vim.fn.input("Project name: ")
+       vim.loop.fs_mkdir("/home/georgios/Projects/" .. project_name, 448)
+end
+nnoremap("<leader>c", create_project)
+-- nnoremap("<leader>c", ":mkdir ~/Projects/")
+nnoremap("<leader>o", "<CMD>Telescope neovim-project discover<CR>")
+
+-- Move text up and down
+xnoremap("J", ":move '>+1<CR>gv-gv")
+xnoremap("K", ":move '<-2<CR>gv-gv")
+
+nnoremap("<leader>x", ":%!xxd<CR>")
+nnoremap("<leader>X", ":%!xxd -r<CR>")
+
+-- Folding
+-- nnoremap("<CR>", "za")
+vnoremap("<M-\\>", require("leap-ast").leap)
+-- vim.keymap.set({ 'n', 'x', 'o', 'v' }, "-", require("leap-ast").leap, { noremap = true, silent = true })
+vim.keymap.set({ 'n' }, "<M-s>", "v<M-\\>", { remap = true })
+-- vim.cmd("nmap <M-s> V-")
+
+-- Multikey
+nnoremap("<C-c>", ":<C-u>call vm#commands#add_cursor_down(0, v:count1)<CR>")
+nnoremap("<M-c>", ":<C-u>call vm#commands#add_cursor_up(0, v:count1)<CR>")
+
+local wk = require("which-key")
+
+-- Tree
+wk.register({
+       ["<leader>e"] = { vim.cmd.NvimTreeToggle, "File Tree" },
+       ["<leader>u"] = { vim.cmd.UndotreeToggle, "Undo Tree" },
+       ["<leader>i"] = { vim.cmd.InspectTree, "Inspect Tree" },
+})
+
+-- Telescope
+wk.register({
+       ["<leader>s"]  = { name = "Search" },
+       -- ["<leader>sf"] = { telescope.find_files, "Find Files" },
+       ["<leader>sf"] = { "<CMD>Telescope frecency workspace=CWD<CR>", "Search Files" },
+       ["<leader>ss"] = { telescope.live_grep, "Grep" },
+       ["<leader>sg"] = { telescope.grep_string, "Grep String Under Cursor" },
+       ["<leader>sM"] = { telescope.man_pages, "Man Pages" },
+       ["<leader>sm"] = { telescope.marks, "List Marks" },
+       ["<leader>sh"] = { telescope.help_tags, "Help Tags" },
+       ["<leader>sb"] = { telescope.buffers, "Buffers" },
+       ["<leader>sr"] = { telescope.lsp_references, "References" },
+       ["<leader>sG"] = { telescope.git_files, "Find Git Files" },
+       ["<leader>sS"] = { telescope.treesitter, "Symbols" },
+})
+
+
+-- LSP Keymaps
+wk.register({
+       ["<leader>l"]  = { name = "LSP" },
+       ["<leader>lD"] = { vim.lsp.buf.declaration, "Goto Declarations" },
+       ["<leader>ld"] = { vim.lsp.buf.definition, "Goto Definition" },
+       ["<leader>li"] = { vim.lsp.buf.implementation, "Goto Implementation" },
+       ["<leader>lh"] = { vim.lsp.buf.hover, "Show Documentation" },
+       ["<leader>lr"] = { vim.lsp.buf.rename, "Rename" },
+       ["<leader>lR"] = { telescope.lsp_references, "Goto References" },
+       ["<leader>la"] = { vim.lsp.buf.code_action, "Code Action" },
+       ["<leader>lf"] = { vim.lsp.buf.format, "Format Code" },
+})
+wk.register({
+       ["<leader>d"]  = { name = "Diagnostics" },
+       ["<leader>df"] = { vim.diagnostic.open_float(), "Show Diagnostics in Line" },
+       ["<leader>dp"] = { function() vim.diagnostic.goto_prev({ border = "rounded" }) end, "Goto Prev Diagnostic" },
+       ["<leader>dn"] = { function() vim.diagnostic.goto_next({ border = "rounded" }) end, "Goto Next Diagnostic" },
+       ["<leader>da"] = { telescope.diagnostics, "Show Open Diagnostics" },
+       -- ["<leader>da"] = { vim.diagnostic.setloclist(), "Show All Diagnostics in Buffer" },
+})
+nnoremap("gD", vim.lsp.buf.declaration)
+nnoremap("gd", vim.lsp.buf.definition)
+nnoremap("gi", vim.lsp.buf.implementation)
+nnoremap("gr", vim.lsp.buf.references)
+nnoremap("K", vim.lsp.buf.hover)
+nnoremap("[d", function() vim.diagnostic.goto_prev({ border = "rounded" }) end)
+nnoremap("]d", function() vim.diagnostic.goto_next({ border = "rounded" }) end)
+
+
+-- Gitsigns
+local gs = require("gitsigns")
+wk.register({
+       ["<leader>g"] = { name = "Git" },
+       ["<leader>gj"] = { gs.next_hunk, "Next Hunk" },
+       ["<leader>gk"] = { gs.prev_hunk, "Prev Hunk" },
+       ["<leader>gs"] = { function() gs.stage_hunk { vim.fn.line("."), vim.fn.line("v") } end, "Stage Hunk" },
+       ["<leader>gr"] = { function() gs.reset_hunk { vim.fn.line("."), vim.fn.line("v") } end, "Reset Hunk" },
+       ["<leader>gp"] = { gs.preview_hunk, "Preview Hunk" },
+       ["<leader>gu"] = { gs.undo_stage_hunk, "Undo Stage Hunk" },
+       ["<leader>gS"] = { gs.stage_buffer, "Stage Buffer" },
+       ["<leader>gb"] = { function() gs.blame_line { vim.fn.line("."), vim.fn.line("v") } end, "Blame Line" },
+       ["<leader>gB"] = { gs.toggle_current_line_blame, "Toggle Blame Line" },
+       ["<leader>gR"] = { gs.reset_buffer, "Reset Buffer" },
+       ["<leader>gd"] = { gs.diffthis, "Diff" },
+       ["<leader>gD"] = { function() gs.diffthis("~") end, "Diff2" },
+       ["<leader>gx"] = { gs.toggle_deleted, "Toggle Deleted" },
+       ["<leader>gc"] = { telescope.git_bcommits, "Buffer Commits" },
+       ["<leader>gC"] = { telescope.git_commits, "Commits" },
+       ["<leader>gn"] = { telescope.git_branches, "Branches" },
+})
+-- -- Text object
+-- map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
+
+nnoremap("yi_", "T_yt_")
+nnoremap("ya_", "F_yf_")
+nnoremap("di_", "T_dt_")
+nnoremap("da_", "F_df_")
+nnoremap("ci_", "T_ct_")
+nnoremap("ca_", "F_cf_")
diff --git a/lua/lsp.lua b/lua/lsp.lua
new file mode 100644 (file)
index 0000000..7e3cd20
--- /dev/null
@@ -0,0 +1,174 @@
+local status_ok_mason, mason = pcall(require, "mason")
+if not status_ok_mason then
+       vim.notify("Error with mason")
+       return
+end
+mason.setup()
+
+local status_ok_mason_lspconfig, mason_lspconfig = pcall(require, "mason-lspconfig")
+if not status_ok_mason_lspconfig then
+       vim.notify("Error with mason-lspconfig")
+       return
+end
+mason_lspconfig.setup()
+
+local status_ok_treesitter, treesitter = pcall(require, "nvim-treesitter")
+if not status_ok_treesitter then
+       vim.notify("Error with nvim-treesitter")
+       return
+end
+treesitter.setup()
+vim.cmd("TSEnable highlight")
+
+local status_ok_cmp, cmp = pcall(require, "cmp")
+if not status_ok_cmp then
+       vim.notify("Error with cmp")
+       return
+end
+local has_words_before = function()
+       unpack = unpack or table.unpack
+       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,
+       },
+       window = {
+               completion = cmp.config.window.bordered(),
+               documentation = cmp.config.window.bordered(),
+       },
+       mapping = cmp.mapping.preset.insert({
+               ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+               ['<C-f>'] = cmp.mapping.scroll_docs(4),
+               ['<C-Space>'] = cmp.mapping.complete(),
+               ['<C-e>'] = cmp.mapping.abort(),
+               ['<CR>'] = cmp.mapping.confirm({ select = false }),
+               ['<TAB>'] = cmp.mapping(cmp.mapping.select_next_item()),
+               ['<S-TAB>'] = cmp.mapping(cmp.mapping.select_prev_item()),
+               ["<Tab>"] = cmp.mapping(function(fallback)
+                       if cmp.visible() then
+                               cmp.select_next_item()
+                       elseif vim.fn["vsnip#available"](1) == 1 then
+                               feedkey("<Plug>(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 `<Tab>`.
+                       end
+               end, { "i", "s" }),
+
+               ["<S-Tab>"] = cmp.mapping(function()
+                       if cmp.visible() then
+                               cmp.select_prev_item()
+                       elseif vim.fn["vsnip#jumpable"](-1) == 1 then
+                               feedkey("<Plug>(vsnip-jump-prev)", "")
+                       end
+               end, { "i", "s" }),
+       }),
+       sources = {
+               {
+                       name = "nvim_lsp",
+                       -- entry_filter = function(entry, ctx)
+                       --      return cmp.lsp.CompletionItemKind.Text ~= entry:get_kind()
+                       -- end
+               },
+               { name = "nvim_lua" },
+               { name = "vsnip" },
+               -- { name = "buffer" },
+               { name = "path" },
+       },
+})
+
+-- `/` cmdline setup.
+cmp.setup.cmdline('/', {
+       mapping = cmp.mapping.preset.cmdline(),
+       sources = {
+               { name = 'buffer' }
+       }
+})
+-- `:` cmdline setup.
+cmp.setup.cmdline(':', {
+       mapping = cmp.mapping.preset.cmdline(),
+       sources = cmp.config.sources({
+               { name = 'path' }
+       }, {
+               {
+                       name = 'cmdline',
+                       option = {
+                               ignore_cmds = { 'Man', '!' }
+                       }
+               }
+       })
+})
+
+local status_ok_cmp_nvim_lsp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
+if not status_ok_cmp_nvim_lsp then
+       vim.notify("Error with cmp_nvim_lsp")
+       return
+end
+local capabilities = cmp_nvim_lsp.default_capabilities()
+local on_attach = function(client, bufnr)
+       if client.name == "tsserver" or client.name == "sumneko_lua" then
+               client.server_capabilities.document_formatting = false
+       end
+       -- lsp_keymaps(bufnr)
+       -- lsp_highlight_document(client)
+end
+
+-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
+-- require('lspconfig')['pylsp'].setup {
+--         capabilities = capabilities
+-- }
+require("lspconfig")["cmake"].setup({
+       capabilities = capabilities,
+})
+require("lspconfig")["nimls"].setup({
+       capabilities = capabilities,
+})
+require("lspconfig")["hls"].setup({
+       capabilities = capabilities,
+})
+require('lspconfig')['pylsp'].setup {
+        on_attach = on_attach,
+        capabilities = capabilities,
+}
+require('lspconfig')['clangd'].setup {
+       capabilities = capabilities,
+}
+require("lspconfig")["gopls"].setup {
+       capabilities = capabilities,
+}
+require("lspconfig")["lemminx"].setup {
+       capabilities = capabilities,
+}
+require('lspconfig')['lua_ls'].setup {
+       capabilities = capabilities,
+       settings = {
+               Lua = {
+                       diagnostics = {
+                               globals = { 'vim' }
+                       }
+               }
+       },
+}
+
+local status_ok_null_ls, null_ls = pcall(require, "null-ls")
+if status_ok_null_ls then
+       null_ls.setup({
+               sources = {
+                       null_ls.builtins.formatting.clang_format,
+                       null_ls.builtins.formatting.black,
+                       null_ls.builtins.formatting.isort,
+                       null_ls.builtins.formatting.prettier,
+                       null_ls.builtins.diagnostics.mypy,
+                       null_ls.builtins.diagnostics.flake8,
+               },
+       })
+end
diff --git a/lua/options.lua b/lua/options.lua
new file mode 100644 (file)
index 0000000..b67a502
--- /dev/null
@@ -0,0 +1,46 @@
+vim.cmd("autocmd BufEnter * set formatoptions-=cro")
+vim.cmd("autocmd BufEnter * setlocal formatoptions-=cro")
+
+local options = {
+       backup = true,
+       backupdir = os.getenv("HOME") .. "/.nvim_saves/backup/",
+       dir = os.getenv("HOME") .. "/.nvim_saves/swap/",
+       clipboard = "unnamedplus",
+       cmdheight = 1,
+       completeopt = { "menuone", "noselect" },
+       conceallevel = 0,
+       fileencoding = "utf-8",
+       hlsearch = false,
+       showtabline = 0,
+       pumheight = 10,
+       smartcase = true,
+       smartindent = true,
+       splitbelow = true,
+       splitright = true,
+       swapfile = true,
+       termguicolors = true,
+       timeout = true,
+       timeoutlen = 0,
+       undofile = true,
+       updatetime = 300,
+       writebackup = false,
+       expandtab = false,
+       shiftwidth = 8,
+       tabstop = 8,
+       number = true,
+       relativenumber = false,
+       cursorline = true,
+       numberwidth = 4,
+       signcolumn = "yes",
+       wrap = false,
+       scrolloff = 5,
+       sidescrolloff = 2,
+       guifont = "FiraMono Nerd Font Mono:h10",
+       list = true,
+}
+
+vim.opt.shortmess:append("c")
+
+for k, v in pairs(options) do
+       vim.opt[k] = v
+end
diff --git a/lua/plugins.lua b/lua/plugins.lua
new file mode 100644 (file)
index 0000000..5444b0d
--- /dev/null
@@ -0,0 +1,78 @@
+require("lazy").setup({
+       -- Lib
+       "nvim-lua/plenary.nvim",
+       "nvim-tree/nvim-web-devicons",
+
+       -- UI
+       "nvim-lualine/lualine.nvim",
+       "nvim-tree/nvim-tree.lua",
+       "akinsho/toggleterm.nvim",
+       "folke/which-key.nvim",
+       {
+               'nvimdev/dashboard-nvim',
+               event = 'VimEnter',
+               config = function()
+                       require('dashboard').setup {
+                               -- config
+                       }
+               end,
+               dependencies = { { 'nvim-tree/nvim-web-devicons' } }
+       },
+       {
+               "coffebar/neovim-project",
+               opts = {
+                       projects = { -- define project roots
+                               "~/Projects/*",
+                               "~/.config/*",
+                       },
+               },
+               init = function()
+                       -- enable saving the state of plugins in the session
+                       vim.opt.sessionoptions:append("globals") -- save global variables that start with an uppercase letter and contain at least one lowercase letter.
+               end,
+               dependencies = {
+                       { "nvim-lua/plenary.nvim" },
+                       { "nvim-telescope/telescope.nvim", tag = "0.1.4" },
+                       { "Shatur/neovim-session-manager" },
+               },
+               lazy = false,
+               priority = 100,
+       },
+
+       -- Lsp
+       -- Snippets
+       "neovim/nvim-lspconfig",
+       "hrsh7th/cmp-nvim-lsp",
+       "hrsh7th/cmp-buffer",
+       "hrsh7th/cmp-path",
+       "hrsh7th/cmp-cmdline",
+       "hrsh7th/nvim-cmp",
+       "hrsh7th/cmp-vsnip",
+       "hrsh7th/vim-vsnip",
+       "hrsh7th/cmp-nvim-lua",
+
+       "williamboman/mason.nvim",
+       "williamboman/mason-lspconfig.nvim",
+       "nvimtools/none-ls.nvim",
+       "nvim-treesitter/nvim-treesitter",
+       "nvim-treesitter/nvim-treesitter-textobjects",
+
+       -- Other
+       "windwp/nvim-autopairs",
+       "windwp/nvim-ts-autotag",
+       "CJYLZS/nvim-bufsurf",
+       "numToStr/Comment.nvim",
+       "lewis6991/gitsigns.nvim",
+       "ggandor/leap.nvim",
+       "ggandor/leap-ast.nvim",
+       "kylechui/nvim-surround",
+       "ziontee113/syntax-tree-surfer",
+       "nvim-telescope/telescope.nvim",
+       "nvim-telescope/telescope-frecency.nvim",
+       "nvim-treesitter/nvim-treesitter-context",
+       "mbbill/undotree",
+       "mg979/vim-visual-multi",
+
+       -- "hiphish/rainbow-delimiters.nvim",
+       { "https://git.atheridis.org/nvim-extras/rainbow-delimiters.git", branch = "feature/fill" },
+})
diff --git a/lua/rainbow.lua b/lua/rainbow.lua
new file mode 100644 (file)
index 0000000..35021d0
--- /dev/null
@@ -0,0 +1,226 @@
+--[[
+   Copyright 2020-2022 Chinmay Dalal
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+--]]
+
+local queries = require("nvim-treesitter.query")
+local parsers = require("nvim-treesitter.parsers")
+local configs = require("nvim-treesitter.configs")
+local api = vim.api
+
+local add_predicate = vim.treesitter.query.add_predicate
+local nsid = vim.api.nvim_create_namespace("rainbow_ns")
+local extended_languages = { "latex", "html", "verilog", "jsx" }
+local colors = configs.get_module("rainbow").colors
+local termcolors = configs.get_module("rainbow").termcolors
+
+--- Maps a buffer ID to the buffer's parser; retaining a reference prevents the
+--- parser from getting garbage-collected.
+local buffer_parsers = {}
+
+--- Find the nesting level of a node.
+--- @param node table # Node to find the level of
+--- @param len number # Number of colours
+--- @param levels table # Levels for the language
+local function color_no(node, len, levels)
+       local counter = 0
+       local current = node
+       local found = false
+       while current:parent() ~= nil do
+               if levels then
+                       if levels[current:type()] then
+                               counter = counter + 1
+                               found = true
+                       end
+               else
+                       counter = counter + 1
+                       found = true
+               end
+               current = current:parent()
+       end
+       if not found then
+               return 1
+       elseif counter % len == 0 then
+               return len
+       else
+               return (counter % len)
+       end
+end
+
+--- Update highlights for a range. Called every time text is changed.
+--- @param bufnr number # Buffer number
+--- @param changes table # Range of text changes
+--- @param tree table # Syntax tree
+--- @param lang string # Language
+local function update_range(bufnr, changes, tree, lang)
+       if vim.fn.pumvisible() ~= 0 or not lang then
+               return
+       end
+
+       for _, change in ipairs(changes) do
+               local root_node = tree:root()
+               local query = queries.get_query(lang, "parens")
+               local levels = require("rainbow.levels")[lang]
+               if query ~= nil then
+                       for _, node, _ in query:iter_captures(root_node, bufnr, change[1], change[3] + 1) do
+                               -- set colour for this nesting level
+                               if not node:has_error() then
+                                       local color_no_ = color_no(node, #colors, levels)
+                                       local startRow, startCol, endRow, endCol = node:range() -- range of the capture, zero-indexed
+                                       if vim.fn.has("nvim-0.7") == 1 then
+                                               vim.highlight.range(
+                                                       bufnr,
+                                                       nsid,
+                                                       ("rainbowcol" .. color_no_),
+                                                       { startRow, startCol },
+                                                       { endRow, endCol - 1 },
+                                                       {
+                                                               regtype = "b",
+                                                               inclusive = true,
+                                                               priority = 210,
+                                                       }
+                                               )
+                                       else
+                                               vim.highlight.range(
+                                                       bufnr,
+                                                       nsid,
+                                                       ("rainbowcol" .. color_no_),
+                                                       { startRow, startCol },
+                                                       { endRow, endCol - 1 },
+                                                       "blockwise",
+                                                       true,
+                                                       210
+                                               )
+                                       end
+                               end
+                       end
+               end
+       end
+end
+
+--- Update highlights for every tree in given buffer.
+--- @param bufnr number # Buffer number
+local function full_update(bufnr)
+       local parser = buffer_parsers[bufnr]
+       parser:for_each_tree(function(tree, sub_parser)
+               update_range(bufnr, { { tree:root():range() } }, tree, sub_parser:lang())
+       end)
+end
+
+--- Register predicates for extended mode.
+--- @param config table # Configuration for the `rainbow` module in nvim-treesitter
+local function register_predicates(config)
+       local extended_mode
+
+       if type(config.extended_mode) == "table" then
+               extended_mode = {}
+               for _, lang in pairs(config.extended_mode) do
+                       extended_mode[lang] = true
+               end
+       elseif type(config.extended_mode) == "boolean" then
+               extended_mode = config.extended_mode
+       else
+               vim.api.nvim_err_writeln("nvim-ts-rainbow: `extended_mode` can be a boolean or a table")
+       end
+
+       for _, lang in ipairs(extended_languages) do
+               local enable_extended_mode
+               if type(extended_mode) == "table" then
+                       enable_extended_mode = extended_mode[lang]
+               else
+                       enable_extended_mode = extended_mode
+               end
+               add_predicate(lang .. "-extended-rainbow-mode?", function()
+                       return enable_extended_mode
+               end, true)
+       end
+end
+
+local state_table = {}
+
+local M = {}
+
+--- Define highlight groups. This had to be a function to allow an autocmd doing this at colorscheme change.
+function M.defhl()
+       for i = 1, math.max(#colors, #termcolors) do
+               local s = string.format("highlight default rainbowcol%d", i)
+               if #colors > 0 then
+                       s = s .. " guifg=" .. colors[(i % #colors == 0) and #colors or (i % #colors)]
+               end
+               if #termcolors > 0 then
+                       s = s
+                           .. " ctermfg="
+                           .. termcolors[(i % #termcolors == 0) and #termcolors or (i % #termcolors)]
+               end
+               vim.cmd(s)
+       end
+end
+
+M.defhl()
+
+--- Attach module to buffer. Called when new buffer is opened or `:TSBufEnable rainbow`.
+--- @param bufnr number # Buffer number
+--- @param lang string # Buffer language
+function M.attach(bufnr, lang)
+       local config = configs.get_module("rainbow")
+       local max_file_lines = config.max_file_lines
+       if max_file_lines ~= nil and vim.api.nvim_buf_line_count(bufnr) > max_file_lines then
+               return
+       end
+       register_predicates(config)
+       local parser = parsers.get_parser(bufnr, lang)
+       parser:register_cbs({
+               on_changedtree = function(changes, tree)
+                       if state_table[bufnr] then
+                               update_range(bufnr, changes, tree, lang)
+                       else
+                               return
+                       end
+               end,
+       })
+       buffer_parsers[bufnr] = parser
+       state_table[bufnr] = true
+       full_update(bufnr)
+end
+
+--- Detach module from buffer. Called when `:TSBufDisable rainbow`.
+--- @param bufnr number # Buffer number
+function M.detach(bufnr)
+       state_table[bufnr] = false
+       if vim.treesitter.highlighter.hl_map then
+               vim.treesitter.highlighter.hl_map["punctuation.bracket"] = "TSPunctBracket"
+       else
+               vim.api.nvim_set_hl(0, "@punctuation.bracket", { link = "TSPunctBracket" })
+       end
+       vim.api.nvim_buf_clear_namespace(bufnr, nsid, 0, -1)
+       buffer_parsers[bufnr] = nil
+end
+
+if vim.fn.has("nvim-0.7") == 1 then
+       api.nvim_create_augroup("RainbowParser", {})
+       api.nvim_create_autocmd("FileType", {
+               group = "RainbowParser",
+               pattern = "*",
+               callback = function()
+                       local bufnr = api.nvim_get_current_buf()
+                       if state_table[bufnr] then
+                               local lang = parsers.get_buf_lang(bufnr)
+                               local parser = parsers.get_parser(bufnr, lang)
+                               buffer_parsers[bufnr] = parser
+                       end
+               end,
+       })
+end
+
+return M
diff --git a/lua/syntax-surf.lua b/lua/syntax-surf.lua
new file mode 100644 (file)
index 0000000..10d1a62
--- /dev/null
@@ -0,0 +1,44 @@
+-- -- Syntax Tree Surfer
+-- local opts = {noremap = true, silent = true}
+--
+--
+-- -- Normal Mode Swapping:
+-- -- Swap The Master Node relative to the cursor with it's siblings, Dot Repeatable
+-- vim.keymap.set("n", "vU", function()
+--     vim.opt.opfunc = "v:lua.STSSwapUpNormal_Dot"
+--     return "g@l"
+-- end, { silent = true, expr = true })
+-- vim.keymap.set("n", "vD", function()
+--     vim.opt.opfunc = "v:lua.STSSwapDownNormal_Dot"
+--     return "g@l"
+-- end, { silent = true, expr = true })
+--
+-- -- Swap Current Node at the Cursor with it's siblings, Dot Repeatable
+-- vim.keymap.set("n", "vd", function()
+--     vim.opt.opfunc = "v:lua.STSSwapCurrentNodeNextNormal_Dot"
+--     return "g@l"
+-- end, { silent = true, expr = true })
+-- vim.keymap.set("n", "vu", function()
+--     vim.opt.opfunc = "v:lua.STSSwapCurrentNodePrevNormal_Dot"
+--     return "g@l"
+-- end, { silent = true, expr = true })
+--
+-- --> If the mappings above don't work, use these instead (no dot repeatable)
+-- -- vim.keymap.set("n", "vd", '<cmd>STSSwapCurrentNodeNextNormal<cr>', opts)
+-- -- vim.keymap.set("n", "vu", '<cmd>STSSwapCurrentNodePrevNormal<cr>', opts)
+-- -- vim.keymap.set("n", "vD", '<cmd>STSSwapDownNormal<cr>', opts)
+-- -- vim.keymap.set("n", "vU", '<cmd>STSSwapUpNormal<cr>', opts)
+--
+-- -- Visual Selection from Normal Mode
+-- vim.keymap.set("n", "vx", '<cmd>STSSelectMasterNode<cr>', opts)
+-- vim.keymap.set("n", "vn", '<cmd>STSSelectCurrentNode<cr>', opts)
+--
+-- -- Select Nodes in Visual Mode
+-- vim.keymap.set("x", "J", '<cmd>STSSelectNextSiblingNode<cr>', opts)
+-- vim.keymap.set("x", "K", '<cmd>STSSelectPrevSiblingNode<cr>', opts)
+-- vim.keymap.set("x", "H", '<cmd>STSSelectParentNode<cr>', opts)
+-- vim.keymap.set("x", "L", '<cmd>STSSelectChildNode<cr>', opts)
+--
+-- -- Swapping Nodes in Visual Mode
+-- vim.keymap.set("x", "<A-j>", 'STSSwapNextVisual', opts)
+-- vim.keymap.set("x", "<A-k>", 'STSSwapPrevVisual', opts)
diff --git a/lua/terminal.lua b/lua/terminal.lua
new file mode 100644 (file)
index 0000000..9596924
--- /dev/null
@@ -0,0 +1,20 @@
+require("toggleterm").setup {
+        size = 15,
+        open_mapping = [[<c-\>]],
+}
+
+function _G.set_terminal_keymaps()
+        local opts = { buffer = 0 , noremap = true, silent = true, }
+        vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
+        -- vim.keymap.set('t', '<C-h>', [[<CMD>wincmd h<CR>]], opts)
+        -- vim.keymap.set('t', '<C-j>', [[<CMD>wincmd j<CR>]], opts)
+        -- vim.keymap.set('t', '<C-k>', [[<CMD>wincmd k<CR>]], opts)
+        -- vim.keymap.set('t', '<C-l>', [[<CMD>wincmd l<CR>]], opts)
+        vim.keymap.set("t", "<M-h>", "<CMD>vertical resize -2<CR>", opts)
+        vim.keymap.set("t", "<M-j>", "<CMD>resize +2<CR>", opts)
+        vim.keymap.set("t", "<M-k>", "<CMD>resize -2<CR>", opts)
+        vim.keymap.set("t", "<M-l>", "<CMD>vertical resize +2<CR>", opts)
+end
+
+-- if you only want these mappings for toggle term use term://*toggleterm#* instead
+vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
diff --git a/lua/treesitter.lua b/lua/treesitter.lua
new file mode 100644 (file)
index 0000000..df1b2bc
--- /dev/null
@@ -0,0 +1,101 @@
+require("nvim-treesitter.configs").setup({
+        textobjects = {
+                select = {
+                        enable = true,
+
+                        -- Automatically jump forward to textobj, similar to targets.vim
+                        lookahead = true,
+
+                        keymaps = {
+                                -- You can use the capture groups defined in textobjects.scm
+                                ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" },
+                                ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" },
+                                ["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" },
+                                ["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" },
+
+                                ["aa"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/argument" },
+                                ["ia"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/argument" },
+
+                                ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" },
+                                ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" },
+
+                                ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" },
+                                ["il"] = { query = "@loop.inner", desc = "Select inner part of a loop" },
+
+                                ["am"] = { query = "@call.outer", desc = "Select outer part of a function call" },
+                                ["im"] = { query = "@call.inner", desc = "Select inner part of a function call" },
+
+                                ["af"] = { query = "@function.outer", desc =
+                                "Select outer part of a method/function definition" },
+                                ["if"] = { query = "@function.inner", desc =
+                                "Select inner part of a method/function definition" },
+
+                                ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" },
+                                ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" },
+                        },
+                },
+                swap = {
+                        enable = true,
+                        swap_next = {
+                                ["<localleader>pn"] = "@parameter.inner", -- swap parameters/argument with next
+                                ["<localleader>fn"] = "@function.outer",  -- swap function with next
+                                ["<localleader>in"] = "@conditional.inner",  -- swap function with next
+                        },
+                        swap_previous = {
+                                ["<localleader>pp"] = "@parameter.inner", -- swap parameters/argument with prev
+                                ["<localleader>fp"] = "@function.outer",  -- swap function with previous
+                                ["<localleader>ip"] = "@conditional.inner",  -- swap function with next
+                        },
+                },
+                move = {
+                        enable = true,
+                        set_jumps = true, -- whether to set jumps in the jumplist
+                        goto_next_start = {
+                                ["]m"] = { query = "@call.outer", desc = "Next function call start" },
+                                ["]f"] = { query = "@function.outer", desc = "Next method/function def start" },
+                                ["]c"] = { query = "@class.outer", desc = "Next class start" },
+                                ["]i"] = { query = "@conditional.outer", desc = "Next conditional start" },
+                                ["]l"] = { query = "@loop.outer", desc = "Next loop start" },
+                                ["]p"] = { query = "@parameter.inner", desc = "Next parameter start" },
+
+                                -- You can pass a query group to use query from `queries/<lang>/<query_group>.scm file in your runtime path.
+                                -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm.
+                                ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" },
+                                ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" },
+                        },
+                        goto_next_end = {
+                                ["]M"] = { query = "@call.outer", desc = "Next function call end" },
+                                ["]F"] = { query = "@function.outer", desc = "Next method/function def end" },
+                                ["]C"] = { query = "@class.outer", desc = "Next class end" },
+                                ["]I"] = { query = "@conditional.outer", desc = "Next conditional end" },
+                                ["]L"] = { query = "@loop.outer", desc = "Next loop end" },
+                        },
+                        goto_previous_start = {
+                                ["[m"] = { query = "@call.outer", desc = "Prev function call start" },
+                                ["[f"] = { query = "@function.outer", desc = "Prev method/function def start" },
+                                ["[c"] = { query = "@class.outer", desc = "Prev class start" },
+                                ["[i"] = { query = "@conditional.outer", desc = "Prev conditional start" },
+                                ["[l"] = { query = "@loop.outer", desc = "Prev loop start" },
+                        },
+                        goto_previous_end = {
+                                ["[M"] = { query = "@call.outer", desc = "Prev function call end" },
+                                ["[F"] = { query = "@function.outer", desc = "Prev method/function def end" },
+                                ["[C"] = { query = "@class.outer", desc = "Prev class end" },
+                                ["[I"] = { query = "@conditional.outer", desc = "Prev conditional end" },
+                                ["[L"] = { query = "@loop.outer", desc = "Prev loop end" },
+                        },
+                },
+        },
+})
+
+local ts_repeat_move = require("nvim-treesitter.textobjects.repeatable_move")
+
+-- vim way: ; goes to the direction you were moving.
+vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move)
+vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite)
+
+-- Optionally, make builtin f, F, t, T also repeatable with ; and ,
+vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f)
+vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F)
+vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t)
+vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T)
diff --git a/lua/undotree.lua b/lua/undotree.lua
new file mode 100644 (file)
index 0000000..656030a
--- /dev/null
@@ -0,0 +1,4 @@
+vim.g.undotree_WindowLayout = 3
+vim.g.undotree_SplitWidth = 32
+vim.g.undotree_DiffpanelHeight = 16
+vim.g.undotree_SetFocusWhenToggle = 1
diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm
new file mode 100644 (file)
index 0000000..19098f5
--- /dev/null
@@ -0,0 +1,15 @@
+;; extends
+
+(if_statement) @branch
+(case_statement) @branch
+(for_statement) @loop
+(while_statement) @loop
+(do_statement) @loop
+(goto_statement) @goto
+(return_statement) @goto
+(break_statement) @goto
+(continue_statement) @goto
+
+(labeled_statement 
+  label: (statement_identifier) @goto
+)
diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm
new file mode 100644 (file)
index 0000000..af2adc6
--- /dev/null
@@ -0,0 +1,9 @@
+;; extends
+
+(if_statement) @branch
+(case_clause) @branch
+(for_statement) @loop
+(while_statement) @loop
+(return_statement) @goto
+(break_statement) @goto
+(continue_statement) @goto