From 85ae713bf52ff00c48cc46fe83aaceaf5503effe Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Sat, 7 Oct 2023 18:23:48 +0300 Subject: [PATCH] refactor to use lazy.nvim --- .luarc.json | 5 +- after/plugin/lspsignature-theme.lua | 10 +- after/plugin/telescope-theme.lua | 38 +- init.lua | 940 +++++++++++++++++++++++- lazy-lock.json | 64 ++ lua/bindings.lua | 52 -- lua/config/autosource.lua | 7 - lua/config/baleia.lua | 14 - lua/config/based.lua | 15 - lua/config/cmp.lua | 94 --- lua/config/colorizer.lua | 19 - lua/config/comment.lua | 17 - lua/config/devicons.lua | 4 - lua/config/diffview.lua | 12 - lua/config/doxygen-tk.lua | 11 - lua/config/dressing.lua | 27 - lua/config/escape.lua | 10 - lua/config/git-conflict.lua | 26 - lua/config/gitblame.lua | 22 - lua/config/gitsigns.lua | 42 -- lua/config/lazygit.lua | 8 - lua/config/leap.lua | 12 - lua/config/legendary.lua | 12 - lua/config/lspconfig.lua | 166 ----- lua/config/lspsignature.lua | 18 - lua/config/lsputils.lua | 14 - lua/config/lualine.lua | 161 ---- lua/config/luapad.lua | 15 - lua/config/luasnip.lua | 99 --- lua/config/mason-lspconfig.lua | 40 - lua/config/mason.lua | 1 - lua/config/move.lua | 11 - lua/config/navbuddy.lua | 33 - lua/config/nvim-tree.lua | 19 - lua/config/quickscope.lua | 9 - lua/config/tabnine.lua | 10 - lua/config/telescope.lua | 138 ---- lua/config/tidy.lua | 4 - lua/config/todo-comments.lua | 11 - lua/config/toggleterm.lua | 11 - lua/config/treesitter.lua | 15 - lua/config/trouble.lua | 15 - lua/config/ts-playground.lua | 5 - lua/config/ufo.lua | 15 - lua/disable-builtin.lua | 11 - lua/highlight-yank.lua | 5 - lua/{config/dap.lua => old_dap_cfg.lua} | 0 lua/options.lua | 151 ---- lua/personal/add-guard.lua | 32 - lua/personal/add-include-guard.lua | 39 + lua/personal/cmacro-align.lua | 67 +- lua/personal/disable-builtin.lua | 17 + lua/personal/pludin-dev.lua | 6 - lua/personal/plugin-dev.lua | 11 + lua/personal/uci.lua | 66 +- lua/plugins-local.lua | 2 - lua/plugins.lua | 138 ---- lua/plugins/lualine.lua | 168 +++++ lua/plugins/luasnip.lua | 89 +++ lua/plugins/telescope.lua | 148 ++++ lua/utils/autocmd.lua | 11 - lua/utils/capture.lua | 10 - lua/utils/init.lua | 6 - lua/utils/map.lua | 8 - lua/utils/opt.lua | 6 - 65 files changed, 1559 insertions(+), 1703 deletions(-) create mode 100644 lazy-lock.json delete mode 100644 lua/bindings.lua delete mode 100644 lua/config/autosource.lua delete mode 100644 lua/config/baleia.lua delete mode 100644 lua/config/based.lua delete mode 100644 lua/config/cmp.lua delete mode 100644 lua/config/colorizer.lua delete mode 100644 lua/config/comment.lua delete mode 100644 lua/config/devicons.lua delete mode 100644 lua/config/diffview.lua delete mode 100644 lua/config/doxygen-tk.lua delete mode 100644 lua/config/dressing.lua delete mode 100644 lua/config/escape.lua delete mode 100644 lua/config/git-conflict.lua delete mode 100644 lua/config/gitblame.lua delete mode 100644 lua/config/gitsigns.lua delete mode 100644 lua/config/lazygit.lua delete mode 100644 lua/config/leap.lua delete mode 100644 lua/config/legendary.lua delete mode 100644 lua/config/lspconfig.lua delete mode 100644 lua/config/lspsignature.lua delete mode 100644 lua/config/lsputils.lua delete mode 100644 lua/config/lualine.lua delete mode 100644 lua/config/luapad.lua delete mode 100644 lua/config/luasnip.lua delete mode 100644 lua/config/mason-lspconfig.lua delete mode 100644 lua/config/mason.lua delete mode 100644 lua/config/move.lua delete mode 100644 lua/config/navbuddy.lua delete mode 100644 lua/config/nvim-tree.lua delete mode 100644 lua/config/quickscope.lua delete mode 100644 lua/config/tabnine.lua delete mode 100644 lua/config/telescope.lua delete mode 100644 lua/config/tidy.lua delete mode 100644 lua/config/todo-comments.lua delete mode 100644 lua/config/toggleterm.lua delete mode 100644 lua/config/treesitter.lua delete mode 100644 lua/config/trouble.lua delete mode 100644 lua/config/ts-playground.lua delete mode 100644 lua/config/ufo.lua delete mode 100644 lua/disable-builtin.lua delete mode 100644 lua/highlight-yank.lua rename lua/{config/dap.lua => old_dap_cfg.lua} (100%) delete mode 100644 lua/options.lua delete mode 100644 lua/personal/add-guard.lua create mode 100644 lua/personal/add-include-guard.lua create mode 100644 lua/personal/disable-builtin.lua delete mode 100644 lua/personal/pludin-dev.lua create mode 100644 lua/personal/plugin-dev.lua delete mode 100644 lua/plugins-local.lua delete mode 100644 lua/plugins.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/luasnip.lua create mode 100644 lua/plugins/telescope.lua delete mode 100644 lua/utils/autocmd.lua delete mode 100644 lua/utils/capture.lua delete mode 100644 lua/utils/init.lua delete mode 100644 lua/utils/map.lua delete mode 100644 lua/utils/opt.lua diff --git a/.luarc.json b/.luarc.json index 6c8fa37..04ef2a8 100644 --- a/.luarc.json +++ b/.luarc.json @@ -1,5 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", "Lua.runtime.version": "LuaJIT", - "Lua.diagnostics.globals": ["vim", "packer_plugins"] + "Lua.diagnostics.globals": ["vim", "packer_plugins"], + "diagnostics.disable": [ + "missing-fields" + ] } diff --git a/after/plugin/lspsignature-theme.lua b/after/plugin/lspsignature-theme.lua index 0438b36..584a268 100644 --- a/after/plugin/lspsignature-theme.lua +++ b/after/plugin/lspsignature-theme.lua @@ -1,8 +1,8 @@ if vim.g.colors_name == "srcery" then - local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground - local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground + local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground + local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground - vim.api.nvim_set_hl(0, "FloatBorder", {bg=hard_black, fg=bright_white}) - vim.api.nvim_set_hl(0, "FloatNormal", {bg=hard_black, fg=bright_white}) - vim.api.nvim_set_hl(0, "Pmenu", {bg=hard_black, fg=bright_white}) + vim.api.nvim_set_hl(0, "FloatBorder", {bg=hard_black, fg=bright_white}) + vim.api.nvim_set_hl(0, "FloatNormal", {bg=hard_black, fg=bright_white}) + vim.api.nvim_set_hl(0, "Pmenu", {bg=hard_black, fg=bright_white}) end diff --git a/after/plugin/telescope-theme.lua b/after/plugin/telescope-theme.lua index c71df0c..fa2fa53 100644 --- a/after/plugin/telescope-theme.lua +++ b/after/plugin/telescope-theme.lua @@ -1,22 +1,22 @@ if vim.g.colors_name == "srcery" then - local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground - local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground - local red = vim.api.nvim_get_hl_by_name("SrceryRed", true).foreground - local yellow = vim.api.nvim_get_hl_by_name("SrceryYellow", true).foreground - local gray1 = vim.api.nvim_get_hl_by_name("SrceryXgray1", true).foreground + local bright_white = vim.api.nvim_get_hl_by_name("SrceryBrightWhite", true).foreground + local hard_black = vim.api.nvim_get_hl_by_name("SrceryHardBlack", true).foreground + local red = vim.api.nvim_get_hl_by_name("SrceryRed", true).foreground + local yellow = vim.api.nvim_get_hl_by_name("SrceryYellow", true).foreground + local gray1 = vim.api.nvim_get_hl_by_name("SrceryXgray1", true).foreground - local TelescopePrompt = { - TelescopeBorder = {bg = hard_black, fg = hard_black}, - TelescopePromptBorder = {bg = gray1, fg = gray1}, - TelescopePromptNormal = {bg = gray1}, - TelescopePromptTitle = {fg = hard_black, bg = red }, - TelescopePreviewTitle = {fg = hard_black, bg = yellow }, - TelescopeNormal = {bg = hard_black, fg = bright_white}, - TelescopeResultsNormal = {bg = hard_black, fg = bright_white}, - TelescopePreviewNormal = {bg = hard_black, fg = bright_white}, - TelescopeSelection = {bg = hard_black, fg = bright_white, underline = true}, - } - for hl, col in pairs(TelescopePrompt) do - vim.api.nvim_set_hl(0, hl, col) - end + local TelescopePrompt = { + TelescopeBorder = {bg = hard_black, fg = hard_black}, + TelescopePromptBorder = {bg = gray1, fg = gray1}, + TelescopePromptNormal = {bg = gray1}, + TelescopePromptTitle = {fg = hard_black, bg = red }, + TelescopePreviewTitle = {fg = hard_black, bg = yellow }, + TelescopeNormal = {bg = hard_black, fg = bright_white}, + TelescopeResultsNormal = {bg = hard_black, fg = bright_white}, + TelescopePreviewNormal = {bg = hard_black, fg = bright_white}, + TelescopeSelection = {bg = hard_black, fg = bright_white, underline = true}, + } + for hl, col in pairs(TelescopePrompt) do + vim.api.nvim_set_hl(0, hl, col) + end end diff --git a/init.lua b/init.lua index 9bb3691..306a93a 100644 --- a/init.lua +++ b/init.lua @@ -1,35 +1,921 @@ -local cmd = vim.cmd +vim.g.mapleader = " " +vim.g.maplocalleader = " " -table.unpack = unpack +-- If possible use 24 Bit Colors +if vim.fn.has('termguicolors') == 1 then + vim.o.termguicolors = true +end --- Allow loading */init.lua files -package.path = "./?/init.lua;"..package.path +-- Bootstrap lazy.nvim +do + 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) +end --- Leader/local leader -vim.g.mapleader = [[ ]] -vim.g.maplocalleader = [[,]] +require("lazy").setup({ + "psliwka/vim-smoothie", + "tpope/vim-unimpaired", + "tpope/vim-eunuch", + "tpope/vim-surround", + "tpope/vim-repeat", + {"christoomey/vim-tmux-navigator", lazy=false}, + "michaeljsmith/vim-indent-object", + "godlygeek/tabular", + "mcauley-penney/tidy.nvim", + "editorconfig/editorconfig-vim", + "kevinhwang91/nvim-bqf", + "wellle/targets.vim", --- Disable some built-in plugins we don't want -require("disable-builtin") -require("highlight-yank") -require("plugin-manager") -require("options") -require("bindings") + { + "krady21/compiler-explorer.nvim", + cmd = {"CECompile", "CECompileLive", "CEFormat", "CEAddLibrary", "CELoadExample", "CEOpenWebsite", "CEDeleteCache", "CEShowTooltip", "CEGotoLabel"} + }, -require("personal.pludin-dev") -require("personal.add-guard") -require("personal.cmacro-align") -require("personal.uci") + { + "kdheepak/lazygit.nvim", + keys = { + { "gg", "LazyGit", desc = "Open lazygit" } + } + }, -vim.g.python_ident = { - disable_parentheses_indenting = false, - closed_paren_align_last_line = false, - searchpair_timeout = 150, - continue = "shiftwidth()", - open_paren = "shiftwidth()", - nested_paren = "shiftwidth()" + { + "unblevable/quick-scope", + init = function () + -- Trigger a highlight in the appropriate direction when pressing these keys: + vim.g.qs_highlight_on_keys = {"f", "F", "t", "T"} + vim.g.qs_max_chars = 150 + end + }, + + { + "stevearc/dressing.nvim", + dependencies = {"nvim-telescope/telescope.nvim"}, + opts = { + select = { + get_config = function(opts) + opts = opts or {} + local cfg = { + telescope = { + layout_config = { + -- width = 120, + -- height = 60, + width = 0.87, + height = 0.80, + }, + }, + } + if opts.kind == "legendary.nvim" then + cfg.telescope.sorter = require("telescope.sorters").fuzzy_with_index_bias({}) + end + return cfg + end, + }, + } + }, + + { "tikhomirov/vim-glsl", ft="glsl" }, + + { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim"}, + opts = { signs = false } + }, + + -- Git related plugins + { + "f-person/git-blame.nvim", + config = function () + vim.g["gitblame_enabled"] = 0 + vim.g["gitblame_date_format"] = "%r" + end, + keys = { + { "gh", "GitBlameCopySHA" , desc = "[G]it blame, copy commit [h]ash" }, + { "go", "GitBlameOpenCommit", desc = "[G]it blame, [o]pen commit" }, + { "gt", "GitBlameToggle" , desc = "[G]it blame, [t]oggle" }, + } + }, + + { + "trmckay/based.nvim", + keys = { + { mode = {"n", "v"}, "b", function(...) require("based").convert(...) end, desc = "Convert [b]ase of number" } + } + }, + + -- Detect tabstop and shiftwidth automatically + "tpope/vim-sleuth", + + -- 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", config = true }, + "williamboman/mason-lspconfig.nvim", + + -- Useful status updates for LSP + -- NOTE: `opts = {}` is the same as calling `require("fidget").setup({})` + { "j-hui/fidget.nvim", tag = "legacy", opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + "folke/neodev.nvim", + }, + }, + + { + "ray-x/lsp_signature.nvim", + opts = { + hint_enable = false, + toggle_key = nil, + handler_opts = { + border = { " ", " ", " ", " ", " ", " ", " ", " " } + } + } + }, + + { + -- Autocompletion + "hrsh7th/nvim-cmp", + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + + -- Adds LSP completion capabilities + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "onsails/lspkind-nvim", + + -- Adds a number of user-friendly snippets + "rafamadriz/friendly-snippets", + }, + }, + + -- Useful plugin to show you pending keybinds. + { "folke/which-key.nvim", opts = {} }, + { + -- Adds git related signs to the gutter, as well as utilities for managing changes + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + on_attach = function() + local function keymap(mode, keybind, cmd, desc) + vim.keymap.set(mode, keybind, cmd, {desc=desc, buffer=true}) + end + keymap({"v","n"}, "hs", ":Gitsigns stage_hunk", "[h]unk [s]tage") + keymap({"v","n"}, "hr", ":Gitsigns reset_hunk", "[h]unk [r]eset") + keymap("n", "hS", "Gitsigns stage_buffer", "[h]unk [S]tage buffer") + keymap("n", "hu", "Gitsigns undo_stage_hunk", "[h]unk [u]ndo stage") + keymap("n", "hR", "Gitsigns reset_buffer", "[h]unk [R]eset buffer") + keymap("n", "hp", "Gitsigns preview_hunk", "[h]unk [p]review") + keymap("n", 'ht', 'Gitsigns toggle_deleted', "[h]unk [t]oggle deleted") + end + }, + }, + + { + "nvim-treesitter/playground", + requires = "nvim-treesitter/nvim-treesitter", + cmd = "TSPlaygroundToggle" + }, + + { + "sindrets/diffview.nvim", + dependencies = {"nvim-lua/plenary.nvim"}, + opts = { + enhanced_diff_hl = true + }, + keys = { + {"gdo", "DiffviewOpen", desc = "[g]it [d]iff [o]pen" }, + {"gdc", "DiffviewClose", desc = "[g]it [d]iff [c]pen" } + } + }, + + { + "vim-scripts/DoxygenToolkit.vim", + cmd = "Dox", + config = function() + vim.g.DoxygenToolkit_startCommentTag = "/// " + vim.g.DoxygenToolkit_interCommentTag = "/// " + vim.g.DoxygenToolkit_endCommentTag = "" + vim.g.DoxygenToolkit_startCommentBlock = "// " + vim.g.DoxygenToolkit_interCommentBlock = "// " + vim.g.DoxygenToolkit_endCommentBlock = "" + end + }, + + { + "SmiteshP/nvim-navbuddy", + dependencies = { + "neovim/nvim-lspconfig", + "SmiteshP/nvim-navic", + "MunifTanjim/nui.nvim", + "nvim-telescope/telescope.nvim" + }, + keys = { + {"o", "Navbuddy", desc="Navbuddy"} + }, + opts = { + window = { + border = "rounded", + size = "60%", + position = "50%", + sections = { + left = { size = "20%" }, + mid = { size = "40%" }, + right = { preview = "leaf" } + }, + }, + node_markers = { enabled = true }, + use_default_mappings = true, + lsp = { auto_attach = true } + } + }, + + { + "m-gail/escape.nvim", + keys = { + {mode="v", "q", function(...) return require("escape").escape(...) end, desc="Escape [q]uotes"} + } + }, + + { + "rest-nvim/rest.nvim", + requires = { "nvim-lua/plenary.nvim" }, + keys = { + {mode="n", "n", "RestNvim", desc = "Run HTTP request under cursor"} + } + }, + + { + "jenterkin/vim-autosource", + config = function() + local data = vim.fn.stdpath("data") + vim.g.autosource_hashdir = data .. "/vim-autosource/hashes" + end + }, + + { + "fedepujol/move.nvim", + config = function() + local opts = { noremap = true, silent = true } + vim.keymap.set("v", "", ":MoveBlock(1)", opts) + vim.keymap.set("v", "", ":MoveBlock(-1)", opts) + end, + }, + + { + "srcery-colors/srcery-vim", + priority = 1000, + config = function() + vim.cmd.colorscheme("srcery") + end, + }, + + { + "rafcamlet/nvim-luapad", + cmd = {"Luapad", "LuaRun"}, + init = function() + local pattern = "^/tmp/.*/%d+_Luapad%.lua$" + vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("LuaPadFiletype", {clear=true}), + callback = function(data) + if data.file:match(pattern) then + vim.bo[data.buf].filetype = "lua.luapad" + end + end + }) + end + }, + + -- { + -- -- Set lualine as statusline + -- "nvim-lualine/lualine.nvim", + -- -- See `:help lualine.txt` + -- opts = { + -- options = { + -- icons_enabled = false, + -- theme = "srcery", + -- component_separators = "|", + -- section_separators = "", + -- }, + -- }, + -- }, + + -- { + -- -- Add indentation guides even on blank lines + -- "lukas-reineke/indent-blankline.nvim", + -- -- Enable `lukas-reineke/indent-blankline.nvim` + -- -- See `:help indent_blankline.txt` + -- main = "ibl", + -- opts = {}, + -- }, + + -- "gc" to comment visual regions/lines + { "numToStr/Comment.nvim", opts = {} }, + + { + "norcalli/nvim-colorizer.lua", + lazy = false, + config = function() + require("colorizer").setup( + nil, + { + RGB = true, + RRGGBB = true, + names = false, + RRGGBBAA = true, + rgb_fn = true, + hsl_fn = true, + css = false, + css_fn = false, + mode = "background" + } + ) + end + }, + + { + -- Highlight, edit, and navigate code + "nvim-treesitter/nvim-treesitter", + dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" }, + build = ":TSUpdate", + }, + + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + keys = { + { id = "Toggle neo tre[e]", "e", "Neotree toggle", desc = "NeoTree" }, + }, + config = function() + require("neo-tree").setup({ + window = { + mappings = { + [""] = "open_vsplit", + [""] = "open_split" + } + } + }) + end + }, + + -- TODO: When updating throws an error + -- { + -- "m00qek/baleia.nvim", + -- tag = "v1.2.0", + -- config = function() + -- local baleia = require("baleia").setup() + -- vim.api.nvim_create_user_command("BaleiaColorize", function() + -- baleia.once(vim.api.nvim_get_current_buf()) + -- end, { }) + -- end, + -- keys = { + -- { id = "[A]NSI [C]olorize", "ac", "BaleiaColorize", desc = "Colorize ANSI codes" } + -- } + -- }, + + + -- TODO: Setup DAP + -- use { "mfussenegger/nvim-dap", config_name="dap" } + -- use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] } + -- use 'simrat39/rust-tools.nvim' + -- use { + -- 'theHamsta/nvim-dap-virtual-text', + -- requires = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"}, + -- config=[[require('nvim-dap-virtual-text')]] + -- } + + { + "s1n7ax/nvim-window-picker", + name = "window-picker", + event = "VeryLazy", + version = "2.*", + config = function() + require("window-picker").setup() + end + }, + + { + dir = "personal/cmacro-align", + config = function() require("personal.cmacro-align").load() end + }, + + { + dir = "personal/add-include-guard", + config = function() require("personal.add-include-guard").load() end, + cmd = "AddIncludeGuard" + }, + + { + dir = "personal/plugin-dev", + config = function() require("personal.plugin-dev").load() end, + }, + + { + dir = "personal/uci", + config = function() require("personal.uci").load() end, + ft="uci" + }, + + { + dir = "personal/disable-builtin", + lazy = false, + config = function() require("personal.disable-builtin").load() end, + }, + + { import = "plugins" } +}, {}) + +-- [[ Setting options ]] +-- See `:help vim.o` + +-- Enable auto reload of changed files +do + vim.o.autoread = true + -- TODO: + -- local autoreload_grp = vim.api.nvim_create_augroup("AutoReload", { clear = true }) + -- vim.api.nvim_create_autocmd({"FocusGained","BufEnter","CursorHold","CursorHoldI"}, { + -- group = autoreload_grp, + -- pattern = {"*"}, + -- callback = function() + -- -- TODO: Port this to lua + -- vim.cmd [[if mode() != 'c' | checktime | endif]] + -- end + -- }) + -- vim.api.nvim_create_autocmd({"FileChangedShellPost"}, { + -- group = autoreload_grp, + -- pattern = {"*"}, + -- callback = function() + -- -- TODO: Port this to lua + -- vim.cmd [[echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]] + -- end + -- }) + -- autocmd("auto-reload", { + -- [[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif]], + -- [[FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]] + -- }, true) +end + +do + -- TODO: Use nvim API + vim.cmd.syntax("on") + vim.cmd.filetype("plugin on") + + vim.g.zig_fmt_autosave = 0 + + -- Folding options + vim.o.foldmethod = 'indent' + vim.o.foldlevelstart = 99 + + -- Identation/Tab settings + local tab_size = 2 + vim.bo.expandtab = true + vim.bo.smartindent = true + vim.bo.shiftwidth = tab_size + vim.bo.tabstop = tab_size + vim.bo.softtabstop = tab_size + + vim.g.python_ident = { + disable_parentheses_indenting = false, + closed_paren_align_last_line = false, + searchpair_timeout = 150, + continue = "shiftwidth()", + open_paren = "shiftwidth()", + nested_paren = "shiftwidth()" + } + + -- Set highlight on search + vim.o.hlsearch = false + vim.o.ignorecase = true + vim.o.smartcase = true + vim.o.incsearch = true + vim.o.inccommand = "nosplit" + + -- Always keep at least 8 blank lines below the last line + vim.o.scrolloff = 8 + + -- Show 110 marker column + vim.o.colorcolumn = "110" + + -- How whitespace characters should be displayed + vim.o.listchars = [[space:.,eol:$,tab:>-]] + + -- Show current mode that you are in + vim.o.showmode = true + + -- Add a bit of transparency to windows + vim.o.pumblend = 15 + vim.cmd.highlight("PmenuSel blend=0") -- TODO: use nvim API + + -- Keep non-visible files open + vim.o.hidden = true + + -- Make line numbers default + relative numbers + vim.wo.number = true + vim.wo.relativenumber = true + + -- Enable mouse mode + vim.o.mouse = 'a' + + -- Skip redrawing window while executing macro + vim.o.lazyredraw = true + + -- Sync clipboard between OS and Neovim. + vim.o.clipboard = 'unnamedplus' + + -- Enable break indent + vim.o.breakindent = true + + -- Save undo history + vim.o.undofile = true + + -- Keep signcolumn on by default + vim.wo.signcolumn = 'yes' + + -- Decrease update time + vim.o.updatetime = 250 + vim.o.timeoutlen = 300 + + -- Place splits below and to the right by default + vim.o.splitbelow = true + vim.o.splitright = true + + -- By default don't wrap text + vim.o.wrap = false + + -- Remove cmdline when not used + vim.o.cmdheight = 0 + + -- Set completeopt to have a better completion experience + vim.o.completeopt = 'menuone,noselect' + + -- Scale neovide a bit + if vim.g.neovide then + vim.g.neovide_scale_factor = 0.75 + vim.g.neovide_hide_mouse_when_typing = true + end +end + +-- [[ Basic Keymaps ]] + +do + -- Keymaps for better default experience + -- See `:help vim.keymap.set()` + vim.keymap.set({ 'n', 'v' }, '', '', { 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 }) + + -- Better movement between tabs + vim.keymap.set('n', '', ':tabprevious', { silent = true }) + vim.keymap.set('n', '', ':tabnext', { silent = true }) + + -- Better indenting + vim.keymap.set('v', '<', '', '>gv') + + -- Save file + vim.keymap.set('n', '', ':w', { silent = true }) + + -- Disable Ex mode + vim.keymap.set('n', 'Q', '') + + -- Window movement + vim.keymap.set('n', '', 'h') + vim.keymap.set('n', '', 'j') + vim.keymap.set('n', '', 'k') + vim.keymap.set('n', '', 'l') +end + +-- Change c file comment string +vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("set-c-commentstring", { clear = true }), + pattern = {"c", "cc", "cpp", "h", "hpp"}, + callback = function(data) + vim.api.nvim_buf_set_option(data.buf, "commentstring", "// %s") + end +}) + +-- Override `ft` for .h files to `c` +vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("override-c-header-ft", { clear = true }), + pattern = "cpp", + callback = function(data) + if data.file:match("%.h$") then + vim.api.nvim_buf_set_option(data.buf, "ft", "c") + end + end +}) + +-- Remove trailing whitespace +vim.api.nvim_create_autocmd({ "BufWritePre" }, { + pattern = { "*" }, + command = [[%s/\s\+$//e]], +}) + +-- Move between windows easier in terminal windows +function _G.set_terminal_keymaps() + local opts = {buffer = 0} + vim.keymap.set('t', '', [[]], opts) + vim.keymap.set('t', '', [[wincmd h]], opts) + vim.keymap.set('t', '', [[wincmd j]], opts) + vim.keymap.set('t', '', [[wincmd k]], opts) + vim.keymap.set('t', '', [[wincmd l]], opts) +end +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +-- [[ Highlight on yank ]] +-- See `:help vim.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() + end, + group = highlight_group, + pattern = '*', +}) + +-- Add abbreviation for != => ~= in lua files +vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("MyTermOpen", { clear = true }), + pattern = "*.lua", + callback = function() + vim.api.nvim_cmd({ cmd = "abb", args = {"", "!=", "~="}}, {}) + end +}) + +-- [[ Configure Treesitter ]] +-- See `:help nvim-treesitter` +-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' +vim.defer_fn(function() + 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", "javascript", "typescript", "vimdoc", "vim" }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = false, + + highlight = { enable = true }, + indent = { enable = true }, + 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", + }, + }, + }, + } +end, 0) + +-- 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' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +-- [[ Configure LSP ]] +-- This function gets run when an LSP connects to a particular buffer. +local on_attach = function(_, 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 + + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[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', require('telescope.builtin').lsp_implementations, '[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' }) +end + +-- document existing key chains +require('which-key').register({ + ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, + ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, + ['h'] = { name = 'More git', _ = 'which_key_ignore' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, +}) + +-- 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. +-- +-- If you want to override the default filetypes that your language server will attach to you can +-- define the property 'filetypes' to the map in question. +local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- tsserver = {}, + -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, } --- THEME_BEGIN -cmd("colorscheme srcery") --- THEME_END \ No newline at end of file +-- 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) + +-- 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], + filetypes = (servers[server_name] or {}).filetypes, + } + end +} + +-- [[ Configure nvim-cmp ]] +-- See `:help cmp` +local cmp = require 'cmp' +local luasnip = require 'luasnip' +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +local lspkind = require('lspkind') +lspkind.init() + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = 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_locally_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.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + { name = 'buffer', max_item_count = 10, keyword_length = 5 }, + }, + formatting = { + format = lspkind.cmp_format{ with_text = true } + }, + experimental = { + native_menu = false, + ghost_text = true, + } +} + +-- Use buffer source for `/`. +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } +}) + +-- The line beneath this is called `modeline`. See `:help modeline` +-- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..45ead19 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,64 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "DoxygenToolkit.vim": { "branch": "master", "commit": "afd8663d36d2ec19d26befdb10e89e912d26bbd3" }, + "LuaSnip": { "branch": "master", "commit": "cdbf6f41381e5ee4810b4b09284b603d8f18365d" }, + "based.nvim": { "branch": "main", "commit": "8a36e03313a07da23f06dbd803843e0646a5a70a" }, + "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "compiler-explorer.nvim": { "branch": "master", "commit": "ee8e7a2808bdad67cd2acb61b5c9ffa7735c7ec9" }, + "diffview.nvim": { "branch": "main", "commit": "0437ef8bfdd67156d87140d692840a3c2824fa20" }, + "dressing.nvim": { "branch": "master", "commit": "8f4d62b7817455896a3c73cab642002072c114bc" }, + "editorconfig-vim": { "branch": "master", "commit": "0d54ea863089fb13be423b4aed6cca35f3a5d778" }, + "escape.nvim": { "branch": "main", "commit": "dffce29f85943cc97c478c859c837df76417028a" }, + "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, + "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, + "git-blame.nvim": { "branch": "master", "commit": "39df33dad2cbf4eb9d17264bcda0c12e670ef1c2" }, + "gitsigns.nvim": { "branch": "main", "commit": "ff01d34daaed72f271a8ffa088a7e839a60c640f" }, + "lazy.nvim": { "branch": "main", "commit": "5aaafcb3019e04dd38a011b3d4c8a0f130c422ef" }, + "lazygit.nvim": { "branch": "main", "commit": "de35012036d43bca03628d40d083f7c02a4cda3f" }, + "lsp_signature.nvim": { "branch": "master", "commit": "bdf3dc7bb03edd25c2173e0e31c2fb122052ed23" }, + "lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, + "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "e2705063f395b44f676cd26596a11007a2cbd3bd" }, + "mason.nvim": { "branch": "main", "commit": "d66c60e17dd6fd8165194b1d14d21f7eb2c1697a" }, + "move.nvim": { "branch": "main", "commit": "d663b74b4e38f257aae757541c9076b8047844d6" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "71f1841ba6c652908678cece623f52c1fea8a6cd" }, + "neodev.nvim": { "branch": "main", "commit": "ee960afffdb95472f719a72a1edb494ffea09c92" }, + "nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" }, + "nvim-bqf": { "branch": "main", "commit": "8784eebf34371049b641646d00232c2603215297" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, + "nvim-lspconfig": { "branch": "master", "commit": "2b361e043810d5587d9af0787f8ce40da92ec5e9" }, + "nvim-luapad": { "branch": "master", "commit": "a5b3d6aa1fe5fe75e6124927392a9d3a60a0ecce" }, + "nvim-navbuddy": { "branch": "master", "commit": "f137a3466a6cd1965cdcc5398daff54e66eebbe5" }, + "nvim-navic": { "branch": "master", "commit": "0ffa7ffe6588f3417e680439872f5049e38a24db" }, + "nvim-treesitter": { "branch": "master", "commit": "957f3f8c15a88ef0f0c77ecd13edf2e2578f176e" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "a7a9ba714bcc31f5453a60d48598186b6487b75c" }, + "nvim-web-devicons": { "branch": "master", "commit": "45d0237c427baba8cd05e0ab26d30e2ee58c2c82" }, + "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, + "plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" }, + "quick-scope": { "branch": "master", "commit": "256d81e391a22eeb53791ff62ce65f870418fa71" }, + "rest.nvim": { "branch": "main", "commit": "35d949df1928b44b6d941fd9015eb3f973845b1f" }, + "srcery-vim": { "branch": "master", "commit": "8ea4c4f5caf61ac4ab887fc53eabc916985db881" }, + "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, + "targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" }, + "telescope.nvim": { "branch": "master", "commit": "205f469244916716c49cc2b9026566749425c5ba" }, + "tidy.nvim": { "branch": "main", "commit": "86eab24e807ed2957d26ca43b2b76b92d0fbf8f4" }, + "todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" }, + "vim-autosource": { "branch": "main", "commit": "569440e157d6eb37fb098dfe95252533553a56f5" }, + "vim-eunuch": { "branch": "master", "commit": "67f3dd32b4dcd1c427085f42ff5f29c7adc645c6" }, + "vim-glsl": { "branch": "master", "commit": "bfd330a271933c3372fcfa8ce052970746c8e9dd" }, + "vim-indent-object": { "branch": "master", "commit": "5c5b24c959478929b54a9e831a8e2e651a465965" }, + "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "vim-smoothie": { "branch": "master", "commit": "df1e324e9f3395c630c1c523d0555a01d2eb1b7e" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vim-tmux-navigator": { "branch": "master", "commit": "7db70e08ea03b3e4d91f63713d76134512e28d7e" }, + "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }, + "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }, + "window-picker": { "branch": "main", "commit": "fd5d3348b3e254ca3134f97793b4a8c702c4ad1d" } +} \ No newline at end of file diff --git a/lua/bindings.lua b/lua/bindings.lua deleted file mode 100644 index 12df6cc..0000000 --- a/lua/bindings.lua +++ /dev/null @@ -1,52 +0,0 @@ -local map = require 'utils.map' - -local silent = {silent = true} - --- Disable Ex mode -map('n', 'Q', '') - --- Save file -map('n', '', ':w', silent) - --- Paste from register and not replace it --- map('x', 'p', '"_dP') - --- Window movement -map('n', '', 'h') -map('n', '', 'j') -map('n', '', 'k') -map('n', '', 'l') - --- Resize windows -map('n', '', ':resize -2', silent) -map('n', '', ':resize +2', silent) -map('n', '', ':vertical resize -2', silent) -map('n', '', ':vertical resize +2', silent) - --- Better indenting -map('v', '<', '', '>gv') - --- Better movement between tabs -map('n', '', ':tabprevious', silent) -map('n', '', ':tabnext', silent) - --- Move between windows easier in terminal windows -function _G.set_terminal_keymaps() - local opts = {buffer = 0} - vim.keymap.set('t', '', [[]], opts) - vim.keymap.set('t', '', [[wincmd h]], opts) - vim.keymap.set('t', '', [[wincmd j]], opts) - vim.keymap.set('t', '', [[wincmd k]], opts) - vim.keymap.set('t', '', [[wincmd l]], opts) -end -vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') - --- Add abbreviation for != => ~= in lua files -vim.api.nvim_create_autocmd("BufEnter", { - group = vim.api.nvim_create_augroup("MyTermOpen", { clear = true }), - pattern = "*.lua", - callback = function() - vim.api.nvim_cmd({ cmd = "abb", args = {"", "!=", "~="}}, {}) - end -}) diff --git a/lua/config/autosource.lua b/lua/config/autosource.lua deleted file mode 100644 index 0d38e58..0000000 --- a/lua/config/autosource.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - 'jenterkin/vim-autosource', - config = function() - local data = vim.fn.stdpath("data") - vim.g.autosource_hashdir = data .. '/vim-autosource/hashes' - end -} diff --git a/lua/config/baleia.lua b/lua/config/baleia.lua deleted file mode 100644 index bd70bff..0000000 --- a/lua/config/baleia.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 'm00qek/baleia.nvim', - tag = 'v1.2.0', - config = function() - local baleia = require("baleia").setup() - vim.api.nvim_create_user_command("BaleiaColorize", function() - baleia.once(vim.api.nvim_get_current_buf()) - end, { }) - - require("legendary").command{ - ":BaleiaColorize", description = "Colorize ANSI codes" - } - end -} diff --git a/lua/config/based.lua b/lua/config/based.lua deleted file mode 100644 index 5cffb22..0000000 --- a/lua/config/based.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - 'trmckay/based.nvim', - config = function () - local based = require("based") - based.setup{} - - vim.keymap.set({"n", "v"}, "", based.convert) - - require("legendary").keymap{ - "", - { n = based.convert, v = based.convert }, - description = "Convert number to other base" - } - end -} diff --git a/lua/config/cmp.lua b/lua/config/cmp.lua deleted file mode 100644 index 1cccff9..0000000 --- a/lua/config/cmp.lua +++ /dev/null @@ -1,94 +0,0 @@ --- Setup nvim-cmp. -local lspkind = require('lspkind') -lspkind.init() - -local cmp = require('cmp') -local luasnip = require("luasnip") - -local function has_words_before() - 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 - -cmp.setup{ - completion = { completeopt = 'menu,menuone,noinsert' }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - mapping = { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - 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_lua' }, - - { name = 'nvim_lsp', max_item_count = 20 }, - { name = 'luasnip' }, - { name = 'cmp_tabnine' }, - { name = 'path' }, - { name = 'buffer', max_item_count = 10, keyword_length = 5 }, - }, - formatting = { - format = lspkind.cmp_format{ - with_text = true, - menu = { - buffer = "[buf]", - cmp_tabnine = "[tab9]", - nvim_lsp = "[lsp]", - nvim_lua = "[api]", - path = "[path]", - luasnip = "[snip]", - } - } - }, - experimental = { - native_menu = false, - ghost_text = true, - } -} - --- Use buffer source for `/`. -cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } - } -}) - --- Use cmdline & path source for ':'. --- cmp.setup.cmdline(':', { --- sources = cmp.config.sources({ --- { name = 'path' } --- }, { --- { name = 'cmdline' } --- }) --- }) diff --git a/lua/config/colorizer.lua b/lua/config/colorizer.lua deleted file mode 100644 index 98dd054..0000000 --- a/lua/config/colorizer.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - 'norcalli/nvim-colorizer.lua', - config = function() - require('colorizer').setup( - nil, - { - RGB = true, - RRGGBB = true, - names = false, - RRGGBBAA = true, - rgb_fn = true, - hsl_fn = true, - css = false, - css_fn = false, - mode = 'background' - } - ) - end -} diff --git a/lua/config/comment.lua b/lua/config/comment.lua deleted file mode 100644 index b360fd1..0000000 --- a/lua/config/comment.lua +++ /dev/null @@ -1,17 +0,0 @@ -return { - 'terrortylor/nvim-comment', - requires = 'JoosepAlviste/nvim-ts-context-commentstring', - config = function() - local config = {} - - if packer_plugins['nvim-ts-context-commentstring'] and packer_plugins['nvim-ts-context-commentstring'].loaded then - config.hook = function() - if vim.api.nvim_buf_get_option(0, "filetype") == "vue" then - require("ts_context_commentstring.internal").update_commentstring() - end - end - end - - require("nvim_comment").setup(config) - end -} diff --git a/lua/config/devicons.lua b/lua/config/devicons.lua deleted file mode 100644 index aebc460..0000000 --- a/lua/config/devicons.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'kyazdani42/nvim-web-devicons', - config = function() require('nvim-web-devicons').setup() end -} diff --git a/lua/config/diffview.lua b/lua/config/diffview.lua deleted file mode 100644 index e7c0c96..0000000 --- a/lua/config/diffview.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - "sindrets/diffview.nvim", - requires = 'nvim-lua/plenary.nvim', - config = function() - require("diffview").setup{ - enhanced_diff_hl = true - } - require("legendary").command{ - ":DiffviewOpen", description = "Open diff view" - } - end -} diff --git a/lua/config/doxygen-tk.lua b/lua/config/doxygen-tk.lua deleted file mode 100644 index cc4a9b8..0000000 --- a/lua/config/doxygen-tk.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - "vim-scripts/DoxygenToolkit.vim", - config = function() - vim.g.DoxygenToolkit_startCommentTag = "/// " - vim.g.DoxygenToolkit_interCommentTag = "/// " - vim.g.DoxygenToolkit_endCommentTag = "" - vim.g.DoxygenToolkit_startCommentBlock = "// " - vim.g.DoxygenToolkit_interCommentBlock = "// " - vim.g.DoxygenToolkit_endCommentBlock = "" - end -} diff --git a/lua/config/dressing.lua b/lua/config/dressing.lua deleted file mode 100644 index 2c88375..0000000 --- a/lua/config/dressing.lua +++ /dev/null @@ -1,27 +0,0 @@ -return { - "stevearc/dressing.nvim", - requires = "nvim-telescope/telescope.nvim", - config = function() - require('dressing').setup({ - select = { - get_config = function(opts) - opts = opts or {} - local cfg = { - telescope = { - layout_config = { - -- width = 120, - -- height = 60, - width = 0.87, - height = 0.80, - }, - }, - } - if opts.kind == 'legendary.nvim' then - cfg.telescope.sorter = require('telescope.sorters').fuzzy_with_index_bias({}) - end - return cfg - end, - }, - }) - end -} diff --git a/lua/config/escape.lua b/lua/config/escape.lua deleted file mode 100644 index 23bb2cb..0000000 --- a/lua/config/escape.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - "m-gail/escape.nvim", - config = function() - local escape = require("escape").escape - - require("legendary").keymaps{ - {"e", escape, description="Escape quotes", mode={"v"}, opts={noremap=true,silent = true}} - } - end -} diff --git a/lua/config/git-conflict.lua b/lua/config/git-conflict.lua deleted file mode 100644 index 50c17fc..0000000 --- a/lua/config/git-conflict.lua +++ /dev/null @@ -1,26 +0,0 @@ -return { - 'akinsho/git-conflict.nvim', - tag = "*", - config = function() - require('git-conflict').setup{ - default_mappings = false - } - - - require("legendary").keymaps{ - { - itemgroup = "git-conflict", - description = "Git conflict", - icon = "", - keymaps = { - { 'co', '(git-conflict-ours)', description = "choose ours" }, - { 'ct', '(git-conflict-theirs)', description = "choose theirs" }, - { 'cb', '(git-conflict-both)', description = "choose both" }, - { 'c0', '(git-conflict-none)', description = "choose none" }, - { ']x', '(git-conflict-prev-conflict)', description = "move to previous conflict" }, - { '[x', '(git-conflict-next-conflict)', description = "move to next conflict" }, - } - } - } - end -} diff --git a/lua/config/gitblame.lua b/lua/config/gitblame.lua deleted file mode 100644 index 4fe7786..0000000 --- a/lua/config/gitblame.lua +++ /dev/null @@ -1,22 +0,0 @@ -return { - 'f-person/git-blame.nvim', - config = function () - local silent = {silent = true} - - require("legendary").keymaps{ - { - itemgroup = "gitblame", - description = "Git blame", - icon = "", - keymaps = { - {"gm", ":GitBlameCopySHA", description = "Copy commit hash", opts = silent}, - {"gj", ":GitBlameOpenCommit", description = "Open commit", opts = silent}, - {"gu", ":GitBlameToggle", description = "Toggle git blame", opts = silent}, - } - } - } - - vim.g["gitblame_enabled"] = 0 - vim.g["gitblame_date_format"] = "%r" - end -} diff --git a/lua/config/gitsigns.lua b/lua/config/gitsigns.lua deleted file mode 100644 index 7f84daf..0000000 --- a/lua/config/gitsigns.lua +++ /dev/null @@ -1,42 +0,0 @@ -return { - 'lewis6991/gitsigns.nvim', - requires = 'nvim-lua/plenary.nvim', - config = function () - local gitsigns = require 'gitsigns' - - gitsigns.setup{ - on_attach = function(bufnr) - local function keymap_n(key, command, description, opts) - opts = vim.tbl_extend('force', {noremap = true, silent = true, buffer=bufnr}, opts or {}) - return {key, command, description=description, opts=opts} - end - local function keymap_vn(key, command, description, opts) - opts = vim.tbl_extend('force', {noremap = true, silent = true, buffer=bufnr}, opts or {}) - return {key, command, mode={"v", "n"}, description=description, opts=opts} - end - - require("legendary").keymaps{ - { - itemgroup = "githunks", - description = "Git hunks", - icon = "", - keymaps = { - keymap_n(']c', "&diff ? ']c' : 'Gitsigns next_hunk'", "Jump to next hunk", {expr=true}), - keymap_n('[c', "&diff ? '[c' : 'Gitsigns prev_hunk'", "Jump to prev hunk", {expr=true}), - - keymap_vn("hs", ":Gitsigns stage_hunk", "Stage hunk"), - keymap_vn("hr", ":Gitsigns reset_hunk", "Reset hunk"), - keymap_n("hS", "Gitsigns stage_buffer", "Stage buffer"), - keymap_n("hu", "Gitsigns undo_stage_hunk", "Undo stage hunk"), - keymap_n("hR", "Gitsigns reset_buffer", "Reset buffer"), - keymap_n("hp", "Gitsigns preview_hunk", "Preview hunk"), - keymap_n('td', 'Gitsigns toggle_deleted', "Toggle deleted"), - - {'ih', {o=':Gitsigns select_hunk', x=':Gitsigns select_hunk'}, description="Select hunk" } - } - } - } - end - } - end -} diff --git a/lua/config/lazygit.lua b/lua/config/lazygit.lua deleted file mode 100644 index 3ed8ede..0000000 --- a/lua/config/lazygit.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - 'kdheepak/lazygit.nvim', - config = function () - require("legendary").keymaps{ - {"gg", ":LazyGit", description = "Open lazygit", opts = {silent = true}} - } - end -} diff --git a/lua/config/leap.lua b/lua/config/leap.lua deleted file mode 100644 index 1e52c73..0000000 --- a/lua/config/leap.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'ggandor/leap.nvim', - config = function() - local silent = {silent=true} - - require("legendary").keymaps{ - {"s", "(leap-forward-to)", description="Leap forward", opts=silent}, - {"S", "(leap-backward-to)", description="Leap backward", opts=silent} - } - - end -} diff --git a/lua/config/legendary.lua b/lua/config/legendary.lua deleted file mode 100644 index b9993d3..0000000 --- a/lua/config/legendary.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'mrjones2014/legendary.nvim', - requires = 'stevearc/dressing.nvim', - config = function() - require("legendary").setup{ - include_legendary_cmds = false, - keymaps = { - {"l", ":Legendary", description = "Open this help menu"} - } - } - end -} diff --git a/lua/config/lspconfig.lua b/lua/config/lspconfig.lua deleted file mode 100644 index 657d866..0000000 --- a/lua/config/lspconfig.lua +++ /dev/null @@ -1,166 +0,0 @@ -local cfg = {} - --- debounce_text_changes = delay, between changing something and lsp updating -cfg.flags = { debounce_text_changes = 150 } - -local general_settings = { } -cfg.server_init_options = { - efm = { - documentFormatting = true - } -} - -cfg.server_settings = { - efm = { - rootMarkers = {".git/"}, - languages = { - lua = { - { formatCommand = "lua-format -i", formatStdin = true } - } - }, - }, - jsonls = { - json = { - schemas = { - { - fileMatch = {"package.json"}, - url = "https://json.schemastore.org/package.json" - }, - { - fileMatch = {"tsconfig*.json"}, - url = "https://json.schemastore.org/tsconfig.json" - }, - } - } - }, - - -- "Lua.runtime.version": "LuaJIT", - -- "Lua.workspace.library": ["${3rd}/love2d/library"], - -- "Lua.workspace.checkThirdParty": false, - -- "Lua.diagnostics.disable": ["undefined-field"] - sumneko_lua = { - Lua = { - -- runtime = { - -- version = "LuaJIT" - -- }, - workspace = { - checkThirdParty = false, - -- library = {"${3rd}/love2d/library"} - }, - telemetry = { enable = false } - - -- } - -- Lua = { - -- runtime = { - -- -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - -- version = 'LuaJIT', - -- -- Setup your lua path - -- path = vim.split(package.path, ';') - -- }, - -- diagnostics = { - -- -- Get the language server to recognize the `vim` global - -- globals = {'vim', 'packer_plugins'} - -- }, - -- workspace = { - -- -- Make the server aware of Neovim runtime files - -- library = vim.api.nvim_get_runtime_file("", true) - -- }, - } - }, - - rust_analyzer = { - ["rust-analyzer"] = { - checkOnSave = { - command = "clippy" - } - } - }, - - pyright = { - python = { - pythonPath = "python3" - } - } -} - --- Apply general settings for each server -for _, settings in ipairs(cfg.server_settings) do - cfg.server_settings = vim.tbl_deep_extend("keep", settings, general_settings) -end - --- Use an on_attach function to only map the following keys --- after the language server attaches to the current buffer ----@diagnostic disable-next-line: unused-local -function cfg.on_attach(client, bufnr) - -- Mappings. - local opts = { noremap = true, silent = true, buffer = bufnr} - - -- local function keymap(mode, lhs, rhs) vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - - require("legendary").keymaps{ - { - itemgroup = "lsp", - description = "LSP", - keymaps = { - {'gd', 'lua vim.lsp.buf.definition()', description = "Jump to definition", opts=opts}, - {'gD', 'lua vim.lsp.buf.declaration()', description = "Jump to declaration", opts=opts}, - {'gi', 'lua vim.lsp.buf.implementation()', description = "Jump to implementation", opts=opts}, - {'K', 'lua vim.lsp.buf.hover()', description = "Show info", opts=opts}, - {'rn', 'lua vim.lsp.buf.rename()', description = "Rename symbol"}, - {'ca', 'lua vim.lsp.buf.code_action()', description = "Show code actions"}, - {'d', 'lua vim.diagnostic.open_float()', description = "Open float"} - } - } - } - - -- Enable completion triggered by - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- See `:help vim.lsp.*` for documentation on any of the below functions - - -- Conflicts with movement between panes - -- buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()') - - -- buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()') - -- buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()') - -- buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') - -- buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()') - -- buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()') - -- buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()') - -- buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()') - -- buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()') - - -- " auto-format - -- autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100) - -- autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100) - -- autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 100) -end - -function cfg.get_capabilities() - local capabilities = vim.lsp.protocol.make_client_capabilities() - - if packer_plugins['cmp-nvim-lsp'] and packer_plugins['cmp-nvim-lsp'].loaded then - capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - end - - return capabilities -end - -function cfg.on_init(initialize_params, config) - -- print("lsp init") - - -- TODO: Load settings from ".lspconfig.json" for each projects settings - -- and merge them with the defaults - -- https://github.com/neovim/nvim-lspconfig/wiki/Project-local-settings -end - -function cfg.get_server_settings(name) - return cfg.server_settings[name] -end - -function cfg.get_server_init_options(name) - return cfg.server_init_options[name] -end - -return cfg diff --git a/lua/config/lspsignature.lua b/lua/config/lspsignature.lua deleted file mode 100644 index 36c18a4..0000000 --- a/lua/config/lspsignature.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - "ray-x/lsp_signature.nvim", - config = function() - local lsp_signature = require("lsp_signature") - - lsp_signature.setup{ - hint_enable = false, - toggle_key = nil, - handler_opts = { - border = { " ", " ", " ", " ", " ", " ", " ", " " } - } - } - - -- require("legendary").keymap{ - -- "x", lsp_signature.toggle_float_win, description="Toggle signature float" - -- } - end -} diff --git a/lua/config/lsputils.lua b/lua/config/lsputils.lua deleted file mode 100644 index d3dd310..0000000 --- a/lua/config/lsputils.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - 'RishabhRD/nvim-lsputils', - requires = 'RishabhRD/popfix', - config = function() - vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler - vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler - vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler - vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler - vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler - vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler - vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler - vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler - end -} diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua deleted file mode 100644 index c2a47b7..0000000 --- a/lua/config/lualine.lua +++ /dev/null @@ -1,161 +0,0 @@ -local bg = vim.g.srcery_xgray1 - -local colors = { - red = vim.g.srcery_red, - grey = vim.g.srcery_black, - black = vim.g.srcery_hard_black, - white = vim.g.srcery_bright_white, - light_green = vim.g.srcery_bright_green, - orange = vim.g.srcery_orange, - green = vim.g.srcery_green, -} - -local theme = { - normal = { - a = { fg = colors.white, bg = colors.black }, - b = { fg = colors.white, bg = colors.grey }, - c = { fg = colors.black, bg = bg }, - z = { fg = colors.white, bg = colors.black }, - }, - insert = { a = { fg = colors.black, bg = colors.light_green } }, - visual = { a = { fg = colors.black, bg = colors.orange } }, - replace = { a = { fg = colors.black, bg = colors.green } }, -} - -local empty = require('lualine.component'):extend() -function empty:draw(default_highlight) - self.status = '' - self.applied_separator = '' - self:apply_highlights(default_highlight) - self:apply_section_separators() - return self.status -end - --- Put proper separators and gaps between components in sections -local function process_sections(sections) - for name, section in pairs(sections) do - local left = name:sub(9, 10) < 'x' - for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do - table.insert(section, pos * 2, { empty, color = { fg = bg, bg = bg } }) - end - for id, comp in ipairs(section) do - if type(comp) ~= 'table' then - comp = { comp } - section[id] = comp - end - comp.separator = left and { right = '' } or { left = '' } - end - end - return sections -end - -local function search_result() - local last_search = vim.fn.getreg('/') - if not last_search or last_search == '' then - return '' - end - local searchcount = vim.fn.searchcount { maxcount = 9999 } - if searchcount.total == 0 then - return '' - end - return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' -end - -local function modified() - if vim.bo.modified then - return '+' - elseif vim.bo.modifiable == false or vim.bo.readonly == true then - return '-' - end - return '' -end - -local function recording_macro() - local reg = vim.api.nvim_call_function("reg_recording", {}) - if reg ~= "" then - return "@" .. reg - else - return "" - end -end - -local extensions = {"man", "quickfix"} -if pcall(require, "nvim-tree") then - table.insert(extensions, "nvim-tree") -end -if pcall(require, "toggleterm") then - table.insert(extensions, "toggleterm") -end -if pcall(require, "luapad.statusline") then - table.insert(extensions, { - sections = process_sections { - lualine_a = {'mode'}, - lualine_b = { - { - 'diagnostics', - source = { 'nvim' }, - sections = { 'error' }, - diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, - }, - { - 'diagnostics', - source = { 'nvim' }, - sections = { 'warn' }, - diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, - }, - { recording_macro, color = { bg = colors.orange } } - }, - lualine_y = { search_result, 'filetype' }, - lualine_z = { '%l:%c', '%p%%/%L' }, - }, - filetypes = {'lua.luapad'} - }) -end - -require('lualine').setup { - options = { - theme = theme, - component_separators = '', - section_separators = { left = '', right = '' }, - -- ignore_focus = {"NvimTree"}, - globalstatus = true - }, - sections = process_sections { - lualine_a = { 'mode' }, - lualine_b = { - 'branch', - 'diff', - { - 'diagnostics', - source = { 'nvim' }, - sections = { 'error' }, - diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, - }, - { - 'diagnostics', - source = { 'nvim' }, - sections = { 'warn' }, - diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, - }, - { 'filename', file_status = false, path = 1 }, - { modified, color = { bg = colors.red } }, - { '%w', cond = function() return vim.wo.previewwindow end }, - { '%r', cond = function() return vim.bo.readonly end }, - { '%q', cond = function() return vim.bo.buftype == 'quickfix' end }, - { recording_macro, color = { bg = colors.orange } } - }, - lualine_c = {}, - lualine_x = {}, - lualine_y = { search_result, 'filetype' }, - lualine_z = { '%l:%c', '%p%%/%L' }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {}, - lualine_x = {}, - lualine_y = {}, - lualine_z = {}, - }, - extensions = extensions -} diff --git a/lua/config/luapad.lua b/lua/config/luapad.lua deleted file mode 100644 index 3ef3994..0000000 --- a/lua/config/luapad.lua +++ /dev/null @@ -1,15 +0,0 @@ -local pattern = "^/tmp/.*/%d+_Luapad%.lua$" -local group = vim.api.nvim_create_augroup("LuaPadFiletype", {clear=true}) -vim.api.nvim_create_autocmd("FileType", { - group = group, - callback = function(data) - if data.file:match(pattern) then - vim.bo[data.buf].filetype = "lua.luapad" - end - end -}) - -require("legendary").commands{ - { ":Luapad", description = "Open interactive lua" }, - { ":LuaRun", description = "Run lua from current buffer" } -} diff --git a/lua/config/luasnip.lua b/lua/config/luasnip.lua deleted file mode 100644 index 87285c7..0000000 --- a/lua/config/luasnip.lua +++ /dev/null @@ -1,99 +0,0 @@ -local function config() - local ls = require("luasnip") - local capture = require("utils.capture") - local s = ls.snippet - local sn = ls.snippet_node - local fmt = require("luasnip.extras.fmt").fmt - local t = ls.text_node - local i = ls.insert_node - local f = ls.function_node - local c = ls.choice_node - local d = ls.dynamic_node - - local function getCurrentYear() - return os.date("%Y") - end - - local function getGitUsername() - local stdout = capture("git config user.name") - if stdout == "" then - return nil - end - return stdout - end - - ls.config.set_config { - history = true, - updateevents = "TextChanged,TextChangedI", - enable_autosnippets = true - } - - vim.keymap.set({"i", "s"}, "", function() - if ls.expand_or_jumpable() then - ls.expand_or_jump() - end - end, { silent = true }) - - vim.keymap.set({ "i", "s" }, "", function() - if ls.jumpable(-1) then - ls.jump(-1) - end - end, { silent = -1 }) - - vim.keymap.set({"i"}, "", function() - if ls.choice_active() then - ls.change_choice(1) - end - end) - - ls.add_snippets("all", { - s("MIT", { - t({"The MIT License (MIT)", "Copyright © "}), - f(getCurrentYear, {}), - t(" "), - d(1, function() - return sn(nil, { - i(1, getGitUsername() or "") - }) - end, {}), - t{ - "", - "", - "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.", - } - }) - }) - - ls.add_snippets("lua", { - s("req", - fmt([[local {} = require("{}")]], { - f(function(module_name) - local parts = vim.split(module_name[1][1], ".", true) - return (parts[#parts] or ""):gsub("-", "_") - end, { 1 }), - i(1) - }) - ) - }) -end - -return { - 'L3MON4D3/LuaSnip', - config = config -} diff --git a/lua/config/mason-lspconfig.lua b/lua/config/mason-lspconfig.lua deleted file mode 100644 index 871bd2e..0000000 --- a/lua/config/mason-lspconfig.lua +++ /dev/null @@ -1,40 +0,0 @@ -local lspconfig_config = require('config.lspconfig') - -local function get_options(server_name) - return { - root_dir = function() - return vim.fn.getcwd() - end, - init_options = lspconfig_config.get_server_init_options(server_name), - on_attach = lspconfig_config.on_attach, - on_init = lspconfig_config.on_init, - flags = lspconfig_config.flags, - capabilities = capabilities, - settings = lspconfig_config.get_server_settings(server_name) - } -end - -require("mason").setup() -require("mason-lspconfig").setup() -require("mason-lspconfig").setup_handlers{ - function (server_name) -- default handler (optional) - require("lspconfig")[server_name].setup(get_options(server_name)) - end, - ["rust_analyzer"] = function () - local opts = get_options(server_name) - - local has_rust_tools, rust_tools = pcall(require, "rust-tools") - if has_rust_tools then - rust_tools.setup({ - server = opts, - tools = { - inlay_hints = { - auto = false - } - } - }) - else - require("lspconfig")[server_name].setup(opts) - end - end -} diff --git a/lua/config/mason.lua b/lua/config/mason.lua deleted file mode 100644 index ac26661..0000000 --- a/lua/config/mason.lua +++ /dev/null @@ -1 +0,0 @@ -require("mason").setup() diff --git a/lua/config/move.lua b/lua/config/move.lua deleted file mode 100644 index 49aeadf..0000000 --- a/lua/config/move.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - 'fedepujol/move.nvim', - config = function() - local opts = { noremap = true, silent = true } - - require("legendary").keymaps{ - {mode='v', '', ':MoveBlock(1)', description = "Move block up", opts=opts}, - {mode='v', '', ':MoveBlock(-1)', description = "Move block down", opts=opts}, - } - end -} diff --git a/lua/config/navbuddy.lua b/lua/config/navbuddy.lua deleted file mode 100644 index b3970dd..0000000 --- a/lua/config/navbuddy.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - "SmiteshP/nvim-navbuddy", - requires = { - "neovim/nvim-lspconfig", - "SmiteshP/nvim-navic", - "MunifTanjim/nui.nvim", - "nvim-telescope/telescope.nvim" - }, - - config = function() - local navbuddy = require("nvim-navbuddy") - - require("legendary").keymaps{ - {"o", ":Navbuddy", description="Navbuddy"} - } - - navbuddy.setup { - window = { - border = "rounded", - size = "60%", - position = "50%", - sections = { - left = { size = "20%" }, - mid = { size = "40%" }, - right = { preview = "leaf" } - }, - }, - node_markers = { enabled = true }, - use_default_mappings = true, - lsp = { auto_attach = true } - } - end -} diff --git a/lua/config/nvim-tree.lua b/lua/config/nvim-tree.lua deleted file mode 100644 index 5271c87..0000000 --- a/lua/config/nvim-tree.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - 'kyazdani42/nvim-tree.lua', - requires = 'kyazdani42/nvim-web-devicons', - config = function () - require("nvim-tree").setup{ - git = { - enable = false - }, - renderer = { - group_empty = true, - }, - } - - require("legendary").keymaps{ - {"e", ":NvimTreeToggle", description = "Toggle file tree", {silent = true}}, - {"f", ":NvimTreeFindFileToggle", description = "Show file in tree", {silent = true}} - } - end -} diff --git a/lua/config/quickscope.lua b/lua/config/quickscope.lua deleted file mode 100644 index a78d999..0000000 --- a/lua/config/quickscope.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - 'unblevable/quick-scope', - config = function () - -- Trigger a highlight in the appropriate direction when pressing these keys: - vim.g['qs_highlight_on_keys'] = {'f', 'F', 't', 'T'} - - vim.g['qs_max_chars'] = 150 - end -} diff --git a/lua/config/tabnine.lua b/lua/config/tabnine.lua deleted file mode 100644 index 53b6123..0000000 --- a/lua/config/tabnine.lua +++ /dev/null @@ -1,10 +0,0 @@ -local tabnine = require('cmp_tabnine.config') - -tabnine:setup{ - max_lines = 1000, - max_num_results = 20, - sort = true, - run_on_every_keystroke = true, - snippet_placeholder = '..' -} - diff --git a/lua/config/telescope.lua b/lua/config/telescope.lua deleted file mode 100644 index 2b151b1..0000000 --- a/lua/config/telescope.lua +++ /dev/null @@ -1,138 +0,0 @@ -local telescope = require('telescope') -local actions = require('telescope.actions') -local builtin = require('telescope.builtin') - --- Falling back to find_files if git_files can't find a .git directory -local function project_files() - local opts = { prompt_title = 'Project files' } - local ok = pcall(builtin.git_files, opts) - if not ok then builtin.find_files(opts) end -end - -local function edit_config() - return M.project_files{ - cwd = "~/.config/nvim", - prompt_title = "Neovim config" - } -end - -telescope.setup{ - defaults = { - vimgrep_arguments = { - "rg", - "-L", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, - prompt_prefix = "  ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "ascending", - layout_strategy = "horizontal", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.55, - results_width = 0.8, - }, - vertical = { mirror = false }, - width = 0.87, - height = 0.80, - preview_cutoff = 120, - }, - file_sorter = require("telescope.sorters").get_fuzzy_file, - file_ignore_patterns = { "node_modules" }, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - path_display = { "truncate" }, - color_devicons = true, - winblend = 0, - border = {}, - borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, - mappings = { - i = { [""] = actions.close } - }, - }, - pickers = { - live_grep = { - disable_coordinates = true - }, - colorscheme = { - enable_preview = true - } - }, - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown {} - } - } -} - -telescope.load_extension("ui-select") - -local fzfPlugin = packer_plugins["telescope-fzf-native.nvim"] -if fzfPlugin and fzfPlugin.loaded then - telescope.load_extension('fzf') -end - -local function get_vtext() - local prev_regv = vim.fn.getreg('v') - vim.cmd('noau normal! "vy"') - local text = vim.fn.getreg('v') - vim.fn.setreg("v", prev_regv) - - text = string.gsub(text, "\n", "") - if #text > 0 then - return text - else - return "" - end -end - -local function escape_sed_symbols(text) - return text:gsub("[.()%[%]]", "\\%1") -end - -local keymaps = { - -- Search project files - { "", project_files, description = "Open git files" }, - - -- Search files from current working directory - { "p", function() builtin.find_files() end, description = "Open files" }, - - -- Edit neovim config - {"ce", edit_config, description = "Edit neovim config" }, - - -- Grep string - { "fw", { - n = function() builtin.live_grep() end, - v = function(a) - local text = escape_sed_symbols(get_vtext()) - builtin.live_grep{ default_text = text } - end - }, description = "Grep" }, - - -- Change colorscheme - { "cs", function() builtin.colorscheme() end, description = "Change colorscheme" }, - - -- See help tags - { "fh", function() builtin.help_tags() end, description = "Search help tags" } -} - -local silent = {silent = true} -for _, keymap in ipairs(keymaps) do - keymap.opts = silent -end - -require("legendary").keymaps(keymaps) diff --git a/lua/config/tidy.lua b/lua/config/tidy.lua deleted file mode 100644 index f44885e..0000000 --- a/lua/config/tidy.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - "mcauley-penney/tidy.nvim", - config = function() require("tidy").setup() end -} diff --git a/lua/config/todo-comments.lua b/lua/config/todo-comments.lua deleted file mode 100644 index 2081f9d..0000000 --- a/lua/config/todo-comments.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - "folke/todo-comments.nvim", - requires = "nvim-lua/plenary.nvim", - config = function() - require("todo-comments").setup { signs = false } - - require("legendary").command{ - ":TodoTelescope", description = "Show TODO's in telescope" - } - end -} diff --git a/lua/config/toggleterm.lua b/lua/config/toggleterm.lua deleted file mode 100644 index 8da2232..0000000 --- a/lua/config/toggleterm.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - 'akinsho/toggleterm.nvim', - tag = '*', - config = function() - require('toggleterm').setup() - - require("legendary").keymap{ - "t", ":ToggleTerm", description = "Toggle terminal", opts = { silent = true } - } - end -} diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua deleted file mode 100644 index 72530d8..0000000 --- a/lua/config/treesitter.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - 'nvim-treesitter/nvim-treesitter', - run = function() require('nvim-treesitter.install').update{ with_sync = true } end, - config = function () - local treesitter = require("nvim-treesitter.configs") - if vim.fn.has("win32") then - require('nvim-treesitter.install').compilers = { "clang" } - end - - treesitter.setup{ - highlight = { enable = true }, - auto_install = true - } - end -} diff --git a/lua/config/trouble.lua b/lua/config/trouble.lua deleted file mode 100644 index 324ce86..0000000 --- a/lua/config/trouble.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - 'folke/trouble.nvim', - requires = 'kyazdani42/nvim-web-devicons', - config = function () - require('trouble').setup() - - local silent = {silent = true} - - require("legendary").keymaps{ - {'qq', ':TroubleToggle document_diagnostics', description="Toggle file diagnostics", opts=silent}, - {'qf', ':TroubleToggle workspace_diagnostics', description="Toggle workspace diagnostics", opts=silent}, - {'gr', ':TroubleToggle lsp_references', description="Show references in trouble", opts=silent}, - } - end -} diff --git a/lua/config/ts-playground.lua b/lua/config/ts-playground.lua deleted file mode 100644 index 9b48306..0000000 --- a/lua/config/ts-playground.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - 'nvim-treesitter/playground', - requires = 'nvim-treesitter/nvim-treesitter', - cmd = "TSPlaygroundToggle" -} diff --git a/lua/config/ufo.lua b/lua/config/ufo.lua deleted file mode 100644 index fad5d13..0000000 --- a/lua/config/ufo.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - "kevinhwang91/nvim-ufo", - requires = {"kevinhwang91/promise-async", "nvim-treesitter/nvim-treesitter"}, - config = function () - local default = {"treesitter", "indent"} - local filetypes = { c = {'indent'} } - - require("ufo").setup({ - provider_selector = function(bufnr, filetype, buftype) - return filetypes[filetype] or default - end - }) - vim.api.nvim_set_hl(0, "UfoFoldedBg", { link = "ColorColumn" }) - end -} diff --git a/lua/disable-builtin.lua b/lua/disable-builtin.lua deleted file mode 100644 index 6c6fe83..0000000 --- a/lua/disable-builtin.lua +++ /dev/null @@ -1,11 +0,0 @@ -local disabled_built_ins = { - 'matchit', - 'netrw', - 'netrwPlugin', - 'netrwSettings', - 'netrwFileHandlers', -} - -for _, name in ipairs(disabled_built_ins) do - vim.g['loaded_' .. name] = 1 -end diff --git a/lua/highlight-yank.lua b/lua/highlight-yank.lua deleted file mode 100644 index 15db80a..0000000 --- a/lua/highlight-yank.lua +++ /dev/null @@ -1,5 +0,0 @@ -local autocmd = require 'utils.autocmd' - -autocmd("highlight_yank", { - [[TextYankPost * silent! lua vim.highlight.on_yank({higroup="IncSearch", timeout=150})]] -}, true) diff --git a/lua/config/dap.lua b/lua/old_dap_cfg.lua similarity index 100% rename from lua/config/dap.lua rename to lua/old_dap_cfg.lua diff --git a/lua/options.lua b/lua/options.lua deleted file mode 100644 index c975ab1..0000000 --- a/lua/options.lua +++ /dev/null @@ -1,151 +0,0 @@ -local opt = require 'utils.opt' -local autocmd = require 'utils.autocmd' -local o, wo, bo = vim.o, vim.wo, vim.bo -local cmd = vim.cmd - -cmd [[syntax on]] -cmd [[filetype plugin on]] - - -local buffer = { o, bo } -local window = { o, wo } - --- Enable auto reload of changed files -opt('autoread', true) -autocmd("auto-reload", { - [[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif]], - [[FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]] -}, true) - --- List of possible completion options -opt('completeopt', 'menu,menuone,noselect') - --- Pseudo transparent popup window -opt('pumblend', 15) -cmd [[highlight PmenuSel blend=0]] - --- Don't wrap text to next line if there isin't enough space -opt('wrap', false) - --- Highlight current line -opt('cursorline', true, window) - --- Store less in shada files -opt('shada', [['20,<50,s10,h,/100]]) - --- Show current mode that you are in -opt('showmode', true) - --- Keep non-visible files open -opt('hidden', true) - --- Skip redrawing window while executing macro -opt('lazyredraw', true) - --- Always use system clipboard -opt('clipboard', 'unnamedplus') - --- Amount of time after which while typing mapping will be canceled -opt('timeoutlen', 300) - --- How whitespace characters should be displayed -opt('listchars', [[space:.,eol:$,tab:>-]]) - --- If possible use 24 Bit Colors -if vim.fn.has('termguicolors') == 1 then - opt('termguicolors', true) -end - --- Better Searching (Incremental searching, live replacing) -opt('ignorecase', true) -opt('smartcase', true) -opt('hlsearch', false) -opt('incsearch', true) -opt('inccommand', 'nosplit') - --- Always keep at least 8 blank lines below the last line -opt('scrolloff', 8) - -opt('colorcolumn', '110') - --- Break lines --- opt('textwidth', 80) - --- Display relative and absolute line numbers -opt('number', true, window) -opt('relativenumber', true, window) - --- Recovery -opt('undofile', true, buffer) - --- Mouse support -opt('mouse', 'nivh') -opt('mousemodel', 'extend') - --- Auto sign column -opt('signcolumn', 'auto:1', window) - --- Disable those annoying DINGS when you pressing something too much -opt('errorbells', false) - --- Always use system clipboard -opt('clipboard', 'unnamedplus') - --- Folding options -opt('foldmethod', 'indent') -opt('foldlevelstart', 99) - --- Identation/Tab settings -local tab_size = 4 -opt('expandtab', false, buffer) -opt('smartindent', true, buffer) -opt('shiftwidth', tab_size, buffer) -opt('tabstop', tab_size, buffer) -opt('softtabstop', tab_size, buffer) -opt('cinkeys', '0{,0},0),0],:,!^F,o,O,e') -opt('cinoptions', 's,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#1,P0') - --- Place splits below and to the right by default -opt('splitbelow', true) -opt('splitright', true) - --- Remove cmdline when not used -opt('cmdheight', 0) - --- Scale neovide a bit -if vim.g.neovide then - vim.g.neovide_scale_factor = 0.75 - vim.g.neovide_hide_mouse_when_typing = true -end - --- Change c file comment string -vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("set-c-commentstring", { clear = true }), - pattern = {"c", "cc", "cpp", "h", "hpp"}, - callback = function(data) - vim.api.nvim_buf_set_option(data.buf, "commentstring", "// %s") - end -}) - --- Indent with spaces for vue files -vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("set-vue-expandtab", { clear = true }), - pattern = "vue", - callback = function(data) - vim.api.nvim_buf_set_option(data.buf, "expandtab", true) - vim.api.nvim_buf_set_option(data.buf, 'shiftwidth', 2) - vim.api.nvim_buf_set_option(data.buf, 'tabstop', 2) - vim.api.nvim_buf_set_option(data.buf, 'softtabstop', 2) - end -}) - --- Override `ft` for .h files to `c` -vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("override-c-header-ft", { clear = true }), - pattern = "cpp", - callback = function(data) - if data.file:match("%.h$") then - vim.api.nvim_buf_set_option(data.buf, "ft", "c") - end - end -}) diff --git a/lua/personal/add-guard.lua b/lua/personal/add-guard.lua deleted file mode 100644 index 642dd42..0000000 --- a/lua/personal/add-guard.lua +++ /dev/null @@ -1,32 +0,0 @@ - -vim.api.nvim_create_user_command("AddIncludeGuard", function(data) - local bufnr = vim.api.nvim_get_current_buf() - local name_pattern = data.fargs[1] or "%s_" - - local function formatName(filename) - local parts = vim.split(filename, "[/\\]", {trimempty=true}) - local last_part = parts[#parts] - local ext = last_part:match("%.([^%.]+)$") - local name = last_part:gsub("%.[^%.]+$", "") - - if ext == "h" or ext == "hpp" then - name = name.."_H" - end - - return name_pattern:format(name:upper()) - end - - local buf_filename = vim.api.nvim_buf_get_name(bufnr) - local guard_name = formatName(buf_filename) - - vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, { - "#ifndef "..guard_name, - "#define "..guard_name, - "" - }) - - vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { - "", - "#endif //"..guard_name - }) -end, { nargs="?" }) diff --git a/lua/personal/add-include-guard.lua b/lua/personal/add-include-guard.lua new file mode 100644 index 0000000..db82b41 --- /dev/null +++ b/lua/personal/add-include-guard.lua @@ -0,0 +1,39 @@ +local M = {} + +function M.load() + -- TODO: Make it work with buffer which don't have a filename yet + + vim.api.nvim_create_user_command("AddIncludeGuard", function(data) + local bufnr = vim.api.nvim_get_current_buf() + local name_pattern = data.fargs[1] or "%s_" + + local function formatName(filename) + local parts = vim.split(filename, "[/\\]", {trimempty=true}) + local last_part = parts[#parts] + local ext = last_part:match("%.([^%.]+)$") + local name = last_part:gsub("%.[^%.]+$", "") + + if ext == "h" or ext == "hpp" then + name = name.."_H" + end + + return name_pattern:format(name:upper()) + end + + local buf_filename = vim.api.nvim_buf_get_name(bufnr) + local guard_name = formatName(buf_filename) + + vim.api.nvim_buf_set_lines(bufnr, 0, 0, false, { + "#ifndef "..guard_name, + "#define "..guard_name, + "" + }) + + vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { + "", + "#endif //"..guard_name + }) + end, { nargs="?" }) +end + +return M diff --git a/lua/personal/cmacro-align.lua b/lua/personal/cmacro-align.lua index be2ea43..a464e5a 100644 --- a/lua/personal/cmacro-align.lua +++ b/lua/personal/cmacro-align.lua @@ -1,8 +1,6 @@ +local M = {} + local ts = vim.treesitter -local query = ts.query.parse("c", [[ -(preproc_function_def value: (preproc_arg) @macro_def) -(preproc_def value: (preproc_arg) @macro_def) -]]) local function get_ast_root(bufnr) local tree = ts.get_parser(bufnr, "c"):parse() @@ -10,12 +8,29 @@ local function get_ast_root(bufnr) end -local capture_lookup = {} -for id, name in ipairs(query.captures) do - capture_lookup[name] = id +local function do_lines_match(lines1, lines2) + if #lines1 ~= lines2 then + return false + end + for i, line1 in ipairs(lines1) do + if line1 ~= lines2[i] then + return false + end + end + return true end local function format_macros() + local query = ts.query.parse("c", [[ + (preproc_function_def value: (preproc_arg) @macro_def) + (preproc_def value: (preproc_arg) @macro_def) + ]]) + + local capture_lookup = {} + for id, name in ipairs(query.captures) do + capture_lookup[name] = id + end + local bufnr = vim.api.nvim_get_current_buf() local winnr = vim.api.nvim_get_current_win() @@ -28,12 +43,14 @@ local function format_macros() local lines = vim.api.nvim_buf_get_lines(bufnr, start_line, end_line+1, false) local tabstop = tonumber(vim.bo[bufnr].tabstop) or 8 + local new_lines = {} for i, line in ipairs(lines) do lines[i] = line:match("^(.-)%s*[\\]?$") + new_lines[i] = lines[i] end while true do - local last_line = lines[#lines] + local last_line = new_lines[#lines] if not last_line then break end if last_line:match("^%s*//") or last_line:match("^%s*/%*") or last_line:match("^%s*$") then table.remove(lines, #lines) @@ -43,7 +60,7 @@ local function format_macros() end end - if #lines > 2 then + if #new_lines > 2 then local line_length = 0 do local textwidth = vim.bo[bufnr].textwidth @@ -59,30 +76,36 @@ local function format_macros() end if line_length <= 0 then - for _, line in ipairs(lines) do + for _, line in ipairs(new_lines) do line_length = math.max(line_length, #line+2) end end end - for i = 1, #lines-1 do - local line = lines[i] + for i = 1, #new_lines-1 do + local line = new_lines[i] local length = #(line:gsub("\t", (" "):rep(tabstop))) lines[i] = line .. (" "):rep(line_length - length-2) .. " \\" end - vim.api.nvim_buf_set_lines(bufnr, start_line, end_line+1, false, lines) + if not do_lines_match(lines, new_lines) then + vim.api.nvim_buf_set_lines(bufnr, start_line, end_line+1, false, lines) + end end end end -local group = vim.api.nvim_create_augroup("UpdateCMacro", { clear = true }) -for _, cmd in ipairs{"InsertLeavePre", "BufWritePre"} do - vim.api.nvim_create_autocmd(cmd, { - group = group, - pattern = {"*.c", "*.h", "*.cpp", "*.hpp", "*.cc"}, - callback = function (data) - format_macros() - end - }) +function M.load() + local group = vim.api.nvim_create_augroup("UpdateCMacro", { clear = true }) + for _, cmd in ipairs{"InsertLeavePre", "BufWritePre"} do + vim.api.nvim_create_autocmd(cmd, { + group = group, + pattern = {"*.c", "*.h", "*.cpp", "*.hpp", "*.cc"}, + callback = function (data) + format_macros() + end + }) + end end + +return M diff --git a/lua/personal/disable-builtin.lua b/lua/personal/disable-builtin.lua new file mode 100644 index 0000000..4c17f65 --- /dev/null +++ b/lua/personal/disable-builtin.lua @@ -0,0 +1,17 @@ +local M = {} + +function M.load() + local disabled_built_ins = { + 'matchit', + 'netrw', + 'netrwPlugin', + 'netrwSettings', + 'netrwFileHandlers', + } + + for _, name in ipairs(disabled_built_ins) do + vim.g['loaded_' .. name] = 1 + end +end + +return M diff --git a/lua/personal/pludin-dev.lua b/lua/personal/pludin-dev.lua deleted file mode 100644 index 0d6b64b..0000000 --- a/lua/personal/pludin-dev.lua +++ /dev/null @@ -1,6 +0,0 @@ - -vim.keymap.set("n", "x", ":w:source %", { silent = true }) - -function P(...) - print(vim.inspect(...)) -end diff --git a/lua/personal/plugin-dev.lua b/lua/personal/plugin-dev.lua new file mode 100644 index 0000000..1cb3b37 --- /dev/null +++ b/lua/personal/plugin-dev.lua @@ -0,0 +1,11 @@ +local M = {} + +function M.load() + vim.keymap.set("n", "x", ":w:source %", { silent = true }) + + function _G.P(...) + print(vim.inspect(...)) + end +end + +return M diff --git a/lua/personal/uci.lua b/lua/personal/uci.lua index bb288e7..bb17e8a 100644 --- a/lua/personal/uci.lua +++ b/lua/personal/uci.lua @@ -1,31 +1,39 @@ +local M = {} --- Setup tree sitter -local parser_config = require("nvim-treesitter.parsers").get_parser_configs() -parser_config.uci = { - install_info = { - url = "git@rpuzonas.com:rpuzonas/tree-sitter-uci.git", - files = {"src/parser.c"}, - branch = "main", - generate_requires_npm = false, - requires_generate_from_grammar = false, - }, - filetype = "uci", -} +function M.load() + -- Setup tree sitter + local parser_config = require("nvim-treesitter.parsers").get_parser_configs() + parser_config.uci = { + install_info = { + url = "git@rpuzonas.com:rpuzonas/tree-sitter-uci.git", + files = {"src/parser.c"}, + branch = "main", + generate_requires_npm = false, + requires_generate_from_grammar = false, + }, + filetype = "uci", + } --- Determine UCI filetype by contents of file. --- If file has no extension and at least one line contains the word "config" -vim.filetype.add({ - pattern = { - [".*/etc/config/.*"] = "uci", - [".*/[^%.]+"] = { - priority = -math.huge, - function(_, bufnr) - for _, line in ipairs(vim.filetype.getlines(bufnr)) do - if line:find("config") ~= nil then - return "uci" - end - end - end - } - } -}) + -- Determine UCI filetype by contents of file. + -- If file has no extension and at least one line contains the word "config" + -- TODO: + --[[ + vim.filetype.add({ + pattern = { + [".*/etc/config/.*"] = "uci", + [".*/[^%.]+"] = { + priority = -math.huge, + function(_, bufnr) + for _, line in ipairs(vim.filetype.getlines(bufnr)) do + if line:find("config") ~= nil then + return "uci" + end + end + end + } + } + }) + ]]-- +end + +return M diff --git a/lua/plugins-local.lua b/lua/plugins-local.lua deleted file mode 100644 index 1b6f21c..0000000 --- a/lua/plugins-local.lua +++ /dev/null @@ -1,2 +0,0 @@ -return function(use) -end diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index 26ec29c..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,138 +0,0 @@ --- TODO: Add minimal plugin mode. Disables all plugins which are not super --- important, to get better performance. - -return function(use) - local function use_config(name) - use(require(("config.%s"):format(name))) - end - - use_config "toggleterm" - use_config "baleia" - use_config "todo-comments" - use_config "dressing" - use_config "legendary" - use_config "move" - use_config "gitblame" - use_config "based" - use_config "lspsignature" - use_config "lsputils" - use_config "luasnip" - use_config "trouble" - use_config "lazygit" - use_config "gitsigns" - use_config "nvim-tree" - use_config "autosource" - use_config "tidy" - use_config "quickscope" - use_config "leap" - use_config "comment" - use_config "colorizer" - use_config "devicons" - use_config "treesitter" - use_config "ts-playground" - use_config "diffview" - use_config "git-conflict" - use_config "doxygen-tk" - use_config "navbuddy" - use_config "escape" - -- use_config "ufo" - - use { - "nvim-telescope/telescope.nvim", - requires = { - "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", - "kyazdani42/nvim-web-devicons", - "nvim-telescope/telescope-ui-select.nvim", - {"nvim-telescope/telescope-fzf-native.nvim", run = "make", disable = vim.fn.has("win32")} - }, - load_config = true - } - - use { - "williamboman/mason.nvim", - requires = 'neovim/nvim-lspconfig', - config_name = "mason" - } - use { - "williamboman/mason-lspconfig.nvim", - requires = "williamboman/mason.nvim", - config_name = "mason-lspconfig" - } - use { - "neovim/nvim-lspconfig", - requires = "williamboman/mason-lspconfig.nvim", - --config_name = "lspconfig" - } - - use { - "nvim-lualine/lualine.nvim", - requires = "kyazdani42/nvim-web-devicons", - load_config = true - } - - use { - 'rafcamlet/nvim-luapad', - config_name = "luapad" - } - - use "krady21/compiler-explorer.nvim" - use "kevinhwang91/nvim-bqf" - use "tpope/vim-eunuch" - use "christoomey/vim-tmux-navigator" - use "eandrju/cellular-automaton.nvim" - use "tweekmonster/startuptime.vim" - use "tpope/vim-unimpaired" - use "wellle/targets.vim" - use "michaeljsmith/vim-indent-object" - use "psliwka/vim-smoothie" - use "godlygeek/tabular" - use "editorconfig/editorconfig-vim" - use "tpope/vim-surround" - use "tpope/vim-repeat" - use "tikhomirov/vim-glsl" - - -- Debugger - use { "mfussenegger/nvim-dap", config_name="dap" } - use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] } - use 'simrat39/rust-tools.nvim' - use { - 'theHamsta/nvim-dap-virtual-text', - requires = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"}, - config=[[require('nvim-dap-virtual-text')]] - } - - -- Completion - use { 'onsails/lspkind-nvim' } - use { - 'hrsh7th/nvim-cmp', - -- requires = 'onsails/lspkind-nvim', -- For some reason breaks with this line - requires = {'saadparwaiz1/cmp_luasnip'}, - after = 'lspkind-nvim', - config_name = "cmp" - } - use {'tzachar/cmp-tabnine', after = 'nvim-cmp', run='./install.sh', requires = 'hrsh7th/nvim-cmp', config_name = "tabnine"} - use {'hrsh7th/cmp-nvim-lsp', requires = {'hrsh7th/nvim-cmp', 'nvim-lspconfig'}} - use {'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'} - use {'hrsh7th/cmp-buffer', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'} - use {'hrsh7th/cmp-path', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'} - use {'hrsh7th/cmp-cmdline', after = 'nvim-cmp', requires = 'hrsh7th/nvim-cmp'} - use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp', requires = {'L3MON4D3/LuaSnip', 'nvim-cmp'}} - - do -- Color themes - use 'srcery-colors/srcery-vim' - -- use 'morhetz/gruvbox' - -- use 'tomasr/molokai' - -- use 'Mangeshrex/uwu.vim' - -- use 'ayu-theme/ayu-vim' - -- use 'sickill/vim-monokai' - -- use 'joshdick/onedark.vim' - -- use 'mswift42/vim-themes' - -- use 'squarefrog/tomorrow-night.vim' - -- use 'fnune/base16-vim' - end - - -- Training plugins - -- use 'tjdevries/train.nvim' - -- use 'ThePrimeagen/vim-be-good' -end diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..1732974 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,168 @@ + +local empty = require('lualine.component'):extend() +function empty:draw(default_highlight) + self.status = '' + self.applied_separator = '' + self:apply_highlights(default_highlight) + self:apply_section_separators() + return self.status +end + +-- Put proper separators and gaps between components in sections +local function process_sections(sections) + local bg = vim.g.srcery_xgray1 + + for name, section in pairs(sections) do + local left = name:sub(9, 10) < 'x' + for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do + table.insert(section, pos * 2, { empty, color = { fg = bg, bg = bg } }) + end + for id, comp in ipairs(section) do + if type(comp) ~= 'table' then + comp = { comp } + section[id] = comp + end + comp.separator = left and { right = '' } or { left = '' } + end + end + return sections +end + +local function search_result() + local last_search = vim.fn.getreg('/') + if not last_search or last_search == '' then + return '' + end + local searchcount = vim.fn.searchcount { maxcount = 9999 } + if searchcount.total == 0 then + return '' + end + return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' +end + +local function recording_macro() + local reg = vim.api.nvim_call_function("reg_recording", {}) + if reg ~= "" then + return "@" .. reg + else + return "" + end +end + +local function modified() + if vim.bo.modified then + return '+' + elseif vim.bo.modifiable == false or vim.bo.readonly == true then + return '-' + end + return '' +end + + +return { + "nvim-lualine/lualine.nvim", + dependencies = {"nvim-tree/nvim-web-devicons"}, + config = function() + local bg = vim.g.srcery_xgray1 + + local colors = { + red = vim.g.srcery_red, + grey = vim.g.srcery_black, + black = vim.g.srcery_hard_black, + white = vim.g.srcery_bright_white, + light_green = vim.g.srcery_bright_green, + orange = vim.g.srcery_orange, + green = vim.g.srcery_green, + } + + local theme = { + normal = { + a = { fg = colors.white, bg = colors.black }, + b = { fg = colors.white, bg = colors.grey }, + c = { fg = colors.black, bg = bg }, + z = { fg = colors.white, bg = colors.black }, + }, + insert = { a = { fg = colors.black, bg = colors.light_green } }, + visual = { a = { fg = colors.black, bg = colors.orange } }, + replace = { a = { fg = colors.black, bg = colors.green } }, + } + + local extensions = {"man", "quickfix"} + if pcall(require, "neo-tree") then + table.insert(extensions, "neo-tree") + end + if pcall(require, "luapad.statusline") then + table.insert(extensions, { + sections = process_sections { + lualine_a = {"mode"}, + lualine_b = { + { + "diagnostics", + source = { "nvim" }, + sections = { "error" }, + diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, + }, + { + "diagnostics", + source = { "nvim" }, + sections = { "warn" }, + diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, + }, + { recording_macro, color = { bg = colors.orange } } + }, + lualine_y = { search_result, "filetype" }, + lualine_z = { "%l:%c", "%p%%/%L" }, + }, + filetypes = {"lua.luapad"} + }) + end + + require("lualine").setup { + options = { + icons_enabled = true, + theme = theme, + component_separators = "", + section_separators = { left = "", right = "" }, + globalstatus = true + }, + sections = process_sections { + lualine_a = { "mode" }, + lualine_b = { + "branch", + "diff", + { + "diagnostics", + source = { "nvim" }, + sections = { "error" }, + diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, + }, + { + "diagnostics", + source = { "nvim" }, + sections = { "warn" }, + diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, + }, + { "filename", file_status = false, path = 1 }, + { modified, color = { bg = colors.red } }, + { "%w", cond = function() return vim.wo.previewwindow end }, + { "%r", cond = function() return vim.bo.readonly end }, + { "%q", cond = function() return vim.bo.buftype == "quickfix" end }, + { recording_macro, color = { bg = colors.orange } } + }, + lualine_c = {}, + lualine_x = {}, + lualine_y = { search_result, "filetype" }, + lualine_z = { "%l:%c", "%p%%/%L" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {}, + }, + extensions = extensions + } + end +} diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua new file mode 100644 index 0000000..1c9faf3 --- /dev/null +++ b/lua/plugins/luasnip.lua @@ -0,0 +1,89 @@ +local function capture(cmd, raw) + local f = assert(io.popen(cmd, 'r')) + local s = assert(f:read('*a')) + f:close() + if raw then return s end + s = string.gsub(s, '^%s+', '') + s = string.gsub(s, '%s+$', '') + s = string.gsub(s, '[\n\r]+', ' ') + return s +end + +return { + "L3MON4D3/LuaSnip", + config = function() + local ls = require("luasnip") + local s = ls.snippet + local sn = ls.snippet_node + local fmt = require("luasnip.extras.fmt").fmt + local t = ls.text_node + local i = ls.insert_node + local f = ls.function_node + local c = ls.choice_node + local d = ls.dynamic_node + + local function getCurrentYear() + return os.date("%Y") + end + + local function getGitUsername() + local stdout = capture("git config user.name") + if stdout == "" then return nil end + return stdout + end + + ls.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI", + enable_autosnippets = true + } + + vim.keymap.set({"i", "s"}, "", function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end + end, { silent = true }) + + vim.keymap.set({ "i", "s" }, "", function() + if ls.jumpable(-1) then ls.jump(-1) end + end, { silent = -1 }) + + vim.keymap.set({"i"}, "", function() + if ls.choice_active() then ls.change_choice(1) end + end) + + ls.add_snippets("all", { + s("MIT", { + t({"The MIT License (MIT)", "Copyright © "}), + f(getCurrentYear, {}), + t(" "), + d(1, function() + return sn(nil, { + i(1, getGitUsername() or "") + }) + end, {}), + t{ + "", + "", + "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.", + } + }) + }) + end +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..62a9444 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,148 @@ +local telescope = require('telescope') +local actions = require('telescope.actions') +local builtin = require('telescope.builtin') + +-- [[ Configure Telescope ]] +-- See `:help telescope` and `:help telescope.setup()` +-- require('telescope').setup { +-- defaults = { +-- mappings = { +-- i = { +-- [''] = false, +-- [''] = false, +-- }, +-- }, +-- }, +-- } + +-- Enable telescope fzf native, if installed +-- pcall(require('telescope').load_extension, 'fzf') + +-- 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() +-- -- You can pass additional configuration to telescope to change theme, layout, etc. +-- require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { +-- winblend = 10, +-- previewer = false, +-- }) +-- end, { desc = '[/] Fuzzily search in current buffer' }) + +-- vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) +-- 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', require('telescope.builtin').grep_string, { 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' }) + +-- Falling back to find_files if git_files can't find a .git directory +local function project_files(opts) + opts = opts or {} + if not opts.prompt_title then + opts.prompt_title = "Project files" + end + local ok = pcall(builtin.git_files, opts) + if not ok then builtin.find_files(opts) end +end + +local function get_vtext() + local prev_regv = vim.fn.getreg('v') + vim.cmd('noau normal! "vy"') + local text = vim.fn.getreg('v') + vim.fn.setreg("v", prev_regv) + + text = string.gsub(text, "\n", "") + if #text > 0 then + return text + else + return "" + end +end + +local function escape_sed_symbols(text) + return text:gsub("[.()%[%]]", "\\%1") +end + +return { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "nvim-tree/nvim-web-devicons", + "nvim-telescope/telescope-ui-select.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + cond = function() return vim.fn.executable('make') == 1 end, + } + }, + config = function() + telescope.setup{ + defaults = { + vimgrep_arguments = { + "rg", + "-L", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "ascending", + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { mirror = false }, + width = 0.87, + height = 0.80, + preview_cutoff = 120, + }, + file_sorter = require("telescope.sorters").get_fuzzy_file, + file_ignore_patterns = { "node_modules" }, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + path_display = { "truncate" }, + color_devicons = true, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + mappings = { + i = { [""] = actions.close } + }, + }, + pickers = { + live_grep = { disable_coordinates = true }, + colorscheme = { enable_preview = true } + }, + extensions = { + ["ui-select"] = { require("telescope.themes").get_dropdown {} } + } + } + + telescope.load_extension("ui-select") + pcall(telescope.load_extension, 'fzf') -- Enable telescope fzf native, if installed + + local keymap = vim.keymap.set + keymap("n", "", project_files, { desc = "Find [P]roject files" }) + keymap("n", "p", function() builtin.find_files() end, { desc = "[P] Find files" }) + keymap("n", "fw", function() builtin.live_grep() end, { desc = "[F]ind [W]ords" }) + keymap("v", "fw", function() builtin.live_grep{ default_text = escape_sed_symbols(get_vtext()) } end, { desc = "[F]ind [W]ords" }) + keymap("n", "fh", function() builtin.help_tags() end, { desc = "Find help tags" }) + end +} diff --git a/lua/utils/autocmd.lua b/lua/utils/autocmd.lua deleted file mode 100644 index a32be94..0000000 --- a/lua/utils/autocmd.lua +++ /dev/null @@ -1,11 +0,0 @@ -local cmd = vim.cmd - -return function(group, cmds, clear) - clear = clear == nil and false or clear - if type(cmds) == 'string' then cmds = {cmds} end - cmd('augroup ' .. group) - if clear then cmd [[au!]] end - for _, c in ipairs(cmds) do cmd('autocmd ' .. c) end - cmd [[augroup END]] -end - diff --git a/lua/utils/capture.lua b/lua/utils/capture.lua deleted file mode 100644 index 35f3dfb..0000000 --- a/lua/utils/capture.lua +++ /dev/null @@ -1,10 +0,0 @@ -return function (cmd, raw) - local f = assert(io.popen(cmd, 'r')) - local s = assert(f:read('*a')) - f:close() - if raw then return s end - s = string.gsub(s, '^%s+', '') - s = string.gsub(s, '%s+$', '') - s = string.gsub(s, '[\n\r]+', ' ') - return s -end diff --git a/lua/utils/init.lua b/lua/utils/init.lua deleted file mode 100644 index 37589ac..0000000 --- a/lua/utils/init.lua +++ /dev/null @@ -1,6 +0,0 @@ -local path = ... -return { - map = require(... .. ".map"), - opt = require(... .. ".opt"), - autocmd = require(... .. ".autocmd"), -} diff --git a/lua/utils/map.lua b/lua/utils/map.lua deleted file mode 100644 index 479c92d..0000000 --- a/lua/utils/map.lua +++ /dev/null @@ -1,8 +0,0 @@ -local map_key = vim.api.nvim_set_keymap - -return function(modes, lhs, rhs, opts) - opts = opts or {} - opts.noremap = opts.noremap == nil and true or opts.noremap - if type(modes) == 'string' then modes = {modes} end - for _, mode in ipairs(modes) do map_key(mode, lhs, rhs, opts) end -end diff --git a/lua/utils/opt.lua b/lua/utils/opt.lua deleted file mode 100644 index 9ae1aba..0000000 --- a/lua/utils/opt.lua +++ /dev/null @@ -1,6 +0,0 @@ -local o_s = vim.o - -return function(o, v, scopes) - scopes = scopes or {o_s} - for _, s in ipairs(scopes) do s[o] = v end -end