diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-03-04 18:18:22 -0600 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-03-04 18:18:22 -0600 |
commit | 0d3b11c231b5d8536fdc8fbddf167956ec999cc6 (patch) | |
tree | 62ddbcfe49228773a5b7425db81a12947dc09450 | |
parent | 6a36592700b75e3658584db672f09ee33b2ba840 (diff) |
feat: more tmux/neovim/alacritty
68 files changed, 4251 insertions, 1133 deletions
diff --git a/NvChad/init.lua b/NvChad/init.lua new file mode 100644 index 0000000..22177d0 --- /dev/null +++ b/NvChad/init.lua @@ -0,0 +1,31 @@ +local present, impatient = pcall(require, "impatient") + +if present then + impatient.enable_profile() +end + +local core_modules = { + "core.options", + "core.autocmds", + "core.mappings", +} + +for _, module in ipairs(core_modules) do + local ok, err = pcall(require, module) + if not ok then + error("Error loading " .. module .. "\n\n" .. err) + end +end + +-- non plugin mappings +require("core.mappings").misc() + +-- check if custom init.lua file exists +if vim.fn.filereadable(vim.fn.stdpath "config" .. "/lua/custom/init.lua") == 1 then + -- try to call custom init, if not successful, show error + local ok, err = pcall(require, "custom") + if not ok then + vim.notify("Error loading custom/init.lua\n\n" .. err) + end + return +end diff --git a/NvChad/lua/colors/highlights.lua b/NvChad/lua/colors/highlights.lua new file mode 100644 index 0000000..1c3dae8 --- /dev/null +++ b/NvChad/lua/colors/highlights.lua @@ -0,0 +1,173 @@ +local cmd = vim.cmd + +local override = require("core.utils").load_config().ui.hl_override +local colors = require("colors").get() +local ui = require("core.utils").load_config().ui + +local black = colors.black +local black2 = colors.black2 +local blue = colors.blue +local darker_black = colors.darker_black +local folder_bg = colors.folder_bg +local green = colors.green +local grey = colors.grey +local grey_fg = colors.grey_fg +local light_grey = colors.light_grey +local line = colors.line +local nord_blue = colors.nord_blue +local one_bg = colors.one_bg +local one_bg2 = colors.one_bg2 +local pmenu_bg = colors.pmenu_bg +local purple = colors.purple +local red = colors.red +local white = colors.white +local yellow = colors.yellow +local orange = colors.orange +local one_bg3 = colors.one_bg3 + +-- functions for setting highlights +local fg = require("core.utils").fg +local fg_bg = require("core.utils").fg_bg +local bg = require("core.utils").bg + +-- Comments +if ui.italic_comments then + fg("Comment", grey_fg .. " gui=italic") +else + fg("Comment", grey_fg) +end + +-- Disable cursor line +cmd "hi clear CursorLine" +-- Line number +fg("cursorlinenr", white) + +-- same it bg, so it doesn't appear +fg("EndOfBuffer", black) + +-- For floating windows +fg("FloatBorder", blue) +bg("NormalFloat", darker_black) + +-- Pmenu +bg("Pmenu", one_bg) +bg("PmenuSbar", one_bg2) +bg("PmenuSel", pmenu_bg) +bg("PmenuThumb", nord_blue) +fg("CmpItemAbbr", white) +fg("CmpItemAbbrMatch", white) +fg("CmpItemKind", white) +fg("CmpItemMenu", white) + +-- misc + +-- inactive statuslines as thin lines +fg("StatusLineNC", one_bg3 .. " gui=underline") + +fg("LineNr", grey) +fg("NvimInternalError", red) +fg("VertSplit", one_bg2) + +if ui.transparency then + bg("Normal", "NONE") + bg("Folded", "NONE") + fg("Folded", "NONE") + fg("Comment", grey) +end + +-- [[ Plugin Highlights + +-- Dashboard +fg("AlphaHeader", grey_fg) +fg("AlphaButtons", light_grey) + +-- Git signs +fg_bg("DiffAdd", blue, "NONE") +fg_bg("DiffChange", grey_fg, "NONE") +fg_bg("DiffChangeDelete", red, "NONE") +fg_bg("DiffModified", red, "NONE") +fg_bg("DiffDelete", red, "NONE") + +-- Indent blankline plugin +fg("IndentBlanklineChar", line) +fg("IndentBlanklineSpaceChar", line) + +-- Lsp diagnostics + +fg("DiagnosticHint", purple) +fg("DiagnosticError", red) +fg("DiagnosticWarn", yellow) +fg("DiagnosticInformation", green) + +-- NvimTree +fg("NvimTreeEmptyFolderName", folder_bg) +fg("NvimTreeEndOfBuffer", darker_black) +fg("NvimTreeFolderIcon", folder_bg) +fg("NvimTreeFolderName", folder_bg) +fg("NvimTreeGitDirty", red) +fg("NvimTreeIndentMarker", one_bg2) +bg("NvimTreeNormal", darker_black) +bg("NvimTreeNormalNC", darker_black) +fg("NvimTreeOpenedFolderName", folder_bg) +fg("NvimTreeRootFolder", red .. " gui=underline") -- enable underline for root folder in nvim tree +fg_bg("NvimTreeStatuslineNc", darker_black, darker_black) +fg_bg("NvimTreeVertSplit", darker_black, darker_black) +fg_bg("NvimTreeWindowPicker", red, black2) + +-- Telescope +fg_bg("TelescopeBorder", darker_black, darker_black) +fg_bg("TelescopePromptBorder", black2, black2) + +fg_bg("TelescopePromptNormal", white, black2) +fg_bg("TelescopePromptPrefix", red, black2) + +bg("TelescopeNormal", darker_black) + +fg_bg("TelescopePreviewTitle", black, green) +fg_bg("TelescopePromptTitle", black, red) +fg_bg("TelescopeResultsTitle", darker_black, darker_black) + +bg("TelescopeSelection", black2) + +-- keybinds cheatsheet + +fg_bg("CheatsheetBorder", black, black) +bg("CheatsheetSectionContent", black) +fg("CheatsheetHeading", white) + +local section_title_colors = { + white, + blue, + red, + green, + yellow, + purple, + orange, +} +for i, color in ipairs(section_title_colors) do + vim.cmd("highlight CheatsheetTitle" .. i .. " guibg = " .. color .. " guifg=" .. black) +end + +-- Disable some highlight in nvim tree if transparency enabled +if ui.transparency then + bg("NormalFloat", "NONE") + bg("NvimTreeNormal", "NONE") + bg("NvimTreeNormalNC", "NONE") + bg("NvimTreeStatusLineNC", "NONE") + fg_bg("NvimTreeVertSplit", grey, "NONE") + + -- telescope + bg("TelescopeBorder", "NONE") + bg("TelescopePrompt", "NONE") + bg("TelescopeResults", "NONE") + bg("TelescopePromptBorder", "NONE") + bg("TelescopePromptNormal", "NONE") + bg("TelescopeNormal", "NONE") + bg("TelescopePromptPrefix", "NONE") + fg("TelescopeBorder", one_bg) + fg_bg("TelescopeResultsTitle", black, blue) +end + +if #override ~= 0 then + require(override) +end diff --git a/NvChad/lua/colors/init.lua b/NvChad/lua/colors/init.lua new file mode 100644 index 0000000..8927251 --- /dev/null +++ b/NvChad/lua/colors/init.lua @@ -0,0 +1,34 @@ +local M = {} + +-- if theme given, load given theme if given, otherwise nvchad_theme +M.init = function(theme) + if not theme then + theme = require("core.utils").load_config().ui.theme + end + + -- set the global theme, used at various places like theme switcher, highlights + vim.g.nvchad_theme = theme + + local present, base16 = pcall(require, "base16") + + if present then + -- first load the base16 theme + base16(base16.themes(theme), true) + + -- unload to force reload + package.loaded["colors.highlights" or false] = nil + -- then load the highlights + require "colors.highlights" + end +end + +-- returns a table of colors for given or current theme +M.get = function(theme) + if not theme then + theme = vim.g.nvchad_theme + end + + return require("hl_themes." .. theme) +end + +return M diff --git a/NvChad/lua/core/autocmds.lua b/NvChad/lua/core/autocmds.lua new file mode 100644 index 0000000..362f0d3 --- /dev/null +++ b/NvChad/lua/core/autocmds.lua @@ -0,0 +1,20 @@ +local settings=require("core.utils").load_config().options.nvChad +-- uncomment this if you want to open nvim with a dir +-- vim.cmd [[ autocmd BufEnter * if &buftype != "terminal" | lcd %:p:h | endif ]] + +-- Use relative & absolute line numbers in 'n' & 'i' modes respectively +-- vim.cmd[[ au InsertEnter * set norelativenumber ]] +-- vim.cmd[[ au InsertLeave * set relativenumber ]] + +-- Don't show any numbers inside terminals +if not settings.terminal_numbers then + vim.cmd [[ au TermOpen term://* setlocal nonumber norelativenumber | setfiletype terminal ]] +end + +-- Don't show status line on certain windows +vim.cmd [[ autocmd BufEnter,BufRead,BufWinEnter,FileType,WinEnter * lua require("core.utils").hide_statusline() ]] + +-- Open a file from its last left off position +-- vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] +-- File extension specific tabbing +-- vim.cmd [[ autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 ]] diff --git a/NvChad/lua/core/default_config.lua b/NvChad/lua/core/default_config.lua new file mode 100644 index 0000000..eb17228 --- /dev/null +++ b/NvChad/lua/core/default_config.lua @@ -0,0 +1,227 @@ +-- IMPORTANT NOTE : This is default config, so dont change anything here. +-- use custom/chadrc.lua instead + +local M = {} + +M.options = { + -- custom = {} + -- general nvim/vim options , check :h optionname to know more about an option + + clipboard = "unnamedplus", + cmdheight = 1, + ruler = false, + hidden = true, + ignorecase = true, + smartcase = true, + mapleader = " ", + mouse = "a", + number = true, + numberwidth = 2, + relativenumber = false, + expandtab = true, + shiftwidth = 2, + smartindent = true, + tabstop = 8, + timeoutlen = 400, + updatetime = 250, + undofile = true, + fillchars = { eob = " " }, + shadafile = vim.opt.shadafile, + + -- NvChad options + nvChad = { + copy_cut = true, -- copy cut text ( x key ), visual and normal mode + copy_del = true, -- copy deleted text ( dd key ), visual and normal mode + insert_nav = true, -- navigation in insertmode + window_nav = true, + terminal_numbers = false, + + -- updater + update_url = "https://github.com/NvChad/NvChad", + update_branch = "main", + }, +} + +---- UI ----- + +M.ui = { + hl_override = "", -- path of your file that contains highlights + italic_comments = false, + theme = "onedark", -- default theme + + -- Change terminal bg to nvim theme's bg color so it'll match well + -- For Ex : if you have onedark set in nvchad, set onedark's bg color on your terminal + transparency = false, +} + +---- PLUGIN OPTIONS ---- + +M.plugins = { + -- enable/disable plugins (false for disable) + status = { + blankline = true, -- indentline stuff + bufferline = true, -- manage and preview opened buffers + colorizer = false, -- color RGB, HEX, CSS, NAME color codes + comment = true, -- easily (un)comment code, language aware + alpha = false, -- dashboard + better_escape = true, -- map to <ESC> with no lag + feline = true, -- statusline + gitsigns = true, + lspsignature = true, -- lsp enhancements + vim_matchup = true, -- improved matchit + cmp = true, + nvimtree = true, + autopairs = true, + }, + options = { + packer = { + init_file = "plugins.packerInit", + }, + autopairs = { loadAfter = "nvim-cmp" }, + cmp = { + lazy_load = true, + }, + lspconfig = { + setup_lspconf = "", -- path of file containing setups of different lsps + }, + nvimtree = { + -- packerCompile required after changing lazy_load + lazy_load = true, + }, + luasnip = { + snippet_path = {}, + }, + statusline = { + -- hide, show on specific filetypes + hidden = { + "help", + "NvimTree", + "terminal", + "alpha", + }, + shown = {}, + + -- truncate statusline on small screens + shortline = true, + style = "default", -- default, round , slant , block , arrow + }, + esc_insertmode_timeout = 300, + }, + default_plugin_config_replace = {}, + default_plugin_remove = {}, + install = nil, +} + +-- Don't use a single keymap twice + +--- MAPPINGS ---- + +-- non plugin +M.mappings = { + -- custom = {}, -- custom user mappings + + misc = { + cheatsheet = "<leader>ch", + close_buffer = "<leader>x", + cp_whole_file = "<C-a>", -- copy all contents of current buffer + lineNR_toggle = "<leader>n", -- toggle line number + lineNR_rel_toggle = "<leader>rn", + update_nvchad = "<leader>uu", + new_buffer = "<S-t>", + new_tab = "<C-t>b", + save_file = "<C-s>", -- save file using :w + }, + + -- navigation in insert mode, only if enabled in options + + insert_nav = { + backward = "<C-h>", + end_of_line = "<C-e>", + forward = "<C-l>", + next_line = "<C-k>", + prev_line = "<C-j>", + beginning_of_line = "<C-a>", + }, + + -- better window movement + window_nav = { + moveLeft = "<C-h>", + moveRight = "<C-l>", + moveUp = "<C-k>", + moveDown = "<C-j>", + }, + + -- terminal related mappings + terminal = { + -- multiple mappings can be given for esc_termmode, esc_hide_termmode + + -- get out of terminal mode + esc_termmode = { "jk" }, + + -- get out of terminal mode and hide it + esc_hide_termmode = { "JK" }, + -- show & recover hidden terminal buffers in a telescope picker + pick_term = "<leader>W", + + -- spawn terminals + new_horizontal = "<leader>h", + new_vertical = "<leader>v", + new_window = "<leader>w", + }, +} + +-- plugins related mappings +-- To disable a mapping, equate the variable to "" or false or nil in chadrc +M.mappings.plugins = { + bufferline = { + next_buffer = "<TAB>", + prev_buffer = "<S-Tab>", + }, + comment = { + toggle = "<leader>/", + }, + + -- map to <ESC> with no lag + better_escape = { -- <ESC> will still work + esc_insertmode = { "jk" }, -- multiple mappings allowed + }, + + lspconfig = { + declaration = "gD", + definition = "gd", + hover = "K", + implementation = "gi", + signature_help = "gk", + add_workspace_folder = "<leader>wa", + remove_workspace_folder = "<leader>wr", + list_workspace_folders = "<leader>wl", + type_definition = "<leader>D", + rename = "<leader>ra", + code_action = "<leader>ca", + references = "gr", + float_diagnostics = "ge", + goto_prev = "[d", + goto_next = "]d", + set_loclist = "<leader>q", + formatting = "<leader>fm", + }, + + nvimtree = { + toggle = "<C-n>", + focus = "<leader>e", + }, + + telescope = { + buffers = "<leader>fb", + find_files = "<leader>ff", + find_hiddenfiles = "<leader>fa", + git_commits = "<leader>cm", + git_status = "<leader>gt", + help_tags = "<leader>fh", + live_grep = "<leader>fw", + oldfiles = "<leader>fo", + themes = "<leader>th", -- NvChad theme picker + }, +} + +return M diff --git a/NvChad/lua/core/mappings.lua b/NvChad/lua/core/mappings.lua new file mode 100644 index 0000000..8cce437 --- /dev/null +++ b/NvChad/lua/core/mappings.lua @@ -0,0 +1,183 @@ +local utils = require "core.utils" + +local config = utils.load_config() +local map_wrapper = utils.map + +local maps = config.mappings +local plugin_maps = maps.plugins +local nvChad_options = config.options.nvChad + +local cmd = vim.cmd + +-- This is a wrapper function made to disable a plugin mapping from chadrc +-- If keys are nil, false or empty string, then the mapping will be not applied +-- Useful when one wants to use that keymap for any other purpose +local map = function(...) + local keys = select(2, ...) + if not keys or keys == "" then + return + end + map_wrapper(...) +end + +local M = {} + +-- these mappings will only be called during initialization +M.misc = function() + local function non_config_mappings() + -- Don't copy the replaced text after pasting in visual mode + map_wrapper("v", "p", "p:let @+=@0<CR>") + + -- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down> + -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ + -- empty mode is same as using :map + -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour + map_wrapper("", "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true }) + map_wrapper("", "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true }) + map_wrapper("", "<Down>", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true }) + map_wrapper("", "<Up>", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true }) + + -- use ESC to turn off search highlighting + map_wrapper("n", "<Esc>", ":noh <CR>") + + -- center cursor when moving (goto_definition) + + -- yank from current cursor to end of line + map_wrapper("n", "Y", "yg$") + end + + local function optional_mappings() + -- don't yank text on cut ( x ) + if not nvChad_options.copy_cut then + map_wrapper({ "n", "v" }, "x", '"_x') + end + + -- don't yank text on delete ( dd ) + if not nvChad_options.copy_del then + map_wrapper({ "n", "v" }, "d", '"_d') + end + + -- navigation within insert mode + if nvChad_options.insert_nav then + local inav = maps.insert_nav + + map("i", inav.backward, "<Left>") + map("i", inav.end_of_line, "<End>") + map("i", inav.forward, "<Right>") + map("i", inav.next_line, "<Up>") + map("i", inav.prev_line, "<Down>") + map("i", inav.beginning_of_line, "<ESC>^i") + end + + -- easier navigation between windows + if nvChad_options.window_nav then + local wnav = maps.window_nav + + map("n", wnav.moveLeft, "<C-w>h") + map("n", wnav.moveRight, "<C-w>l") + map("n", wnav.moveUp, "<C-w>k") + map("n", wnav.moveDown, "<C-w>j") + end + end + + local function required_mappings() + map("n", maps.misc.cheatsheet, ":lua require('nvchad.cheatsheet').show() <CR>") -- show keybinds + map("n", maps.misc.close_buffer, ":lua require('core.utils').close_buffer() <CR>") -- close buffer + map("n", maps.misc.cp_whole_file, ":%y+ <CR>") -- copy whole file content + map("n", maps.misc.new_buffer, ":enew <CR>") -- new buffer + map("n", maps.misc.new_tab, ":tabnew <CR>") -- new tabs + map("n", maps.misc.lineNR_toggle, ":set nu! <CR>") + map("n", maps.misc.lineNR_rel_toggle, ":set rnu! <CR>") -- relative line numbers + map("n", maps.misc.save_file, ":w <CR>") -- ctrl + s to save file + + -- terminal mappings -- + local term_maps = maps.terminal + -- get out of terminal mode + map("t", term_maps.esc_termmode, "<C-\\><C-n>") + -- hide a term from within terminal mode + map("t", term_maps.esc_hide_termmode, "<C-\\><C-n> :lua require('core.utils').close_buffer() <CR>") + -- pick a hidden term + map("n", term_maps.pick_term, ":Telescope terms <CR>") + -- Open terminals + -- TODO this opens on top of an existing vert/hori term, fixme + map("n", term_maps.new_horizontal, ":execute 15 .. 'new +terminal' | let b:term_type = 'hori' | startinsert <CR>") + map("n", term_maps.new_vertical, ":execute 'vnew +terminal' | let b:term_type = 'vert' | startinsert <CR>") + map("n", term_maps.new_window, ":execute 'terminal' | let b:term_type = 'wind' | startinsert <CR>") + -- terminal mappings end -- + + -- Add Packer commands because we are not loading it at startup + cmd "silent! command PackerClean lua require 'plugins' require('packer').clean()" + cmd "silent! command PackerCompile lua require 'plugins' require('packer').compile()" + cmd "silent! command PackerInstall lua require 'plugins' require('packer').install()" + cmd "silent! command PackerStatus lua require 'plugins' require('packer').status()" + cmd "silent! command PackerSync lua require 'plugins' require('packer').sync()" + cmd "silent! command PackerUpdate lua require 'plugins' require('packer').update()" + + -- add NvChadUpdate command and mapping + cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()" + map("n", maps.misc.update_nvchad, ":NvChadUpdate <CR>") + end + + non_config_mappings() + optional_mappings() + required_mappings() +end + +-- below are all plugin related mappings + +M.bufferline = function() + local m = plugin_maps.bufferline + + map("n", m.next_buffer, ":BufferLineCycleNext <CR>") + map("n", m.prev_buffer, ":BufferLineCyclePrev <CR>") +end + +M.comment = function() + local m = plugin_maps.comment.toggle + map("n", m, ":lua require('Comment.api').toggle_current_linewise()<CR>") + map("v", m, ":lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>") +end + +M.lspconfig = function() + local m = plugin_maps.lspconfig + + -- See `:help vim.lsp.*` for documentation on any of the below functions + map("n", m.declaration, "<cmd>lua vim.lsp.buf.declaration()<CR>") + map("n", m.definition, "<cmd>lua vim.lsp.buf.definition()<CR>") + map("n", m.hover, "<cmd>lua vim.lsp.buf.hover()<CR>") + map("n", m.implementation, "<cmd>lua vim.lsp.buf.implementation()<CR>") + map("n", m.signature_help, "<cmd>lua vim.lsp.buf.signature_help()<CR>") + map("n", m.add_workspace_folder, "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>") + map("n", m.remove_workspace_folder, "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>") + map("n", m.list_workspace_folders, "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>") + map("n", m.type_definition, "<cmd>lua vim.lsp.buf.type_definition()<CR>") + map("n", m.rename, "<cmd>lua vim.lsp.buf.rename()<CR>") + map("n", m.code_action, "<cmd>lua vim.lsp.buf.code_action()<CR>") + map("n", m.references, "<cmd>lua vim.lsp.buf.references()<CR>") + map("n", m.float_diagnostics, "<cmd>lua vim.diagnostic.open_float()<CR>") + map("n", m.goto_prev, "<cmd>lua vim.diagnostic.goto_prev()<CR>") + map("n", m.goto_next, "<cmd>lua vim.diagnostic.goto_next()<CR>") + map("n", m.set_loclist, "<cmd>lua vim.diagnostic.setloclist()<CR>") + map("n", m.formatting, "<cmd>lua vim.lsp.buf.formatting()<CR>") +end + +M.nvimtree = function() + map("n", plugin_maps.nvimtree.toggle, ":NvimTreeToggle <CR>") + map("n", plugin_maps.nvimtree.focus, ":NvimTreeFocus <CR>") +end + +M.telescope = function() + local m = plugin_maps.telescope + + map("n", m.buffers, ":Telescope buffers <CR>") + map("n", m.find_files, ":Telescope find_files <CR>") + map("n", m.find_hiddenfiles, ":Telescope find_files follow=true no_ignore=true hidden=true <CR>") + map("n", m.git_commits, ":Telescope git_commits <CR>") + map("n", m.git_status, ":Telescope git_status <CR>") + map("n", m.help_tags, ":Telescope help_tags <CR>") + map("n", m.live_grep, ":Telescope live_grep <CR>") + map("n", m.oldfiles, ":Telescope oldfiles <CR>") + map("n", m.themes, ":Telescope themes <CR>") +end + +return M diff --git a/NvChad/lua/core/options.lua b/NvChad/lua/core/options.lua new file mode 100644 index 0000000..f8436a8 --- /dev/null +++ b/NvChad/lua/core/options.lua @@ -0,0 +1,81 @@ +local opt = vim.opt +local g = vim.g + +local options = require("core.utils").load_config().options + +opt.title = true +opt.clipboard = options.clipboard +opt.cmdheight = options.cmdheight +opt.cul = true -- cursor line + +-- Indentline +opt.expandtab = options.expandtab +opt.shiftwidth = options.shiftwidth +opt.smartindent = options.smartindent + +-- disable tilde on end of buffer: https://github.com/neovim/neovim/pull/8546#issuecomment-643643758 +opt.fillchars = options.fillchars + +opt.hidden = options.hidden +opt.ignorecase = options.ignorecase +opt.smartcase = options.smartcase +opt.mouse = options.mouse + +-- Numbers +opt.number = options.number +opt.numberwidth = options.numberwidth +opt.relativenumber = options.relativenumber +opt.ruler = options.ruler + +-- disable nvim intro +opt.shortmess:append "sI" + +opt.signcolumn = "yes" +opt.splitbelow = true +opt.splitright = true +opt.tabstop = options.tabstop +opt.termguicolors = true +opt.timeoutlen = options.timeoutlen +opt.undofile = options.undofile + +-- interval for writing swap file to disk, also used by gitsigns +opt.updatetime = options.updatetime + +-- go to previous/next line with h,l,left arrow and right arrow +-- when cursor reaches end/beginning of line +opt.whichwrap:append "<>[]hl" + +g.mapleader = options.mapleader + +-- disable some builtin vim plugins +local disabled_built_ins = { + "2html_plugin", + "getscript", + "getscriptPlugin", + "gzip", + "logipat", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "matchit", + "tar", + "tarPlugin", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimballPlugin", + "zip", + "zipPlugin", +} + +for _, plugin in pairs(disabled_built_ins) do + g["loaded_" .. plugin] = 1 +end + +--Defer loading shada until after startup_ +vim.opt.shadafile = "NONE" +vim.schedule(function() + vim.opt.shadafile = require("core.utils").load_config().options.shadafile + vim.cmd [[ silent! rsh ]] +end) diff --git a/NvChad/lua/core/utils.lua b/NvChad/lua/core/utils.lua new file mode 100644 index 0000000..9c16c53 --- /dev/null +++ b/NvChad/lua/core/utils.lua @@ -0,0 +1,317 @@ +local M = {} + +local cmd = vim.cmd +M.close_buffer = function(force) + -- This is a modification of a NeoVim plugin from + -- Author: ojroques - Olivier Roques + -- Src: https://github.com/ojroques/nvim-bufdel + -- (Author has okayed copy-paste) + + -- Options + local opts = { + next = "cycle", -- how to retrieve the next buffer + quit = false, -- exit when last buffer is deleted + --TODO make this a chadrc flag/option + } + + -- ---------------- + -- Helper functions + -- ---------------- + + -- Switch to buffer 'buf' on each window from list 'windows' + local function switch_buffer(windows, buf) + local cur_win = vim.fn.winnr() + for _, winid in ipairs(windows) do + winid = tonumber(winid) or 0 + vim.cmd(string.format("%d wincmd w", vim.fn.win_id2win(winid))) + vim.cmd(string.format("buffer %d", buf)) + end + vim.cmd(string.format("%d wincmd w", cur_win)) -- return to original window + end + + -- Select the first buffer with a number greater than given buffer + local function get_next_buf(buf) + local next = vim.fn.bufnr "#" + if opts.next == "alternate" and vim.fn.buflisted(next) == 1 then + return next + end + for i = 0, vim.fn.bufnr "$" - 1 do + next = (buf + i) % vim.fn.bufnr "$" + 1 -- will loop back to 1 + if vim.fn.buflisted(next) == 1 then + return next + end + end + end + + -- ---------------- + -- End helper functions + -- ---------------- + + local buf = vim.fn.bufnr() + if vim.fn.buflisted(buf) == 0 then -- exit if buffer number is invalid + vim.cmd "close" + return + end + + if #vim.fn.getbufinfo { buflisted = 1 } < 2 then + if opts.quit then + -- exit when there is only one buffer left + if force then + vim.cmd "qall!" + else + vim.cmd "confirm qall" + end + return + end + + local chad_term, _ = pcall(function() + return vim.api.nvim_buf_get_var(buf, "term_type") + end) + + if chad_term then + -- Must be a window type + vim.cmd(string.format("setlocal nobl", buf)) + vim.cmd "enew" + return + end + -- don't exit and create a new empty buffer + vim.cmd "enew" + vim.cmd "bp" + end + + local next_buf = get_next_buf(buf) + local windows = vim.fn.getbufinfo(buf)[1].windows + + -- force deletion of terminal buffers to avoid the prompt + if force or vim.fn.getbufvar(buf, "&buftype") == "terminal" then + local chad_term, type = pcall(function() + return vim.api.nvim_buf_get_var(buf, "term_type") + end) + + -- TODO this scope is error prone, make resilient + if chad_term then + if type == "wind" then + -- hide from bufferline + vim.cmd(string.format("%d bufdo setlocal nobl", buf)) + -- switch to another buff + -- TODO switch to next buffer, this works too + vim.cmd "BufferLineCycleNext" + else + local cur_win = vim.fn.winnr() + -- we can close this window + vim.cmd(string.format("%d wincmd c", cur_win)) + return + end + else + switch_buffer(windows, next_buf) + vim.cmd(string.format("bd! %d", buf)) + end + else + switch_buffer(windows, next_buf) + vim.cmd(string.format("silent! confirm bd %d", buf)) + end + -- revert buffer switches if user has canceled deletion + if vim.fn.buflisted(buf) == 1 then + switch_buffer(windows, buf) + end +end + +-- hide statusline +-- tables fetched from load_config function +M.hide_statusline = function() + local hidden = require("core.utils").load_config().plugins.options.statusline.hidden + local shown = require("core.utils").load_config().plugins.options.statusline.shown + local api = vim.api + local buftype = api.nvim_buf_get_option(0, "ft") + + -- shown table from config has the highest priority + if vim.tbl_contains(shown, buftype) then + api.nvim_set_option("laststatus", 2) + return + end + + if vim.tbl_contains(hidden, buftype) then + api.nvim_set_option("laststatus", 0) + return + end + + api.nvim_set_option("laststatus", 2) +end + +M.load_config = function() + local conf = require "core.default_config" + + local chadrcExists, change = pcall(require, "custom.chadrc") + + -- if chadrc exists , then merge its table into the default config's + + if chadrcExists then + conf = vim.tbl_deep_extend("force", conf, change) + end + + return conf +end + +M.map = function(mode, keys, command, opt) + local options = { noremap = true, silent = true } + if opt then + options = vim.tbl_extend("force", options, opt) + end + + -- all valid modes allowed for mappings + -- :h map-modes + local valid_modes = { + [""] = true, + ["n"] = true, + ["v"] = true, + ["s"] = true, + ["x"] = true, + ["o"] = true, + ["!"] = true, + ["i"] = true, + ["l"] = true, + ["c"] = true, + ["t"] = true, + } + + -- helper function for M.map + -- can gives multiple modes and keys + local function map_wrapper(sub_mode, lhs, rhs, sub_options) + if type(lhs) == "table" then + for _, key in ipairs(lhs) do + map_wrapper(sub_mode, key, rhs, sub_options) + end + else + if type(sub_mode) == "table" then + for _, m in ipairs(sub_mode) do + map_wrapper(m, lhs, rhs, sub_options) + end + else + if valid_modes[sub_mode] and lhs and rhs then + vim.api.nvim_set_keymap(sub_mode, lhs, rhs, sub_options) + else + sub_mode, lhs, rhs = sub_mode or "", lhs or "", rhs or "" + print( + "Cannot set mapping [ mode = '" .. sub_mode .. "' | key = '" .. lhs .. "' | cmd = '" .. rhs .. "' ]" + ) + end + end + end + end + + map_wrapper(mode, keys, command, options) +end + +-- load plugin after entering vim ui +M.packer_lazy_load = function(plugin, timer) + if plugin then + timer = timer or 0 + vim.defer_fn(function() + require("packer").loader(plugin) + end, timer) + end +end + +-- Highlights functions + +-- Define bg color +-- @param group Group +-- @param color Color + +M.bg = function(group, col) + cmd("hi " .. group .. " guibg=" .. col) +end + +-- Define fg color +-- @param group Group +-- @param color Color +M.fg = function(group, col) + cmd("hi " .. group .. " guifg=" .. col) +end + +-- Define bg and fg color +-- @param group Group +-- @param fgcol Fg Color +-- @param bgcol Bg Color +M.fg_bg = function(group, fgcol, bgcol) + cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol) +end + +-- Override default config of a plugin based on the path provided in the chadrc +-- Arguments: +-- 1st - name of plugin +-- 2nd - default config path +-- 3rd - optional function name which will called from default_config path +-- e.g: if given args - "telescope", "plugins.configs.telescope", "setup" +-- then return "require('plugins.configs.telescope').setup()" +-- if 3rd arg not given, then return "require('plugins.configs.telescope')" +-- if override is a table, mark set the override flag for the default config to true +-- override flag being true tells the plugin to call tbl_override_req as part of configuration + +M.override_req = function(name, default_config, config_function) + local override, apply_table_override = + require("core.utils").load_config().plugins.default_plugin_config_replace[name], "false" + local result = default_config + if type(override) == "string" and override ~= "" then + return "require('" .. override .. "')" + elseif type(override) == "table" then + apply_table_override = "true" + elseif type(override) == "function" then + return override + end + + result = "('" .. result .. "')" + if type(config_function) == "string" and config_function ~= "" then + -- add the . to call the functions and concatenate true or false as argument + result = result .. "." .. config_function .. "(" .. apply_table_override .. ")" + end + + return "require" .. result +end + +-- Override parts of default config of a plugin based on the table provided in the chadrc + +-- FUNCTION: tbl_override_req, use `chadrc` plugin config override to modify default config if present +-- name = name inside `default_config` / `chadrc` +-- default_table = the default configuration table of the plugin +-- returns the modified configuration table +M.tbl_override_req = function(name, default_table) + local override = require("core.utils").load_config().plugins.default_plugin_config_replace[name] or {} + return vim.tbl_deep_extend("force", default_table, override) +end + +--provide labels to plugins instead of integers +M.label_plugins = function(plugins) + local plugins_labeled = {} + for _, plugin in ipairs(plugins) do + plugins_labeled[plugin[1]] = plugin + end + return plugins_labeled +end + +-- remove plugins specified by user from the plugins table +M.remove_default_plugins = function(plugins) + local removals = require("core.utils").load_config().plugins.default_plugin_remove or {} + if not vim.tbl_isempty(removals) then + for _, plugin in pairs(removals) do + plugins[plugin] = nil + end + end + return plugins +end + +-- append user plugins to default plugins +M.add_user_plugins = function(plugins) + local user_Plugins = require("core.utils").load_config().plugins.install or {} + if type(user_Plugins) == "string" + then user_Plugins=require(user_Plugins) + end + if not vim.tbl_isempty(user_Plugins) then + for _, v in pairs(user_Plugins) do + plugins[v[1]] = v + end + end + return plugins +end + +return M diff --git a/NvChad/lua/custom/chadrc.lua b/NvChad/lua/custom/chadrc.lua new file mode 100644 index 0000000..369fb0a --- /dev/null +++ b/NvChad/lua/custom/chadrc.lua @@ -0,0 +1,30 @@ +local M = {} + +local plugin_conf = require "custom.plugins.configs" +local userPlugins = require "custom.plugins" + +M.plugins = { + status = { + colorizer = true, + }, + + options = { + lspconfig = { + setup_lspconf = "custom.plugins.lspconfig", + }, + }, + + default_plugin_config_replace = { + nvim_treesitter = plugin_conf.treesitter, + nvim_tree = plugin_conf.nvimtree, + }, + + install = userPlugins, +} + + +M.ui = { + theme = "tomorrow-night", +} + +return M diff --git a/NvChad/lua/custom/init.lua b/NvChad/lua/custom/init.lua new file mode 100644 index 0000000..fe9a055 --- /dev/null +++ b/NvChad/lua/custom/init.lua @@ -0,0 +1 @@ +require "custom.mappings" diff --git a/NvChad/lua/custom/mappings.lua b/NvChad/lua/custom/mappings.lua new file mode 100644 index 0000000..0ddd88e --- /dev/null +++ b/NvChad/lua/custom/mappings.lua @@ -0,0 +1,6 @@ +local map = require("core.utils").map + +map("n", "<leader>r", ":NvimTreeRefresh<CR>") +map("n", "<C-b>", ":NvimTreeToggle<CR>") +map("n", "<C-F>", ":!tmux-sessionizer<CR>") + diff --git a/NvChad/lua/custom/plugins/configs.lua b/NvChad/lua/custom/plugins/configs.lua new file mode 100644 index 0000000..1250cd7 --- /dev/null +++ b/NvChad/lua/custom/plugins/configs.lua @@ -0,0 +1,26 @@ +local M = {} + +-- overriding default plugin configs! +M.treesitter = { + ensure_installed = { + "lua", + "vim", + "html", + "css", + "javascript", + "json", + "toml", + "markdown", + "c", + "rust", + "bash", + }, +} + +M.nvimtree = { + git = { + enable = true, + }, +} + +return M
\ No newline at end of file diff --git a/NvChad/lua/custom/plugins/init.lua b/NvChad/lua/custom/plugins/init.lua new file mode 100644 index 0000000..8c07f0c --- /dev/null +++ b/NvChad/lua/custom/plugins/init.lua @@ -0,0 +1,91 @@ +return { + + { + "williamboman/nvim-lsp-installer", + requires = 'nvim-lspconfig', + after = 'nvim-lspconfig', + config = function() + local lsp_installer = require "nvim-lsp-installer" + + lsp_installer.settings({ + ui = { + icons = { + server_installed = "✓", + server_pending = "➜", + server_uninstalled = "✗" + } + } + }) + + lsp_installer.on_server_ready(function(server) + local opts = {} + + server:setup(opts) + vim.cmd [[ do User LspAttachBuffers ]] + end) + end, + }, + + + { + 'TimUntersberger/neogit', + cmd = 'Neogit', + config = function() + require('neogit').setup { + disable_commit_confirmation = true, + disable_signs = true + } + end + }, + + { + "jose-elias-alvarez/null-ls.nvim", + after = "nvim-lspconfig", + config = function() + require("custom.plugins.null-ls").setup() + end, + + }, + + + { + "nvim-telescope/telescope-frecency.nvim", + after = "telescope.nvim", + config = function() + require("telescope").load_extension("frecency") + end, + requires = 'tami5/sqlite.lua', + }, + + { + "nvim-telescope/telescope-fzf-native.nvim", + after = "telescope.nvim", + config = function() + require("telescope").setup { + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + } + } + } + require("telescope").load_extension("fzf") + end, + run = 'make', + }, + + { + "karb94/neoscroll.nvim", + opt = true, + config = function() + require("neoscroll").setup() + end, + + -- lazy loading + setup = function() + require("core.utils").packer_lazy_load "neoscroll.nvim" + end, +} +} diff --git a/NvChad/lua/custom/plugins/lspconfig.lua b/NvChad/lua/custom/plugins/lspconfig.lua new file mode 100644 index 0000000..2a6e969 --- /dev/null +++ b/NvChad/lua/custom/plugins/lspconfig.lua @@ -0,0 +1,29 @@ +local M = {} + +M.setup_lsp = function(attach, capabilities) + local lspconfig = require "lspconfig" + + lspconfig.tsserver.setup { + on_attach = function(client, bufnr) + client.resolved_capabilities.document_formatting = false + vim.api.nvim_buf_set_keymap(bufnr, "n", "A-F", "<cmd>lua vim.lsp.buf.formatting()<CR>", {}) + end, + } + + -- lspservers with default config + local servers = { "html", "cssls", "bashls", "clangd", "emmet_ls" } + + + for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = attach, + capabilities = capabilities, + flags = { + debounce_text_changes = 150, + }, + } + end + +end + +return M diff --git a/NvChad/lua/custom/plugins/null-ls.lua b/NvChad/lua/custom/plugins/null-ls.lua new file mode 100644 index 0000000..f0b540f --- /dev/null +++ b/NvChad/lua/custom/plugins/null-ls.lua @@ -0,0 +1,29 @@ +local null_s = require "null-ls" + +local b = null_ls.builtins + +local sources = { + + -- webdev stuff + b.formatting.deno_fmt, + b.formatting.prettierd.with { filetypes = { "html", "markdown", "css" } }, + + -- Lua + b.formatting.stylua, + b.diagnostics.luacheck.with { extra_args = { "--global vim" } }, + + -- Shell + b.formatting.shfmt, + b.diagnostics.shellcheck.with { diagnostics_format = "#{m} [#{c}]" }, +} + +local M = {} + +M.setup = function() + null_ls.setup { + debug = true, + sources = sources, + } +end + +return M diff --git a/NvChad/lua/plugins/configs/alpha.lua b/NvChad/lua/plugins/configs/alpha.lua new file mode 100644 index 0000000..7171306 --- /dev/null +++ b/NvChad/lua/plugins/configs/alpha.lua @@ -0,0 +1,86 @@ +local present, alpha = pcall(require, "alpha") + +if not present then + return +end + +local ascii = { + " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", + " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", + " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", + " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", + " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", + " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", + " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", + " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", + " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ", + " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", + " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", +} + +local header = { + type = "text", + val = ascii, + opts = { + position = "center", + hl = "AlphaHeader", + }, +} + +local function button(sc, txt, keybind) + local sc_ = sc:gsub("%s", ""):gsub("SPC", "<leader>") + + local opts = { + position = "center", + text = txt, + shortcut = sc, + cursor = 5, + width = 36, + align_shortcut = "right", + hl = "AlphaButtons", + } + + if keybind then + opts.keymap = { "n", sc_, keybind, { noremap = true, silent = true } } + end + + return { + type = "button", + val = txt, + on_press = function() + local key = vim.api.nvim_replace_termcodes(sc_, true, false, true) + vim.api.nvim_feedkeys(key, "normal", false) + end, + opts = opts, + } +end + +local buttons = { + type = "group", + val = { + button("SPC f f", " Find File ", ":Telescope find_files<CR>"), + button("SPC f o", " Recent File ", ":Telescope oldfiles<CR>"), + button("SPC f w", " Find Word ", ":Telescope live_grep<CR>"), + button("SPC b m", " Bookmarks ", ":Telescope marks<CR>"), + button("SPC t h", " Themes ", ":Telescope themes<CR>"), + button("SPC e s", " Settings", ":e $MYVIMRC | :cd %:p:h <CR>"), + }, + opts = { + spacing = 1, + }, +} + +local section = { + header = header, + buttons = buttons, +} + +alpha.setup { + layout = { + { type = "padding", val = 5 }, + section.header, + { type = "padding", val = 2 }, + section.buttons, + }, + opts = {}, +} diff --git a/NvChad/lua/plugins/configs/bufferline.lua b/NvChad/lua/plugins/configs/bufferline.lua new file mode 100644 index 0000000..98557fd --- /dev/null +++ b/NvChad/lua/plugins/configs/bufferline.lua @@ -0,0 +1,148 @@ +local present, bufferline = pcall(require, "bufferline") +if not present then + return +end + +local default = { + colors = require("colors").get(), +} +default = { + options = { + offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + buffer_close_icon = "", + modified_icon = "", + close_icon = "", + show_close_icon = true, + left_trunc_marker = "", + right_trunc_marker = "", + max_name_length = 14, + max_prefix_length = 13, + tab_size = 20, + show_tab_indicators = true, + enforce_regular_tabs = false, + view = "multiwindow", + show_buffer_close_icons = true, + separator_style = "thin", + always_show_bufferline = true, + diagnostics = false, + custom_filter = function(buf_number) + -- Func to filter out our managed/persistent split terms + local present_type, type = pcall(function() + return vim.api.nvim_buf_get_var(buf_number, "term_type") + end) + + if present_type then + if type == "vert" then + return false + elseif type == "hori" then + return false + end + return true + end + + return true + end, + }, + + highlights = { + background = { + guifg = default.colors.grey_fg, + guibg = default.colors.black2, + }, + + -- buffers + buffer_selected = { + guifg = default.colors.white, + guibg = default.colors.black, + gui = "bold", + }, + buffer_visible = { + guifg = default.colors.light_grey, + guibg = default.colors.black2, + }, + + -- for diagnostics = "nvim_lsp" + error = { + guifg = default.colors.light_grey, + guibg = default.colors.black2, + }, + error_diagnostic = { + guifg = default.colors.light_grey, + guibg = default.colors.black2, + }, + + -- close buttons + close_button = { + guifg = default.colors.light_grey, + guibg = default.colors.black2, + }, + close_button_visible = { + guifg = default.colors.light_grey, + guibg = default.colors.black2, + }, + close_button_selected = { + guifg = default.colors.red, + guibg = default.colors.black, + }, + fill = { + guifg = default.colors.grey_fg, + guibg = default.colors.black2, + }, + indicator_selected = { + guifg = default.colors.black, + guibg = default.colors.black, + }, + + -- modified + modified = { + guifg = default.colors.red, + guibg = default.colors.black2, + }, + modified_visible = { + guifg = default.colors.red, + guibg = default.colors.black2, + }, + modified_selected = { + guifg = default.colors.green, + guibg = default.colors.black, + }, + + -- separators + separator = { + guifg = default.colors.black2, + guibg = default.colors.black2, + }, + separator_visible = { + guifg = default.colors.black2, + guibg = default.colors.black2, + }, + separator_selected = { + guifg = default.colors.black2, + guibg = default.colors.black2, + }, + + -- tabs + tab = { + guifg = default.colors.light_grey, + guibg = default.colors.one_bg3, + }, + tab_selected = { + guifg = default.colors.black2, + guibg = default.colors.nord_blue, + }, + tab_close = { + guifg = default.colors.red, + guibg = default.colors.black, + }, + }, +} + +local M = {} +M.setup = function(override_flag) + if override_flag then + default = require("core.utils").tbl_override_req("bufferline", default) + end + bufferline.setup(default) +end + +return M diff --git a/NvChad/lua/plugins/configs/cmp.lua b/NvChad/lua/plugins/configs/cmp.lua new file mode 100644 index 0000000..94944b7 --- /dev/null +++ b/NvChad/lua/plugins/configs/cmp.lua @@ -0,0 +1,76 @@ +local present, cmp = pcall(require, "cmp") + +if not present then + return +end + +vim.opt.completeopt = "menuone,noselect" + +local default = { + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + formatting = { + format = function(entry, vim_item) + local icons = require "plugins.configs.lspkind_icons" + vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) + + vim_item.menu = ({ + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + buffer = "[BUF]", + })[entry.source.name] + + return vim_item + end, + }, + mapping = { + ["<C-p>"] = cmp.mapping.select_prev_item(), + ["<C-n>"] = cmp.mapping.select_next_item(), + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + ["<C-e>"] = cmp.mapping.close(), + ["<CR>"] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + ["<Tab>"] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, + ["<S-Tab>"] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" }, + }, +} + +local M = {} +M.setup = function(override_flag) + if override_flag then + default = require("core.utils").tbl_override_req("nvim_cmp", default) + end + cmp.setup(default) +end + +return M diff --git a/NvChad/lua/plugins/configs/icons.lua b/NvChad/lua/plugins/configs/icons.lua new file mode 100644 index 0000000..4f23dd9 --- /dev/null +++ b/NvChad/lua/plugins/configs/icons.lua @@ -0,0 +1,158 @@ +local present, icons = pcall(require, "nvim-web-devicons") +if not present then + return +end + +local default = { + colors = require("colors").get(), +} + +default = { + override = { + c = { + icon = "", + color = default.colors.blue, + name = "c", + }, + css = { + icon = "", + color = default.colors.blue, + name = "css", + }, + deb = { + icon = "", + color = default.colors.cyan, + name = "deb", + }, + Dockerfile = { + icon = "", + color = default.colors.cyan, + name = "Dockerfile", + }, + html = { + icon = "", + color = default.colors.baby_pink, + name = "html", + }, + jpeg = { + icon = "", + color = default.colors.dark_purple, + name = "jpeg", + }, + jpg = { + icon = "", + color = default.colors.dark_purple, + name = "jpg", + }, + js = { + icon = "", + color = default.colors.sun, + name = "js", + }, + kt = { + icon = "", + color = default.colors.orange, + name = "kt", + }, + lock = { + icon = "", + color = default.colors.red, + name = "lock", + }, + lua = { + icon = "", + color = default.colors.blue, + name = "lua", + }, + mp3 = { + icon = "", + color = default.colors.white, + name = "mp3", + }, + mp4 = { + icon = "", + color = default.colors.white, + name = "mp4", + }, + out = { + icon = "", + color = default.colors.white, + name = "out", + }, + png = { + icon = "", + color = default.colors.dark_purple, + name = "png", + }, + py = { + icon = "", + color = default.colors.cyan, + name = "py", + }, + ["robots.txt"] = { + icon = "ﮧ", + color = default.colors.red, + name = "robots", + }, + toml = { + icon = "", + color = default.colors.blue, + name = "toml", + }, + ts = { + icon = "ﯤ", + color = default.colors.teal, + name = "ts", + }, + ttf = { + icon = "", + color = default.colors.white, + name = "TrueTypeFont", + }, + rb = { + icon = "", + color = default.colors.pink, + name = "rb", + }, + rpm = { + icon = "", + color = default.colors.orange, + name = "rpm", + }, + vue = { + icon = "﵂", + color = default.colors.vibrant_green, + name = "vue", + }, + woff = { + icon = "", + color = default.colors.white, + name = "WebOpenFontFormat", + }, + woff2 = { + icon = "", + color = default.colors.white, + name = "WebOpenFontFormat2", + }, + xz = { + icon = "", + color = default.colors.sun, + name = "xz", + }, + zip = { + icon = "", + color = default.colors.sun, + name = "zip", + }, + }, +} + +local M = {} +M.setup = function(override_flag) + if override_flag then + default = require("core.utils").tbl_override_req("nvim_web_devicons", default) + end + icons.setup(default) +end + +return M diff --git a/NvChad/lua/plugins/configs/lspconfig.lua b/NvChad/lua/plugins/configs/lspconfig.lua new file mode 100644 index 0000000..2d1273b --- /dev/null +++ b/NvChad/lua/plugins/configs/lspconfig.lua @@ -0,0 +1,36 @@ +require("plugins.configs.others").lsp_handlers() + +local function on_attach(_, bufnr) + local function buf_set_option(...) + vim.api.nvim_buf_set_option(bufnr, ...) + end + + -- Enable completion triggered by <c-x><c-o> + buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") + + require("core.mappings").lspconfig() +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.documentationFormat = { "markdown", "plaintext" } +capabilities.textDocument.completion.completionItem.snippetSupport = true +capabilities.textDocument.completion.completionItem.preselectSupport = true +capabilities.textDocument.completion.completionItem.insertReplaceSupport = true +capabilities.textDocument.completion.completionItem.labelDetailsSupport = true +capabilities.textDocument.completion.completionItem.deprecatedSupport = true +capabilities.textDocument.completion.completionItem.commitCharactersSupport = true +capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } } +capabilities.textDocument.completion.completionItem.resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, +} + +-- requires a file containing user's lspconfigs +local addlsp_confs = require("core.utils").load_config().plugins.options.lspconfig.setup_lspconf + +if #addlsp_confs ~= 0 then + require(addlsp_confs).setup_lsp(on_attach, capabilities) +end diff --git a/NvChad/lua/plugins/configs/lspkind_icons.lua b/NvChad/lua/plugins/configs/lspkind_icons.lua new file mode 100644 index 0000000..2d538a7 --- /dev/null +++ b/NvChad/lua/plugins/configs/lspkind_icons.lua @@ -0,0 +1,29 @@ +local icons = { + Text = "", + Method = "", + Function = "", + Constructor = "", + Field = "ﰠ", + Variable = "", + Class = "ﴯ", + Interface = "", + Module = "", + Property = "ﰠ", + Unit = "塞", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "פּ", + Event = "", + Operator = "", + TypeParameter = "", +} + +return icons diff --git a/NvChad/lua/plugins/configs/nvimtree.lua b/NvChad/lua/plugins/configs/nvimtree.lua new file mode 100644 index 0000000..d74f4f5 --- /dev/null +++ b/NvChad/lua/plugins/configs/nvimtree.lua @@ -0,0 +1,80 @@ +local present, nvimtree = pcall(require, "nvim-tree") + +if not present then + return +end + +local g = vim.g + +g.nvim_tree_add_trailing = 0 -- append a trailing slash to folder names +g.nvim_tree_git_hl = 0 +g.nvim_tree_highlight_opened_files = 0 +g.nvim_tree_indent_markers = 1 +g.nvim_tree_root_folder_modifier = table.concat { ":t:gs?$?/..", string.rep(" ", 1000), "?:gs?^??" } + +g.nvim_tree_show_icons = { + folders = 1, + files = 1, + git = 1, +} + +g.nvim_tree_icons = { + default = "", + symlink = "", + git = { + deleted = "", + ignored = "◌", + renamed = "➜", + staged = "✓", + unmerged = "", + unstaged = "✗", + untracked = "★", + }, + folder = { + default = "", + empty = "", + empty_open = "", + open = "", + symlink = "", + symlink_open = "", + }, +} + +local default = { + filters = { + dotfiles = false, + }, + disable_netrw = true, + hijack_netrw = true, + ignore_ft_on_setup = { "dashboard" }, + auto_close = false, + open_on_tab = false, + hijack_cursor = true, + hijack_unnamed_buffer_when_opening = false, + update_cwd = true, + update_focused_file = { + enable = true, + update_cwd = false, + }, + view = { + allow_resize = true, + side = "left", + width = 25, + hide_root_folder = true, + }, + git = { + enable = false, + ignore = false, + }, +} + +local M = {} + +M.setup = function(override_flag) + if override_flag then + default = require("core.utils").tbl_override_req("nvim_tree", default) + end + nvimtree.setup(default) +end + +return M diff --git a/NvChad/lua/plugins/configs/others.lua b/NvChad/lua/plugins/configs/others.lua new file mode 100644 index 0000000..99877cc --- /dev/null +++ b/NvChad/lua/plugins/configs/others.lua @@ -0,0 +1,196 @@ +local M = {} + +local chadrc_config = require("core.utils").load_config() + +M.autopairs = function(override_flag) + local present1, autopairs = pcall(require, "nvim-autopairs") + local present2, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp") + + if present1 and present2 then + local default = { fast_wrap = {} } + if override_flag then + default = require("core.utils").tbl_override_req("nvim_autopairs", default) + end + autopairs.setup(default) + + local cmp = require "cmp" + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end +end + +M.better_escape = function() + require("better_escape").setup { + mapping = chadrc_config.mappings.plugins.better_escape.esc_insertmode, + timeout = chadrc_config.plugins.options.esc_insertmode_timeout, + } +end + +M.blankline = function(override_flag) + local default = { + indentLine_enabled = 1, + char = "▏", + filetype_exclude = { + "help", + "terminal", + "alpha", + "packer", + "lspinfo", + "TelescopePrompt", + "TelescopeResults", + "nvchad_cheatsheet", + "lsp-installer", + "", + }, + buftype_exclude = { "terminal" }, + show_trailing_blankline_indent = false, + show_first_indent_level = false, + } + if override_flag then + default = require("core.utils").tbl_override_req("indent_blankline", default) + end + require("indent_blankline").setup(default) +end + +M.colorizer = function(override_flag) + local present, colorizer = pcall(require, "colorizer") + if present then + local default = { + filetypes = { + "*", + }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = false, -- "Name" codes like Blue + RRGGBBAA = false, -- #RRGGBBAA hex codes + rgb_fn = false, -- CSS rgb() and rgba() functions + hsl_fn = false, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn + + -- Available modes: foreground, background + mode = "background", -- Set the display mode. + }, + } + if override_flag then + default = require("core.utils").tbl_override_req("nvim_colorizer", default) + end + colorizer.setup(default["filetypes"], default["user_default_options"]) + vim.cmd "ColorizerReloadAllBuffers" + end +end + +M.comment = function(override_flag) + local present, nvim_comment = pcall(require, "Comment") + if present then + local default = {} + if override_flag then + default = require("core.utils").tbl_override_req("nvim_comment", default) + end + nvim_comment.setup(default) + end +end + +M.luasnip = function(override_flag) + local present, luasnip = pcall(require, "luasnip") + if present then + local default = { + history = true, + updateevents = "TextChanged,TextChangedI", + } + if override_flag then + default = require("core.utils").tbl_override_req("luasnip", default) + end + luasnip.config.set_config(default) + require("luasnip/loaders/from_vscode").load { paths = chadrc_config.plugins.options.luasnip.snippet_path } + require("luasnip/loaders/from_vscode").load() + end +end + +M.signature = function(override_flag) + local present, lspsignature = pcall(require, "lsp_signature") + if present then + local default = { + bind = true, + doc_lines = 0, + floating_window = true, + fix_pos = true, + hint_enable = true, + hint_prefix = " ", + hint_scheme = "String", + hi_parameter = "Search", + max_height = 22, + max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width + handler_opts = { + border = "single", -- double, single, shadow, none + }, + zindex = 200, -- by default it will be on top of all floating windows, set to 50 send it to bottom + padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc + } + if override_flag then + default = require("core.utils").tbl_override_req("signature", default) + end + lspsignature.setup(default) + end +end + +M.lsp_handlers = function() + local function lspSymbol(name, icon) + local hl = "DiagnosticSign" .. name + vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl }) + end + + lspSymbol("Error", "") + lspSymbol("Info", "") + lspSymbol("Hint", "") + lspSymbol("Warn", "") + + vim.diagnostic.config { + virtual_text = { + prefix = "", + }, + signs = true, + underline = true, + update_in_insert = false, + } + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "single", + }) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "single", + }) + + -- suppress error messages from lang servers + vim.notify = function(msg, log_level) + if msg:match "exit code" then + return + end + if log_level == vim.log.levels.ERROR then + vim.api.nvim_err_writeln(msg) + else + vim.api.nvim_echo({ { msg } }, true, {}) + end + end +end + +M.gitsigns = function(override_flag) + local present, gitsigns = pcall(require, "gitsigns") + if present then + local default = { + signs = { + add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" }, + change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" }, + delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" }, + topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, + changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, + }, + } + if override_flag then + default = require("core.utils").tbl_override_req("gitsigns", default) + end + gitsigns.setup(default) + end +end + +return M diff --git a/NvChad/lua/plugins/configs/statusline.lua b/NvChad/lua/plugins/configs/statusline.lua new file mode 100644 index 0000000..ddad9d5 --- /dev/null +++ b/NvChad/lua/plugins/configs/statusline.lua @@ -0,0 +1,438 @@ +local present, feline = pcall(require, "feline") +if not present then + return +end + +local default = { + colors = require("colors").get(), + lsp = require "feline.providers.lsp", + lsp_severity = vim.diagnostic.severity, + config = require("core.utils").load_config().plugins.options.statusline, +} + +default.icon_styles = { + default = { + left = "", + right = " ", + main_icon = " ", + vi_mode_icon = " ", + position_icon = " ", + }, + arrow = { + left = "", + right = "", + main_icon = " ", + vi_mode_icon = " ", + position_icon = " ", + }, + + block = { + left = " ", + right = " ", + main_icon = " ", + vi_mode_icon = " ", + position_icon = " ", + }, + + round = { + left = "", + right = "", + main_icon = " ", + vi_mode_icon = " ", + position_icon = " ", + }, + + slant = { + left = " ", + right = " ", + main_icon = " ", + vi_mode_icon = " ", + position_icon = " ", + }, +} + +-- statusline style +default.statusline_style = default.icon_styles[default.config.style] + +-- show short statusline on small screens +default.shortline = default.config.shortline == false and true + +-- Initialize the components table +default.components = { + active = {}, +} + +default.main_icon = { + provider = default.statusline_style.main_icon, + + hl = { + fg = default.colors.statusline_bg, + bg = default.colors.nord_blue, + }, + + right_sep = { + str = default.statusline_style.right, + hl = { + fg = default.colors.nord_blue, + bg = default.colors.lightbg, + }, + }, +} + +default.file_name = { + provider = function() + local filename = vim.fn.expand "%:t" + local extension = vim.fn.expand "%:e" + local icon = require("nvim-web-devicons").get_icon(filename, extension) + if icon == nil then + icon = " " + return icon + end + return " " .. icon .. " " .. filename .. " " + end, + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70 + end, + hl = { + fg = default.colors.white, + bg = default.colors.lightbg, + }, + + right_sep = { + str = default.statusline_style.right, + hl = { fg = default.colors.lightbg, bg = default.colors.lightbg2 }, + }, +} + +default.dir_name = { + provider = function() + local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") + return " " .. dir_name .. " " + end, + + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 80 + end, + + hl = { + fg = default.colors.grey_fg2, + bg = default.colors.lightbg2, + }, + right_sep = { + str = default.statusline_style.right, + hi = { + fg = default.colors.lightbg2, + bg = default.colors.statusline_bg, + }, + }, +} + +default.diff = { + add = { + provider = "git_diff_added", + hl = { + fg = default.colors.grey_fg2, + bg = default.colors.statusline_bg, + }, + icon = " ", + }, + + change = { + provider = "git_diff_changed", + hl = { + fg = default.colors.grey_fg2, + bg = default.colors.statusline_bg, + }, + icon = " ", + }, + + remove = { + provider = "git_diff_removed", + hl = { + fg = default.colors.grey_fg2, + bg = default.colors.statusline_bg, + }, + icon = " ", + }, +} + +default.git_branch = { + provider = "git_branch", + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70 + end, + hl = { + fg = default.colors.grey_fg2, + bg = default.colors.statusline_bg, + }, + icon = " ", +} + +default.diagnostic = { + error = { + provider = "diagnostic_errors", + enabled = function() + return default.lsp.diagnostics_exist(default.lsp_severity.ERROR) + end, + + hl = { fg = default.colors.red }, + icon = " ", + }, + + warning = { + provider = "diagnostic_warnings", + enabled = function() + return default.lsp.diagnostics_exist(default.lsp_severity.WARN) + end, + hl = { fg = default.colors.yellow }, + icon = " ", + }, + + hint = { + provider = "diagnostic_hints", + enabled = function() + return default.lsp.diagnostics_exist(default.lsp_severity.HINT) + end, + hl = { fg = default.colors.grey_fg2 }, + icon = " ", + }, + + info = { + provider = "diagnostic_info", + enabled = function() + return default.lsp.diagnostics_exist(default.lsp_severity.INFO) + end, + hl = { fg = default.colors.green }, + icon = " ", + }, +} + +default.lsp_progress = { + provider = function() + local Lsp = vim.lsp.util.get_progress_messages()[1] + + if Lsp then + local msg = Lsp.message or "" + local percentage = Lsp.percentage or 0 + local title = Lsp.title or "" + local spinners = { + "", + "", + "", + } + + local success_icon = { + "", + "", + "", + } + + local ms = vim.loop.hrtime() / 1000000 + local frame = math.floor(ms / 120) % #spinners + + if percentage >= 70 then + return string.format(" %%<%s %s %s (%s%%%%) ", success_icon[frame + 1], title, msg, percentage) + end + + return string.format(" %%<%s %s %s (%s%%%%) ", spinners[frame + 1], title, msg, percentage) + end + + return "" + end, + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 80 + end, + hl = { fg = default.colors.green }, +} + +default.lsp_icon = { + provider = function() + if next(vim.lsp.buf_get_clients()) ~= nil then + return " LSP" + else + return "" + end + end, + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 70 + end, + hl = { fg = default.colors.grey_fg2, bg = default.colors.statusline_bg }, +} + +default.mode_colors = { + ["n"] = { "NORMAL", default.colors.red }, + ["no"] = { "N-PENDING", default.colors.red }, + ["i"] = { "INSERT", default.colors.dark_purple }, + ["ic"] = { "INSERT", default.colors.dark_purple }, + ["t"] = { "TERMINAL", default.colors.green }, + ["v"] = { "VISUAL", default.colors.cyan }, + ["V"] = { "V-LINE", default.colors.cyan }, + [""] = { "V-BLOCK", default.colors.cyan }, + ["R"] = { "REPLACE", default.colors.orange }, + ["Rv"] = { "V-REPLACE", default.colors.orange }, + ["s"] = { "SELECT", default.colors.nord_blue }, + ["S"] = { "S-LINE", default.colors.nord_blue }, + [""] = { "S-BLOCK", default.colors.nord_blue }, + ["c"] = { "COMMAND", default.colors.pink }, + ["cv"] = { "COMMAND", default.colors.pink }, + ["ce"] = { "COMMAND", default.colors.pink }, + ["r"] = { "PROMPT", default.colors.teal }, + ["rm"] = { "MORE", default.colors.teal }, + ["r?"] = { "CONFIRM", default.colors.teal }, + ["!"] = { "SHELL", default.colors.green }, +} + +default.chad_mode_hl = function() + return { + fg = default.mode_colors[vim.fn.mode()][2], + bg = default.colors.one_bg, + } +end + +default.empty_space = { + provider = " " .. default.statusline_style.left, + hl = { + fg = default.colors.one_bg2, + bg = default.colors.statusline_bg, + }, +} + +-- this matches the vi mode color +default.empty_spaceColored = { + provider = default.statusline_style.left, + hl = function() + return { + fg = default.mode_colors[vim.fn.mode()][2], + bg = default.colors.one_bg2, + } + end, +} + +default.mode_icon = { + provider = default.statusline_style.vi_mode_icon, + hl = function() + return { + fg = default.colors.statusline_bg, + bg = default.mode_colors[vim.fn.mode()][2], + } + end, +} + +default.empty_space2 = { + provider = function() + return " " .. default.mode_colors[vim.fn.mode()][1] .. " " + end, + hl = default.chad_mode_hl, +} + +default.separator_right = { + provider = default.statusline_style.left, + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90 + end, + hl = { + fg = default.colors.grey, + bg = default.colors.one_bg, + }, +} + +default.separator_right2 = { + provider = default.statusline_style.left, + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90 + end, + hl = { + fg = default.colors.green, + bg = default.colors.grey, + }, +} + +default.position_icon = { + provider = default.statusline_style.position_icon, + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90 + end, + hl = { + fg = default.colors.black, + bg = default.colors.green, + }, +} + +default.current_line = { + provider = function() + local current_line = vim.fn.line "." + local total_line = vim.fn.line "$" + + if current_line == 1 then + return " Top " + elseif current_line == vim.fn.line "$" then + return " Bot " + end + local result, _ = math.modf((current_line / total_line) * 100) + return " " .. result .. "%% " + end, + + enabled = default.shortline or function(winid) + return vim.api.nvim_win_get_width(tonumber(winid) or 0) > 90 + end, + + hl = { + fg = default.colors.green, + bg = default.colors.one_bg, + }, +} + +local function add_table(a, b) + table.insert(a, b) +end + +local M = {} +M.setup = function(override_flag) + if override_flag then + default = require("core.utils").tbl_override_req("feline", default) + end + -- components are divided in 3 sections + default.left = {} + default.middle = {} + default.right = {} + + -- left + add_table(default.left, default.main_icon) + add_table(default.left, default.file_name) + add_table(default.left, default.dir_name) + add_table(default.left, default.diff.add) + add_table(default.left, default.diff.change) + add_table(default.left, default.diff.remove) + add_table(default.left, default.diagnostic.error) + add_table(default.left, default.diagnostic.warning) + add_table(default.left, default.diagnostic.hint) + add_table(default.left, default.diagnostic.info) + + add_table(default.middle, default.lsp_progress) + + -- right + add_table(default.right, default.lsp_icon) + add_table(default.right, default.git_branch) + add_table(default.right, default.empty_space) + add_table(default.right, default.empty_spaceColored) + add_table(default.right, default.mode_icon) + add_table(default.right, default.empty_space2) + add_table(default.right, default.separator_right) + add_table(default.right, default.separator_right2) + add_table(default.right, default.position_icon) + add_table(default.right, default.current_line) + + default.components.active[1] = default.left + default.components.active[2] = default.middle + default.components.active[3] = default.right + + feline.setup { + theme = { + bg = default.colors.statusline_bg, + fg = default.colors.fg, + }, + components = default.components, + } +end + +return M diff --git a/NvChad/lua/plugins/configs/telescope.lua b/NvChad/lua/plugins/configs/telescope.lua new file mode 100644 index 0000000..5d4ea01 --- /dev/null +++ b/NvChad/lua/plugins/configs/telescope.lua @@ -0,0 +1,72 @@ +local present, telescope = pcall(require, "telescope") + +if not present then + return +end + +local default = { + defaults = { + vimgrep_arguments = { + "rg", + "--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" }, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = true, + use_less = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + }, +} + +local M = {} +M.setup = function(override_flag) + if override_flag then + default = require("core.utils").tbl_override_req("telescope", default) + end + + telescope.setup(default) + + local extensions = { "themes", "terms" } + pcall(function() + for _, ext in ipairs(extensions) do + telescope.load_extension(ext) + end + end) +end + +return M diff --git a/NvChad/lua/plugins/configs/treesitter.lua b/NvChad/lua/plugins/configs/treesitter.lua new file mode 100644 index 0000000..777b907 --- /dev/null +++ b/NvChad/lua/plugins/configs/treesitter.lua @@ -0,0 +1,26 @@ +local present, ts_config = pcall(require, "nvim-treesitter.configs") + +if not present then + return +end + +local default = { + ensure_installed = { + "lua", + "vim", + }, + highlight = { + enable = true, + use_languagetree = true, + }, +} + +local M = {} +M.setup = function(override_flag) + if override_flag then + default = require("core.utils").tbl_override_req("nvim_treesitter", default) + end + ts_config.setup(default) +end + +return M diff --git a/NvChad/lua/plugins/init.lua b/NvChad/lua/plugins/init.lua new file mode 100644 index 0000000..2e83bdd --- /dev/null +++ b/NvChad/lua/plugins/init.lua @@ -0,0 +1,237 @@ +local plugin_settings = require("core.utils").load_config().plugins +local present, packer = pcall(require, plugin_settings.options.packer.init_file) + +if not present then + return false +end + +local override_req = require("core.utils").override_req + +local plugins = { + { "NvChad/extensions" }, + { "nvim-lua/plenary.nvim" }, + { "lewis6991/impatient.nvim" }, + { "nathom/filetype.nvim" }, + + { + "wbthomason/packer.nvim", + event = "VimEnter", + }, + + { + "NvChad/nvim-base16.lua", + after = "packer.nvim", + config = function() + require("colors").init() + end, + }, + + { + "kyazdani42/nvim-web-devicons", + after = "nvim-base16.lua", + config = override_req("nvim_web_devicons", "plugins.configs.icons", "setup"), + }, + + { + "feline-nvim/feline.nvim", + disable = not plugin_settings.status.feline, + after = "nvim-web-devicons", + config = override_req("feline", "plugins.configs.statusline", "setup"), + }, + + { + "akinsho/bufferline.nvim", + disable = not plugin_settings.status.bufferline, + after = "nvim-web-devicons", + config = override_req("bufferline", "plugins.configs.bufferline", "setup"), + setup = function() + require("core.mappings").bufferline() + end, + }, + + { + "lukas-reineke/indent-blankline.nvim", + disable = not plugin_settings.status.blankline, + event = "BufRead", + config = override_req("indent_blankline", "plugins.configs.others", "blankline"), + }, + + { + "NvChad/nvim-colorizer.lua", + disable = not plugin_settings.status.colorizer, + event = "BufRead", + config = override_req("nvim_colorizer", "plugins.configs.others", "colorizer"), + }, + + { + "nvim-treesitter/nvim-treesitter", + event = { "BufRead", "BufNewFile" }, + config = override_req("nvim_treesitter", "plugins.configs.treesitter", "setup"), + run = ":TSUpdate", + }, + + -- git stuff + { + "lewis6991/gitsigns.nvim", + disable = not plugin_settings.status.gitsigns, + opt = true, + config = override_req("gitsigns", "plugins.configs.others", "gitsigns"), + setup = function() + require("core.utils").packer_lazy_load "gitsigns.nvim" + end, + }, + + -- lsp stuff + + { + "neovim/nvim-lspconfig", + module = "lspconfig", + opt = true, + setup = function() + require("core.utils").packer_lazy_load "nvim-lspconfig" + -- reload the current file so lsp actually starts for it + vim.defer_fn(function() + vim.cmd 'if &ft == "packer" | echo "" | else | silent! e %' + end, 0) + end, + config = override_req("lspconfig", "plugins.configs.lspconfig"), + }, + + { + "ray-x/lsp_signature.nvim", + disable = not plugin_settings.status.lspsignature, + after = "nvim-lspconfig", + config = override_req("signature", "plugins.configs.others", "signature"), + }, + + { + "andymass/vim-matchup", + disable = not plugin_settings.status.vim_matchup, + opt = true, + setup = function() + require("core.utils").packer_lazy_load "vim-matchup" + end, + }, + + { + "max397574/better-escape.nvim", + disable = not plugin_settings.status.better_escape, + event = "InsertCharPre", + config = override_req("better_escape", "plugins.configs.others", "better_escape"), + }, + + -- load luasnips + cmp related in insert mode only + + { + "rafamadriz/friendly-snippets", + module = "cmp_nvim_lsp", + disable = not plugin_settings.status.cmp, + event = "InsertEnter", + }, + + { + "hrsh7th/nvim-cmp", + disable = not plugin_settings.status.cmp, + after = "friendly-snippets", + config = override_req("nvim_cmp", "plugins.configs.cmp", "setup"), + }, + + { + "L3MON4D3/LuaSnip", + disable = not plugin_settings.status.cmp, + wants = "friendly-snippets", + after = "nvim-cmp", + config = override_req("luasnip", "plugins.configs.others", "luasnip"), + }, + + { + "saadparwaiz1/cmp_luasnip", + disable = not plugin_settings.status.cmp, + after = plugin_settings.options.cmp.lazy_load and "LuaSnip", + }, + + { + "hrsh7th/cmp-nvim-lua", + disable = not plugin_settings.status.cmp, + after = "cmp_luasnip", + }, + + { + "hrsh7th/cmp-nvim-lsp", + disable = not plugin_settings.status.cmp, + after = "cmp-nvim-lua", + }, + + { + "hrsh7th/cmp-buffer", + disable = not plugin_settings.status.cmp, + after = "cmp-nvim-lsp", + }, + + { + "hrsh7th/cmp-path", + disable = not plugin_settings.status.cmp, + after = "cmp-buffer", + }, + + -- misc plugins + { + "windwp/nvim-autopairs", + disable = not plugin_settings.status.autopairs, + after = plugin_settings.options.autopairs.loadAfter, + config = override_req("nvim_autopairs", "plugins.configs.others", "autopairs"), + }, + + { + disable = not plugin_settings.status.alpha, + "goolord/alpha-nvim", + config = override_req("alpha", "plugins.configs.alpha"), + }, + + { + "numToStr/Comment.nvim", + disable = not plugin_settings.status.comment, + module = "Comment", + keys = { "gcc" }, + config = override_req("nvim_comment", "plugins.configs.others", "comment"), + setup = function() + require("core.mappings").comment() + end, + }, + + -- file managing , picker etc + { + "kyazdani42/nvim-tree.lua", + disable = not plugin_settings.status.nvimtree, + -- only set "after" if lazy load is disabled and vice versa for "cmd" + after = not plugin_settings.options.nvimtree.lazy_load and "nvim-web-devicons", + cmd = plugin_settings.options.nvimtree.lazy_load and { "NvimTreeToggle", "NvimTreeFocus" }, + config = override_req("nvim_tree", "plugins.configs.nvimtree", "setup"), + setup = function() + require("core.mappings").nvimtree() + end, + }, + + { + "nvim-telescope/telescope.nvim", + module = "telescope", + cmd = "Telescope", + config = override_req("telescope", "plugins.configs.telescope", "setup"), + setup = function() + require("core.mappings").telescope() + end, + }, +} + +--label plugins for operational assistance +plugins = require("core.utils").label_plugins(plugins) +--remove plugins specified in chadrc +plugins = require("core.utils").remove_default_plugins(plugins) +--add plugins specified in chadrc +plugins = require("core.utils").add_user_plugins(plugins) + +return packer.startup(function(use) + for _, v in pairs(plugins) do + use(v) + end +end) diff --git a/NvChad/lua/plugins/packerInit.lua b/NvChad/lua/plugins/packerInit.lua new file mode 100644 index 0000000..cafdd4f --- /dev/null +++ b/NvChad/lua/plugins/packerInit.lua @@ -0,0 +1,44 @@ +vim.cmd "packadd packer.nvim" + +local present, packer = pcall(require, "packer") + +if not present then + local packer_path = vim.fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim" + + print "Cloning packer.." + -- remove the dir before cloning + vim.fn.delete(packer_path, "rf") + vim.fn.system { + "git", + "clone", + "https://github.com/wbthomason/packer.nvim", + "--depth", + "20", + packer_path, + } + + vim.cmd "packadd packer.nvim" + present, packer = pcall(require, "packer") + + if present then + print "Packer cloned successfully." + else + error("Couldn't clone packer !\nPacker path: " .. packer_path .. "\n" .. packer) + end +end + +packer.init { + display = { + open_fn = function() + return require("packer.util").float { border = "single" } + end, + prompt_border = "single", + }, + git = { + clone_timeout = 6000, -- seconds + }, + auto_clean = true, + compile_on_sync = true, +} + +return packer diff --git a/NvChad/plugin/packer_compiled.lua b/NvChad/plugin/packer_compiled.lua new file mode 100644 index 0000000..42ffb3a --- /dev/null +++ b/NvChad/plugin/packer_compiled.lua @@ -0,0 +1,489 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + + local time + local profile_info + local should_profile = false + if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end + else + time = function(chunk, start) end + end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + + _G._packer = _G._packer or {} + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/home/tobyv/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + ["Comment.nvim"] = { + config = { "require('plugins.configs.others').comment(false)" }, + keys = { { "", "gcc" } }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/Comment.nvim", + url = "https://github.com/numToStr/Comment.nvim" + }, + LuaSnip = { + after = { "cmp_luasnip" }, + config = { "require('plugins.configs.others').luasnip(false)" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip", + wants = { "friendly-snippets" } + }, + ["better-escape.nvim"] = { + config = { "require('plugins.configs.others').better_escape(false)" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/better-escape.nvim", + url = "https://github.com/max397574/better-escape.nvim" + }, + ["bufferline.nvim"] = { + config = { "require('plugins.configs.bufferline').setup(false)" }, + load_after = { + ["nvim-web-devicons"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/bufferline.nvim", + url = "https://github.com/akinsho/bufferline.nvim" + }, + ["cmp-buffer"] = { + after = { "cmp-path" }, + after_files = { "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp-buffer/after/plugin/cmp_buffer.lua" }, + load_after = { + ["cmp-nvim-lsp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-nvim-lsp"] = { + after = { "cmp-buffer" }, + after_files = { "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp/after/plugin/cmp_nvim_lsp.lua" }, + load_after = { + ["cmp-nvim-lua"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-nvim-lua"] = { + after = { "cmp-nvim-lsp" }, + after_files = { "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lua/after/plugin/cmp_nvim_lua.lua" }, + load_after = { + cmp_luasnip = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp-nvim-lua", + url = "https://github.com/hrsh7th/cmp-nvim-lua" + }, + ["cmp-path"] = { + after_files = { "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp-path/after/plugin/cmp_path.lua" }, + load_after = { + ["cmp-buffer"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + cmp_luasnip = { + after = { "cmp-nvim-lua" }, + after_files = { "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp_luasnip/after/plugin/cmp_luasnip.lua" }, + load_after = { + LuaSnip = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, + extensions = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/extensions", + url = "https://github.com/NvChad/extensions" + }, + ["feline.nvim"] = { + config = { "require('plugins.configs.statusline').setup(false)" }, + load_after = { + ["nvim-web-devicons"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/feline.nvim", + url = "https://github.com/feline-nvim/feline.nvim" + }, + ["filetype.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/filetype.nvim", + url = "https://github.com/nathom/filetype.nvim" + }, + ["friendly-snippets"] = { + after = { "nvim-cmp" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, + ["gitsigns.nvim"] = { + config = { "require('plugins.configs.others').gitsigns(false)" }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/gitsigns.nvim", + url = "https://github.com/lewis6991/gitsigns.nvim" + }, + ["impatient.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/impatient.nvim", + url = "https://github.com/lewis6991/impatient.nvim" + }, + ["indent-blankline.nvim"] = { + config = { "require('plugins.configs.others').blankline(false)" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/indent-blankline.nvim", + url = "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + ["lsp_signature.nvim"] = { + config = { "require('plugins.configs.others').signature(false)" }, + load_after = { + ["nvim-lspconfig"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/lsp_signature.nvim", + url = "https://github.com/ray-x/lsp_signature.nvim" + }, + neogit = { + commands = { "Neogit" }, + config = { "\27LJ\2\ng\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\1K\0\1\0\1\0\2\18disable_signs\2 disable_commit_confirmation\2\nsetup\vneogit\frequire\0" }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/neogit", + url = "https://github.com/TimUntersberger/neogit" + }, + ["neoscroll.nvim"] = { + config = { "\27LJ\2\n7\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\14neoscroll\frequire\0" }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/neoscroll.nvim", + url = "https://github.com/karb94/neoscroll.nvim" + }, + ["null-ls.nvim"] = { + config = { "\27LJ\2\nD\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\27custom.plugins.null-ls\frequire\0" }, + load_after = { + ["nvim-lspconfig"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/null-ls.nvim", + url = "https://github.com/jose-elias-alvarez/null-ls.nvim" + }, + ["nvim-autopairs"] = { + config = { "require('plugins.configs.others').autopairs(false)" }, + load_after = { + ["nvim-cmp"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-autopairs", + url = "https://github.com/windwp/nvim-autopairs" + }, + ["nvim-base16.lua"] = { + after = { "nvim-web-devicons" }, + config = { "\27LJ\2\n3\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\tinit\vcolors\frequire\0" }, + load_after = { + ["packer.nvim"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-base16.lua", + url = "https://github.com/NvChad/nvim-base16.lua" + }, + ["nvim-cmp"] = { + after = { "nvim-autopairs", "LuaSnip" }, + config = { "require('plugins.configs.cmp').setup(false)" }, + load_after = { + ["friendly-snippets"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-colorizer.lua"] = { + config = { "require('plugins.configs.others').colorizer(false)" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-colorizer.lua", + url = "https://github.com/NvChad/nvim-colorizer.lua" + }, + ["nvim-lsp-installer"] = { + config = { "\27LJ\2\nX\0\1\6\0\4\0\n4\1\0\0\18\4\0\0009\2\0\0\18\5\1\0B\2\3\0016\2\1\0009\2\2\2'\4\3\0B\2\2\1K\0\1\0\31 do User LspAttachBuffers \bcmd\bvim\nsetup\1\1\0\6\0\n\0\0146\0\0\0'\2\1\0B\0\2\0029\1\2\0005\3\6\0005\4\4\0005\5\3\0=\5\5\4=\4\a\3B\1\2\0019\1\b\0003\3\t\0B\1\2\1K\0\1\0\0\20on_server_ready\aui\1\0\0\nicons\1\0\0\1\0\3\19server_pending\b➜\23server_uninstalled\b✗\21server_installed\b✓\rsettings\23nvim-lsp-installer\frequire\0" }, + load_after = { + ["nvim-lspconfig"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-lsp-installer", + url = "https://github.com/williamboman/nvim-lsp-installer" + }, + ["nvim-lspconfig"] = { + after = { "lsp_signature.nvim", "null-ls.nvim", "nvim-lsp-installer" }, + config = { "require('plugins.configs.lspconfig')" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-tree.lua"] = { + commands = { "NvimTreeToggle", "NvimTreeFocus" }, + config = { "require('plugins.configs.nvimtree').setup(true)" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-tree.lua", + url = "https://github.com/kyazdani42/nvim-tree.lua" + }, + ["nvim-treesitter"] = { + config = { "require('plugins.configs.treesitter').setup(true)" }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-web-devicons"] = { + after = { "feline.nvim", "bufferline.nvim" }, + config = { "require('plugins.configs.icons').setup(false)" }, + load_after = { + ["nvim-base16.lua"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons", + url = "https://github.com/kyazdani42/nvim-web-devicons" + }, + ["packer.nvim"] = { + after = { "nvim-base16.lua" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["sqlite.lua"] = { + loaded = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/start/sqlite.lua", + url = "https://github.com/tami5/sqlite.lua" + }, + ["telescope-frecency.nvim"] = { + config = { "\27LJ\2\nM\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\1K\0\1\0\rfrecency\19load_extension\14telescope\frequire\0" }, + load_after = { + ["telescope.nvim"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/telescope-frecency.nvim", + url = "https://github.com/nvim-telescope/telescope-frecency.nvim" + }, + ["telescope-fzf-native.nvim"] = { + config = { "\27LJ\2\n\1\0\0\5\0\t\0\0176\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\6\0005\3\4\0005\4\3\0=\4\5\3=\3\a\2B\0\2\0016\0\0\0'\2\1\0B\0\2\0029\0\b\0'\2\5\0B\0\2\1K\0\1\0\19load_extension\15extensions\1\0\0\bfzf\1\0\0\1\0\4\14case_mode\15smart_case\28override_generic_sorter\2\25override_file_sorter\2\nfuzzy\2\nsetup\14telescope\frequire\0" }, + load_after = { + ["telescope.nvim"] = true + }, + loaded = false, + needs_bufread = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/telescope-fzf-native.nvim", + url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + ["telescope.nvim"] = { + after = { "telescope-frecency.nvim", "telescope-fzf-native.nvim" }, + commands = { "Telescope" }, + config = { "require('plugins.configs.telescope').setup(false)" }, + loaded = false, + needs_bufread = true, + only_cond = false, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["vim-matchup"] = { + after_files = { "/home/tobyv/.local/share/nvim/site/pack/packer/opt/vim-matchup/after/plugin/matchit.vim" }, + loaded = false, + needs_bufread = true, + path = "/home/tobyv/.local/share/nvim/site/pack/packer/opt/vim-matchup", + url = "https://github.com/andymass/vim-matchup" + } +} + +time([[Defining packer_plugins]], false) +local module_lazy_loads = { + ["^Comment"] = "Comment.nvim", + ["^cmp_nvim_lsp"] = "friendly-snippets", + ["^lspconfig"] = "nvim-lspconfig", + ["^telescope"] = "telescope.nvim" +} +local lazy_load_called = {['packer.load'] = true} +local function lazy_load_module(module_name) + local to_load = {} + if lazy_load_called[module_name] then return nil end + lazy_load_called[module_name] = true + for module_pat, plugin_name in pairs(module_lazy_loads) do + if not _G.packer_plugins[plugin_name].loaded and string.match(module_name, module_pat) then + to_load[#to_load + 1] = plugin_name + end + end + + if #to_load > 0 then + require('packer.load')(to_load, {module = module_name}, _G.packer_plugins) + local loaded_mod = package.loaded[module_name] + if loaded_mod then + return function(modname) return loaded_mod end + end + end +end + +if not vim.g.packer_custom_loader_enabled then + table.insert(package.loaders, 1, lazy_load_module) + vim.g.packer_custom_loader_enabled = true +end + +-- Setup for: telescope.nvim +time([[Setup for telescope.nvim]], true) +try_loadstring("\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\14telescope\18core.mappings\frequire\0", "setup", "telescope.nvim") +time([[Setup for telescope.nvim]], false) +-- Setup for: bufferline.nvim +time([[Setup for bufferline.nvim]], true) +try_loadstring("\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\15bufferline\18core.mappings\frequire\0", "setup", "bufferline.nvim") +time([[Setup for bufferline.nvim]], false) +-- Setup for: nvim-tree.lua +time([[Setup for nvim-tree.lua]], true) +try_loadstring("\27LJ\2\n>\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\rnvimtree\18core.mappings\frequire\0", "setup", "nvim-tree.lua") +time([[Setup for nvim-tree.lua]], false) +-- Setup for: gitsigns.nvim +time([[Setup for gitsigns.nvim]], true) +try_loadstring("\27LJ\2\nU\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\1K\0\1\0\18gitsigns.nvim\21packer_lazy_load\15core.utils\frequire\0", "setup", "gitsigns.nvim") +time([[Setup for gitsigns.nvim]], false) +-- Setup for: Comment.nvim +time([[Setup for Comment.nvim]], true) +try_loadstring("\27LJ\2\n=\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\fcomment\18core.mappings\frequire\0", "setup", "Comment.nvim") +time([[Setup for Comment.nvim]], false) +-- Setup for: nvim-lspconfig +time([[Setup for nvim-lspconfig]], true) +try_loadstring("\27LJ\2\nU\0\0\3\0\3\0\0056\0\0\0009\0\1\0'\2\2\0B\0\2\1K\0\1\0006if &ft == \"packer\" | echo \"\" | else | silent! e %\bcmd\bvimx\1\0\4\0\a\0\f6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\0016\0\4\0009\0\5\0003\2\6\0)\3\0\0B\0\3\1K\0\1\0\0\rdefer_fn\bvim\19nvim-lspconfig\21packer_lazy_load\15core.utils\frequire\0", "setup", "nvim-lspconfig") +time([[Setup for nvim-lspconfig]], false) +-- Setup for: vim-matchup +time([[Setup for vim-matchup]], true) +try_loadstring("\27LJ\2\nS\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\1K\0\1\0\16vim-matchup\21packer_lazy_load\15core.utils\frequire\0", "setup", "vim-matchup") +time([[Setup for vim-matchup]], false) +-- Setup for: neoscroll.nvim +time([[Setup for neoscroll.nvim]], true) +try_loadstring("\27LJ\2\nV\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\1K\0\1\0\19neoscroll.nvim\21packer_lazy_load\15core.utils\frequire\0", "setup", "neoscroll.nvim") +time([[Setup for neoscroll.nvim]], false) + +-- Command lazy-loads +time([[Defining lazy-load commands]], true) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file NvimTreeFocus lua require("packer.load")({'nvim-tree.lua'}, { cmd = "NvimTreeFocus", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Telescope lua require("packer.load")({'telescope.nvim'}, { cmd = "Telescope", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file NvimTreeToggle lua require("packer.load")({'nvim-tree.lua'}, { cmd = "NvimTreeToggle", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Neogit lua require("packer.load")({'neogit'}, { cmd = "Neogit", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args>, mods = "<mods>" }, _G.packer_plugins)]]) +time([[Defining lazy-load commands]], false) + +-- Keymap lazy-loads +time([[Defining lazy-load keymaps]], true) +vim.cmd [[noremap <silent> gcc <cmd>lua require("packer.load")({'Comment.nvim'}, { keys = "gcc", prefix = "" }, _G.packer_plugins)<cr>]] +time([[Defining lazy-load keymaps]], false) + +vim.cmd [[augroup packer_load_aucmds]] +vim.cmd [[au!]] + -- Event lazy-loads +time([[Defining lazy-load event autocommands]], true) +vim.cmd [[au InsertCharPre * ++once lua require("packer.load")({'better-escape.nvim'}, { event = "InsertCharPre *" }, _G.packer_plugins)]] +vim.cmd [[au VimEnter * ++once lua require("packer.load")({'packer.nvim'}, { event = "VimEnter *" }, _G.packer_plugins)]] +vim.cmd [[au BufNewFile * ++once lua require("packer.load")({'nvim-treesitter'}, { event = "BufNewFile *" }, _G.packer_plugins)]] +vim.cmd [[au InsertEnter * ++once lua require("packer.load")({'friendly-snippets'}, { event = "InsertEnter *" }, _G.packer_plugins)]] +vim.cmd [[au BufRead * ++once lua require("packer.load")({'indent-blankline.nvim', 'nvim-colorizer.lua', 'nvim-treesitter'}, { event = "BufRead *" }, _G.packer_plugins)]] +time([[Defining lazy-load event autocommands]], false) +vim.cmd("augroup END") +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end diff --git a/alacritty.yml b/alacritty.yml index 212a792..4dbd66f 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -15,340 +15,109 @@ # environment variables. Some entries may override variables # set by alacritty itself. env: -# TERM variable -# -# This value is used to set the `$TERM` environment variable for -# each instance of Alacritty. If it is not present, alacritty will -# check the local terminfo database and use `alacritty` if it is -# available, otherwise `xterm-256color` is used. + # TERM variable + # + # This value is used to set the `$TERM` environment variable for + # each instance of Alacritty. If it is not present, alacritty will + # check the local terminfo database and use `alacritty` if it is + # available, otherwise `xterm-256color` is used. TERM: alacritty -#window: -# Window dimensions (changes require restart) -# -# Number of lines/columns (not pixels) in the terminal. The number of columns -# must be at least `2`, while using a value of `0` for columns and lines will -# fall back to the window manager's recommended size. -#dimensions: -# columns: 0 -# lines: 0 - -# Window position (changes require restart) -# -# Specified in number of pixels. -# If the position is not set, the window manager will handle the placement. -#position: -# x: 0 -# y: 0 - -# Window padding (changes require restart) -# -# Blank space added around the window in pixels. This padding is scaled -# by DPI and the specified value is always added at both opposing sides. -#padding: -# x: 0 -# y: 0 - -# Spread additional padding evenly around the terminal content. -#dynamic_padding: false - -# Window decorations -# -# Values for `decorations`: -# - full: Borders and title bar -# - none: Neither borders nor title bar -# -# Values for `decorations` (macOS only): -# - transparent: Title bar, transparent background and title bar buttons -# - buttonless: Title bar, transparent background and no title bar buttons -#decorations: full +window: + # Window dimensions (changes require restart) + # + # Number of lines/columns (not pixels) in the terminal. The number of columns + # must be at least `2`, while using a value of `0` for columns and lines will + # fall back to the window manager's recommended size. + dimensions: + columns: 120 + lines: 40 -# Background opacity -# -# Window opacity as a floating point number from `0.0` to `1.0`. -# The value `0.0` is completely transparent and `1.0` is opaque. -#opacity: 1.0 + # Spread additional padding evenly around the terminal content. + dynamic_padding: false -# Startup Mode (changes require restart) -# -# Values for `startup_mode`: -# - Windowed -# - Maximized -# - Fullscreen -# -# Values for `startup_mode` (macOS only): -# - SimpleFullscreen -#startup_mode: Windowed + # Window decorations + # + # Values for `decorations`: + # - full: Borders and title bar + # - none: Neither borders nor title bar + # + # Values for `decorations` (macOS only): + # - transparent: Title bar, transparent background and title bar buttons + # - buttonless: Title bar, transparent background and no title bar buttons + decorations: full -# Window title -title: Alacritty + # Background opacity + # + # Window opacity as a floating point number from `0.0` to `1.0`. + # The value `0.0` is completely transparent and `1.0` is opaque. + #opacity: 1.0 -# Allow terminal applications to change Alacritty's window title. -#dynamic_title: true + # Startup Mode (changes require restart) + # + # Values for `startup_mode`: + # - Windowed + # - Maximized + # - Fullscreen + # + # Values for `startup_mode` (macOS only): + # - SimpleFullscreen + startup_mode: Fullscreen -# Window class (Linux/BSD only): -#class: -# Application instance name -#instance: Alacritty -# General application class -#general: Alacritty + # Window title + title: + Alacritty -# GTK theme variant (Linux/BSD only) -# -# Override the variant of the GTK theme. Commonly supported values are `dark` -# and `light`. Set this to `None` to use the default theme variant. -#gtk_theme_variant: None + # Allow terminal applications to change Alacritty's window title. + # dynamic_title: true scrolling: -# Maximum number of lines in the scrollback buffer. -# Specifying '0' will disable scrolling. + # Maximum number of lines in the scrollback buffer. + # Specifying '0' will disable scrolling. history: 10000 -# Scrolling distance multiplier. + # Scrolling distance multiplier. multiplier: 3 # Font configuration font: - # Normal (roman) font face normal: - # Font family - # - # Default: - # - (macOS) Menlo - # - (Linux/BSD) monospace - # - (Windows) Consolas family: FiraCode NF - - # The `style` can be specified to pick a specific face. - #style: Regular - - # Bold font face - #bold: - # Font family - # - # If the bold family is not specified, it will fall back to the - # value specified for the normal font. - #family: monospace - - # The `style` can be specified to pick a specific face. - #style: Bold - - # Italic font face - #italic: - # Font family - # - # If the italic family is not specified, it will fall back to the - # value specified for the normal font. - #family: monospace - - # The `style` can be specified to pick a specific face. - #style: Italic - - # Bold italic font face - #bold_italic: - # Font family - # - # If the bold italic family is not specified, it will fall back to the - # value specified for the normal font. - #family: monospace - - # The `style` can be specified to pick a specific face. - #style: Bold Italic - - # Point size - #size: 11.0 - - # Offset is the extra space around each character. `offset.y` can be thought - # of as modifying the line spacing, and `offset.x` as modifying the letter - # spacing. - #offset: - # x: 0 - # y: 0 - - # Glyph offset determines the locations of the glyphs within their cells with - # the default being at the bottom. Increasing `x` moves the glyph to the - # right, increasing `y` moves the glyph upward. - #glyph_offset: - # x: 0 - # y: 0 - - # Thin stroke font rendering (macOS only) - # - # Thin strokes are suitable for retina displays, but for non-retina screens - # it is recommended to set `use_thin_strokes` to `false`. - #use_thin_strokes: true - -# If `true`, bold text is drawn using the bright color variants. -#draw_bold_text_with_bright_colors: false - -# Colors (Tomorrow Night) -#colors: -# Default colors -#primary: -# background: '#1d1f21' -# foreground: '#c5c8c6' - -# Bright and dim foreground colors -# -# The dimmed foreground color is calculated automatically if it is not -# present. If the bright foreground color is not set, or -# `draw_bold_text_with_bright_colors` is `false`, the normal foreground -# color will be used. -#dim_foreground: '#828482' -#bright_foreground: '#eaeaea' - -# Cursor colors -# -# Colors which should be used to draw the terminal cursor. -# -# Allowed values are CellForeground/CellBackground, which reference the -# affected cell, or hexadecimal colors like #ff00ff. -#cursor: -# text: CellBackground -# cursor: CellForeground - -# Vi mode cursor colors -# -# Colors for the cursor when the vi mode is active. -# -# Allowed values are CellForeground/CellBackground, which reference the -# affected cell, or hexadecimal colors like #ff00ff. -#vi_mode_cursor: -# text: CellBackground -# cursor: CellForeground - -# Search colors -# -# Colors used for the search bar and match highlighting. -#search: -# Allowed values are CellForeground/CellBackground, which reference the -# affected cell, or hexadecimal colors like #ff00ff. -#matches: -# foreground: '#000000' -# background: '#ffffff' -#focused_match: -# foreground: '#ffffff' -# background: '#000000' - -#bar: -# background: '#c5c8c6' -# foreground: '#1d1f21' - -# Keyboard regex hints -#hints: -# First character in the hint label -# -# Allowed values are CellForeground/CellBackground, which reference the -# affected cell, or hexadecimal colors like #ff00ff. -#start: -# foreground: '#1d1f21' -# background: '#e9ff5e' - -# All characters after the first one in the hint label -# -# Allowed values are CellForeground/CellBackground, which reference the -# affected cell, or hexadecimal colors like #ff00ff. -#end: -# foreground: '#e9ff5e' -# background: '#1d1f21' - -# Line indicator -# -# Color used for the indicator displaying the position in history during -# search and vi mode. -# -# By default, these will use the opposing primary color. -#line_indicator: -# foreground: None -# background: None - -# Selection colors -# -# Colors which should be used to draw the selection area. -# -# Allowed values are CellForeground/CellBackground, which reference the -# affected cell, or hexadecimal colors like #ff00ff. -#selection: -# text: CellBackground -# background: CellForeground - -# Normal colors -#normal: -# black: '#1d1f21' -# red: '#cc6666' -# green: '#b5bd68' -# yellow: '#f0c674' -# blue: '#81a2be' -# magenta: '#b294bb' -# cyan: '#8abeb7' -# white: '#c5c8c6' - -# Bright colors -#bright: -# black: '#666666' -# red: '#d54e53' -# green: '#b9ca4a' -# yellow: '#e7c547' -# blue: '#7aa6da' -# magenta: '#c397d8' -# cyan: '#70c0b1' -# white: '#eaeaea' - -# Dim colors -# -# If the dim colors are not set, they will be calculated automatically based -# on the `normal` colors. -#dim: -# black: '#131415' -# red: '#864343' -# green: '#777c44' -# yellow: '#9e824c' -# blue: '#556a7d' -# magenta: '#75617b' -# cyan: '#5b7d78' -# white: '#828482' - -# Indexed Colors -# -# The indexed colors include all colors from 16 to 256. -# When these are not set, they're filled with sensible defaults. -# -# Example: -# `- { index: 16, color: '#ff00ff' }` -# -#indexed_colors: [] - -# Transparent cell backgrounds -# -# Whether or not `window.opacity` applies to all cell backgrounds or only to -# the default background. When set to `true` all cells will be transparent -# regardless of their background color. -#transparent_background_colors: false + style: Regular + bold: + family: FiraCode NF + style: Bold + italic: + family: FiraCode NF + style: Italic + bold_italic: + family: FiraCode NF + style: Bold Italic # Bell # # The bell is rung every time the BEL control character is received. -#bell: -# Visual Bell Animation -# -# Animation effect for flashing the screen when the visual bell is rung. -# -# Values for `animation`: -# - Ease -# - EaseOut -# - EaseOutSine -# - EaseOutQuad -# - EaseOutCubic -# - EaseOutQuart -# - EaseOutQuint -# - EaseOutExpo -# - EaseOutCirc -# - Linear -#animation: EaseOutExpo - -# Duration of the visual bell flash in milliseconds. A `duration` of `0` will -# disable the visual bell animation. -duration: 100 +bell: + # Visual Bell Animation + # + # Animation effect for flashing the screen when the visual bell is rung. + # + # Values for `animation`: + # - Ease + # - EaseOut + # - EaseOutSine + # - EaseOutQuad + # - EaseOutCubic + # - EaseOutQuart + # - EaseOutQuint + # - EaseOutExpo + # - EaseOutCirc + # - Linear + animation: EaseOutExpo + + # Duration of the visual bell flash in milliseconds. A `duration` of `0` will + # disable the visual bell animation. + duration: 100 # Visual bell animation color. #color: '#ffffff' @@ -367,54 +136,25 @@ duration: 100 #command: None selection: -# This string contains all characters that are used as separators for -# "semantic words" in Alacritty. -#semantic_escape_chars: ",│`|:\"' ()[]{}<>\t" + # This string contains all characters that are used as separators for + # "semantic words" in Alacritty. + semantic_escape_chars: ",│`|:\"' ()[]{}<>\t" -# When set to `true`, selected text will be copied to the primary clipboard. + # When set to `true`, selected text will be copied to the primary clipboard. save_to_clipboard: false -#cursor: -# Cursor style -#style: -# Cursor shape -# -# Values for `shape`: -# - ▇ Block -# - _ Underline -# - | Beam -#shape: Block - -# Cursor blinking state -# -# Values for `blinking`: -# - Never: Prevent the cursor from ever blinking -# - Off: Disable blinking by default -# - On: Enable blinking by default -# - Always: Force the cursor to always blink -#blinking: Off - -# Vi mode cursor style -# -# If the vi mode cursor style is `None` or not specified, it will fall back to -# the style of the active value of the normal cursor. -# -# See `cursor.style` for available options. -#vi_mode_style: None - -# Cursor blinking interval in milliseconds. -#blink_interval: 750 - -# If this is `true`, the cursor will be rendered as a hollow box when the -# window is not focused. -#unfocused_hollow: true - -# Thickness of the cursor relative to the cell width as floating point number -# from `0.0` to `1.0`. -#thickness: 0.15 +cursor: + # Cursor blinking state + # + # Values for `blinking`: + # - Never: Prevent the cursor from ever blinking + # - Off: Disable blinking by default + # - On: Enable blinking by default + # - Always: Force the cursor to always blink + blinking: On # Live config reload (changes require restart) -#live_config_reload: true +live_config_reload: true # Shell # @@ -428,6 +168,9 @@ selection: # - (Windows) powershell shell: program: C:\WINDOWS\system32\wsl.exe + args: + - -e + - '/bin/zsh -lc "tmux new -As main"' # Startup directory # @@ -435,68 +178,6 @@ shell: # directory of the parent process will be used. working_directory: '\\wsl$\Debian\home\tobyv' -# Send ESC (\x1b) before characters when alt is pressed. -#alt_send_esc: true - -# Offer IPC using `alacritty msg` (unix only) -#ipc_socket: true - -#mouse: -# Click settings -# -# The `double_click` and `triple_click` settings control the time -# alacritty should wait for accepting multiple clicks as one double -# or triple click. -#double_click: { threshold: 300 } -#triple_click: { threshold: 300 } - -# If this is `true`, the cursor is temporarily hidden when typing. -#hide_when_typing: false - -# Regex hints -# -# Terminal hints can be used to find text in the visible part of the terminal -# and pipe it to other applications. -#hints: -# Keys used for the hint labels. -#alphabet: "jfkdls;ahgurieowpq" - -# List with all available hints -# -# Each hint must have a `regex` and either an `action` or a `command` field. -# The fields `mouse`, `binding` and `post_processing` are optional. -# -# The fields `command`, `binding.key`, `binding.mods`, `binding.mode` and -# `mouse.mods` accept the same values as they do in the `key_bindings` section. -# -# The `mouse.enabled` field controls if the hint should be underlined while -# the mouse with all `mouse.mods` keys held or the vi mode cursor is above it. -# -# If the `post_processing` field is set to `true`, heuristics will be used to -# shorten the match if there are characters likely not to be part of the hint -# (e.g. a trailing `.`). This is most useful for URIs. -# -# Values for `action`: -# - Copy -# Copy the hint's text to the clipboard. -# - Paste -# Paste the hint's text to the terminal or search. -# - Select -# Select the hint's text. -# - MoveViModeCursor -# Move the vi mode cursor to the beginning of the hint. -#enabled: -# - regex: "(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)\ -# [^\u0000-\u001F\u007F-\u009F<>\"\\s{-}\\^⟨⟩`]+" -# command: xdg-open -# post_processing: true -# mouse: -# enabled: true -# mods: None -# binding: -# key: U -# mods: Control|Shift - # Mouse bindings # # Mouse bindings are specified as a list of objects, much like the key @@ -811,7 +492,7 @@ key_bindings: # (Windows, Linux, and BSD only) #- { key: V, mods: Control|Shift, mode: ~Vi, action: Paste } #- { key: C, mods: Control|Shift, action: Copy } - #- { key: F, mods: Control|Shift, mode: ~Search, action: SearchForward } + - { key: F, mods: Control|Shift, mode: ~Search, action: ReceiveChar } #- { key: B, mods: Control|Shift, mode: ~Search, action: SearchBackward } #- { key: C, mods: Control|Shift, mode: Vi|~Search, action: ClearSelection } #- { key: Insert, mods: Shift, action: PasteSelection } diff --git a/bash/aliases.sh b/bash/aliases.sh index 657e909..0ed360a 100644 --- a/bash/aliases.sh +++ b/bash/aliases.sh @@ -10,6 +10,7 @@ alias grep='grep --color' alias ipa="ip -s -c -h a" alias untar="tar -zxvf" alias td=". td.sh" +alias vim=nvim # scripts alias dfi=~/dotfiles/install alias dfu=~/dotfiles/update diff --git a/bash/env.sh b/bash/env.sh index 6424fd9..3bc6dbd 100644 --- a/bash/env.sh +++ b/bash/env.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash export EDITOR="$(command -v vim 2>/dev/null || command -v vi)" -export TERM=alacritty export VISUAL="code --wait" export GPG_TTY=$(tty) export MANPAGER="sh -c 'col -bx | bat -l man -p'" @@ -17,7 +16,3 @@ export PATH=$PATH:$HOME/.dotnet/tools export PATH=$PATH:$HOME/.cargo/bin export PATH=$PATH:$HOME/dotfiles/scripts export PATH=$PATH:/usr/local/texlive/2021/bin/x86_64-linux - -if command -v tmux &>/dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then - exec tmux -fi @@ -80,3 +80,8 @@ smrm = "!f(){ git rm --cached \"$1\";rm -r \"$1\";git config -f .gitmodules --re ignore = "!f() { IFS=\",\"; curl -L -s \"https://www.toptal.com/developers/gitignore/api/$*\" ;}; f" attributes = "!f() { curl -sL https://gist.githubusercontent.com/tobyvin/70f3671c76016063594ea45edbb97094/raw ;}; f" license = "!f() { curl -sH 'Accept: application/vnd.github.v3+json' https://api.github.com/licenses/$1 | grep -oP '.*\"body\":\\s*\"\\K.*(?=\\s*\",)' | tr '\\n' '\\0' | xargs -0 printf '%b\\n' | sed \"s/\\[year\\]/$(date +'%Y')/\" | sed \"s/\\[fullname\\]/$(git config --get user.name)/\"; }; f" +[filter "lfs"] + clean = git-lfs clean -- %f + smudge = git-lfs smudge -- %f + process = git-lfs filter-process + required = true diff --git a/nvim/ftplugin/json.vim b/nvim/ftplugin/json.vim deleted file mode 100644 index 4533aea..0000000 --- a/nvim/ftplugin/json.vim +++ /dev/null @@ -1,5 +0,0 @@ -nnoremap <left> :lua require("jvim").to_parent()<CR> -nnoremap <right> :lua require("jvim").descend()<CR> -nnoremap <up> :lua require("jvim").prev_sibling()<CR> -nnoremap <down> :lua require("jvim").next_sibling()<CR> - diff --git a/nvim/lua/theprimeagen/debugger.lua b/nvim/lua/theprimeagen/debugger.lua deleted file mode 100644 index c935273..0000000 --- a/nvim/lua/theprimeagen/debugger.lua +++ /dev/null @@ -1,19 +0,0 @@ -local dap_install = require("dap-install") -dap_install.config("chrome", {}) - - -local dap = require("dap"); -dap.configurations.typescriptreact = { -- change to typescript if needed - { - type = "chrome", - request = "attach", - program = "${file}", - cwd = vim.fn.getcwd(), - sourceMaps = true, - protocol = "inspector", - port = 9222, - webRoot = "${workspaceFolder}" - } -} - -require('dap.ext.vscode').load_launchjs() diff --git a/nvim/lua/theprimeagen/git-worktree.lua b/nvim/lua/theprimeagen/git-worktree.lua deleted file mode 100644 index 7c3bce9..0000000 --- a/nvim/lua/theprimeagen/git-worktree.lua +++ /dev/null @@ -1,29 +0,0 @@ -local Worktree = require("git-worktree") - -local function is_nrdp(path) - local found = path:find(vim.env["NRDP"]) - return type(found) == "number" and found > 0 -end - -local function is_tvui(path) - local found = path:find(vim.env["TVUI"]) - return type(found) == "number" and found > 0 -end - -local M = {} -function M.execute(path, just_build) - if is_nrdp(path) then - local command = string.format(":silent !tmux-nrdp tmux %s %s", path, just_build) - vim.cmd(command) - elseif is_tvui(path) then - print("EXECUTE ", path) - local command = string.format(":!tmux-tvui %s", path) - vim.cmd(command) - end -end - -Worktree.on_tree_change(function(_ --[[op]], path, _ --[[upstream]]) - M.execute(path.path) -end) - -return M diff --git a/nvim/lua/theprimeagen/harpoon.lua b/nvim/lua/theprimeagen/harpoon.lua deleted file mode 100644 index 4f1543e..0000000 --- a/nvim/lua/theprimeagen/harpoon.lua +++ /dev/null @@ -1,13 +0,0 @@ -require("harpoon").setup({ - nav_first_in_list = true, - projects = { - ["/home/theprimeagen/work/nrdp/backport-2"] = { - term = { - cmds = { - "ninja -C /home/theprimeagen/work/nrdp/builds/backport-2 -j 25 && cp compile_commands.json /home/theprimeagen/work/nrdp/backport-2\n", - } - } - } - } -}) - diff --git a/nvim/lua/theprimeagen/init.lua b/nvim/lua/theprimeagen/init.lua deleted file mode 100644 index 5db4e28..0000000 --- a/nvim/lua/theprimeagen/init.lua +++ /dev/null @@ -1,19 +0,0 @@ -require("theprimeagen.telescope") -require("theprimeagen.git-worktree") -require("theprimeagen.debugger") -require("theprimeagen.harpoon") -require("theprimeagen.lsp") - -P = function(v) - print(vim.inspect(v)) - return v -end - -if pcall(require, "plenary") then - RELOAD = require("plenary.reload").reload_module - - R = function(name) - RELOAD(name) - return require(name) - end -end diff --git a/nvim/lua/theprimeagen/lsp.lua b/nvim/lua/theprimeagen/lsp.lua deleted file mode 100644 index 3911c72..0000000 --- a/nvim/lua/theprimeagen/lsp.lua +++ /dev/null @@ -1,191 +0,0 @@ -local sumneko_root_path = "/home/mpaulson/personal/lua-language-server" -local sumneko_binary = sumneko_root_path .. "/bin/lua-language-server" - -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true - --- Setup nvim-cmp. -local cmp = require("cmp") -local source_mapping = { - buffer = "[Buffer]", - nvim_lsp = "[LSP]", - nvim_lua = "[Lua]", - path = "[Path]" -} -local lspkind = require("lspkind") -require("lspkind").init({ - mode = 'Text' -}) - -cmp.setup({ - snippet = { - expand = function(args) - -- For `vsnip` user. - -- vim.fn["vsnip#anonymous"](args.body) - - -- For `luasnip` user. - require("luasnip").lsp_expand(args.body) - - -- For `ultisnips` user. - -- vim.fn["UltiSnips#Anon"](args.body) - end - }, - mapping = { - ["<C-u>"] = cmp.mapping.scroll_docs(-4), - ["<C-d>"] = cmp.mapping.scroll_docs(4), - ["<C-Space>"] = cmp.mapping.complete() - }, - - formatting = { - format = function(entry, vim_item) - vim_item.kind = lspkind.presets.default[vim_item.kind] - local menu = source_mapping[entry.source.name] - vim_item.menu = menu - return vim_item - end - }, - - sources = {{ - name = "nvim_lsp" - }, -- For vsnip user. - -- { name = 'vsnip' }, - -- For luasnip user. - { - name = "luasnip" - }, -- For ultisnips user. - -- { name = 'ultisnips' }, - { - name = "buffer" - }} -}) - -local function config(_config) - return vim.tbl_deep_extend("force", { - capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) - }, _config or {}) -end - -require("lspconfig").tsserver.setup(config()) - ---[[ I cannot seem to get this woring on new computer.. -require("lspconfig").clangd.setup(config({ - cmd = { "clangd", "--background-index", "--log=verbose" }, - root_dir = function() - print("clangd-Rootdir", vim.loop.cwd()) - return vim.loop.cwd() - end, -})) ---]] -require("lspconfig").ccls.setup(config()) - -require("lspconfig").jedi_language_server.setup(config()) - -require("lspconfig").svelte.setup(config()) - -require("lspconfig").solang.setup(config()) - -require("lspconfig").cssls.setup(config()) - -require("lspconfig").gopls.setup(config({ - cmd = {"gopls", "serve"}, - settings = { - gopls = { - analyses = { - unusedparams = true - }, - staticcheck = true - } - } -})) - -require('rust-tools').setup(config({ - tools = { - autoSetHints = true, - hover_with_actions = true, - runnables = { - use_telescope = true - }, - inlay_hints = { - show_parameter_hints = false, - parameter_hints_prefix = "", - other_hints_prefix = "" - } - }, - - -- all the opts to send to nvim-lspconfig - -- these override the defaults set by rust-tools.nvim - -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer - server = { - -- on_attach is a callback called when the language server attachs to the buffer - -- on_attach = on_attach, - settings = { - -- to enable rust-analyzer settings visit: - -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc - ["rust-analyzer"] = { - -- enable clippy on save - checkOnSave = { - command = "clippy" - } - } - } - } -})) - -require("lspconfig").sumneko_lua.setup(config({ - cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, - settings = { - 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"} - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true - } - } - } - } -})) - -local opts = { - -- whether to highlight the currently hovered symbol - -- disable if your cpu usage is higher than you want it - -- or you just hate the highlight - -- default: true - highlight_hovered_item = true, - - -- whether to show outline guides - -- default: true - show_guides = true -} - -require("symbols-outline").setup(opts) - -local snippets_paths = function() - local plugins = {"friendly-snippets"} - local paths = {} - local path - local root_path = vim.env.HOME .. "/.vim/plugged/" - for _, plug in ipairs(plugins) do - path = root_path .. plug - if vim.fn.isdirectory(path) ~= 0 then - table.insert(paths, path) - end - end - return paths -end - -require("luasnip.loaders.from_vscode").lazy_load({ - paths = snippets_paths(), - include = nil, -- Load all languages - exclude = {} -}) diff --git a/nvim/lua/theprimeagen/telescope.lua b/nvim/lua/theprimeagen/telescope.lua deleted file mode 100644 index 2be6bbb..0000000 --- a/nvim/lua/theprimeagen/telescope.lua +++ /dev/null @@ -1,222 +0,0 @@ -local pickers = require("telescope.pickers") -local finders = require("telescope.finders") -local previewers = require("telescope.previewers") -local action_state = require("telescope.actions.state") -local conf = require("telescope.config").values -local actions = require("telescope.actions") - -require("telescope").setup({ - defaults = { - file_sorter = require("telescope.sorters").get_fzy_sorter, - prompt_prefix = " >", - color_devicons = true, - - 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, - - mappings = { - i = { - ["<C-x>"] = false, - ["<C-q>"] = actions.send_to_qflist, - }, - }, - }, - extensions = { - fzy_native = { - override_generic_sorter = false, - override_file_sorter = true, - }, - }, -}) - -require("telescope").load_extension("git_worktree") -require("telescope").load_extension("fzy_native") - -local M = {} - -function M.reload_modules() - -- Because TJ gave it to me. Makes me happpy. Put it next to his other - -- awesome things. - local lua_dirs = vim.fn.glob("./lua/*", 0, 1) - for _, dir in ipairs(lua_dirs) do - dir = string.gsub(dir, "./lua/", "") - require("plenary.reload").reload_module(dir) - end -end - -M.search_dotfiles = function() - require("telescope.builtin").find_files({ - prompt_title = "< VimRC >", - cwd = vim.env.DOTFILES, - hidden = true, - }) -end - -local function set_background(content) - vim.fn.system("dconf write /org/mate/desktop/background/picture-filename \"'" .. content .. "'\"") -end - -local function select_background(prompt_bufnr, map) - local function set_the_background(close) - local content = require("telescope.actions.state").get_selected_entry(prompt_bufnr) - set_background(content.cwd .. "/" .. content.value) - if close then - require("telescope.actions").close(prompt_bufnr) - end - end - - map("i", "<C-p>", function() - set_the_background() - end) - - map("i", "<CR>", function() - set_the_background(true) - end) -end - -local function image_selector(prompt, cwd) - return function() - require("telescope.builtin").find_files({ - prompt_title = prompt, - cwd = cwd, - - attach_mappings = function(prompt_bufnr, map) - select_background(prompt_bufnr, map) - - -- Please continue mapping (attaching additional key maps): - -- Ctrl+n/p to move up and down the list. - return true - end, - }) - end -end - -M.anime_selector = image_selector("< Anime Bobs > ", "~/personal/anime") - -local function refactor(prompt_bufnr) - local content = require("telescope.actions.state").get_selected_entry(prompt_bufnr) - require("telescope.actions").close(prompt_bufnr) - require("refactoring").refactor(content.value) -end - -M.refactors = function() - require("telescope.pickers").new({}, { - prompt_title = "refactors", - finder = require("telescope.finders").new_table({ - results = require("refactoring").get_refactors(), - }), - sorter = require("telescope.config").values.generic_sorter({}), - attach_mappings = function(_, map) - map("i", "<CR>", refactor) - map("n", "<CR>", refactor) - return true - end, - }):find() -end - -M.git_branches = function() - require("telescope.builtin").git_branches({ - attach_mappings = function(_, map) - map("i", "<c-d>", actions.git_delete_branch) - map("n", "<c-d>", actions.git_delete_branch) - return true - end, - }) -end - -M.dev = function(opts) - opts = opts or {} - - opts.cwd = opts.cwd or vim.loop.fs_realpath(vim.loop.cwd()) - print("HEY BAE", opts.cwd) - - local possible_files = vim.api.nvim_get_runtime_file("/lua/**/dev.lua", true) - local local_files = {} - for _, raw_f in ipairs(possible_files) do - local real_f = vim.loop.fs_realpath(raw_f) - - if string.find(real_f, opts.cwd, 1, true) then - table.insert(local_files, real_f) - end - end - - local dev = local_files[1] - local loaded = loadfile(dev) - local ok, mod = pcall(loaded) - if not ok then - print("===================================================") - print("HEY PRIME. YOUR CODE DOESNT WORK. THIS IS NOT ON ME") - print("===================================================") - return - end - - -- P(mod) - local objs = {} - for k, v in pairs(mod) do - local debug_info = debug.getinfo(v) - table.insert(objs, { - filename = string.sub(debug_info.source, 2), - text = k, - }) - end - - local mod_name = vim.split(dev, "/lua/") - if #mod_name ~= 2 then - print("===================================================") - print("HEY PRIME. I DO NOT KNOW HOW TO FIND THIS FILE:") - print(dev) - print("===================================================") - end - mod_name = string.gsub(mod_name[2], ".lua$", "") - mod_name = string.gsub(mod_name, "/", ".") - - pickers.new({ - finder = finders.new_table({ - results = objs, - entry_maker = function(entry) - return { - value = entry, - text = entry.text, - display = entry.text, - ordinal = entry.text, - filename = entry.filename, - } - end, - }), - sorter = conf.generic_sorter(opts), - previewer = previewers.builtin.new(opts), - attach_mappings = function(_, map) - actions.select_default:replace(function(...) - -- print("SELECTED", vim.inspect(action_state.get_selected_entry())) - local entry = action_state.get_selected_entry() - actions.close(...) - - mod[entry.value.text]() - end) - - map("i", "<tab>", function(...) - local entry = action_state.get_selected_entry() - actions.close(...) - - vim.schedule(function() - -- vim.cmd(string.format([[normal!]], entry.value.text)) - vim.api.nvim_feedkeys( - vim.api.nvim_replace_termcodes( - string.format("<esc>:lua require('%s').%s()", mod_name, entry.value.text), - true, - false, - true - ), - "n", - true - ) - end) - end) - - return true - end, - }):find() -end - -return M diff --git a/nvim/plugin/colors.vim b/nvim/plugin/colors.vim deleted file mode 100644 index d200e2a..0000000 --- a/nvim/plugin/colors.vim +++ /dev/null @@ -1,33 +0,0 @@ -let g:theprimeagen_colorscheme = "gruvbox" -fun! ColorMyPencils() - let g:gruvbox_contrast_dark = 'hard' - if exists('+termguicolors') - let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" - let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" - endif - let g:gruvbox_invert_selection='0' - - set background=dark - if has('nvim') - call luaeval('vim.cmd("colorscheme " .. _A[1])', [g:theprimeagen_colorscheme]) - else - " TODO: What the way to use g:theprimeagen_colorscheme - colorscheme gruvbox - endif - - highlight ColorColumn ctermbg=0 guibg=grey - hi SignColumn guibg=none - hi CursorLineNR guibg=None - highlight Normal guibg=none - " highlight LineNr guifg=#ff8659 - " highlight LineNr guifg=#aed75f - highlight LineNr guifg=#5eacd3 - highlight netrwDir guifg=#5eacd3 - highlight qfFileName guifg=#aed75f - hi TelescopeBorder guifg=#5eacd -endfun -call ColorMyPencils() - -" Vim with me -nnoremap <leader>cmp :call ColorMyPencils()<CR> -nnoremap <leader>vwb :let g:theprimeagen_colorscheme = diff --git a/nvim/plugin/harpoon.vim b/nvim/plugin/harpoon.vim deleted file mode 100644 index 46c3a31..0000000 --- a/nvim/plugin/harpoon.vim +++ /dev/null @@ -1,19 +0,0 @@ -lua require("theprimeagen") - -" Terminal commands -" ueoa is first through fourth finger left hand home row. -" This just means I can crush, with opposite hand, the 4 terminal positions -" -" These functions are stored in harpoon. A plugn that I am developing -nnoremap <silent><leader>a :lua require("harpoon.mark").add_file()<CR> -nnoremap <silent><C-e> :lua require("harpoon.ui").toggle_quick_menu()<CR> -nnoremap <silent><leader>tc :lua require("harpoon.cmd-ui").toggle_quick_menu()<CR> - -nnoremap <silent><C-h> :lua require("harpoon.ui").nav_file(1)<CR> -nnoremap <silent><C-t> :lua require("harpoon.ui").nav_file(2)<CR> -nnoremap <silent><C-n> :lua require("harpoon.ui").nav_file(3)<CR> -nnoremap <silent><C-s> :lua require("harpoon.ui").nav_file(4)<CR> -nnoremap <silent><leader>tu :lua require("harpoon.term").gotoTerminal(1)<CR> -nnoremap <silent><leader>te :lua require("harpoon.term").gotoTerminal(2)<CR> -nnoremap <silent><leader>cu :lua require("harpoon.term").sendCommand(1, 1)<CR> -nnoremap <silent><leader>ce :lua require("harpoon.term").sendCommand(1, 2)<CR> diff --git a/nvim/plugin/lsp.vim b/nvim/plugin/lsp.vim deleted file mode 100644 index 2d4672d..0000000 --- a/nvim/plugin/lsp.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Do this in lua?? maybe... -" vim.o is short for something teej thinks makes sense. -set completeopt=menu,menuone,noselect -let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy'] - -fun! LspLocationList() - " lua vim.lsp.diagnostic.set_loclist({open_loclist = false}) -endfun - -nnoremap <leader>vd :lua vim.lsp.buf.definition()<CR> -nnoremap <leader>vi :lua vim.lsp.buf.implementation()<CR> -nnoremap <leader>vsh :lua vim.lsp.buf.signature_help()<CR> -nnoremap <leader>vrr :lua vim.lsp.buf.references()<CR> -nnoremap <leader>vrn :lua vim.lsp.buf.rename()<CR> -nnoremap <leader>vh :lua vim.lsp.buf.hover()<CR> -nnoremap <leader>vca :lua vim.lsp.buf.code_action()<CR> -nnoremap <leader>vsd :lua vim.lsp.diagnostic.show_line_diagnostics(); vim.lsp.util.show_line_diagnostics()<CR> -nnoremap <leader>vn :lua vim.lsp.diagnostic.goto_next()<CR> -nnoremap <leader>vll :call LspLocationList()<CR> - -augroup THE_PRIMEAGEN_LSP - autocmd! - autocmd! BufWrite,BufEnter,InsertLeave * :call LspLocationList() -augroup END diff --git a/nvim/plugin/netrw.vim b/nvim/plugin/netrw.vim deleted file mode 100644 index 7988327..0000000 --- a/nvim/plugin/netrw.vim +++ /dev/null @@ -1,4 +0,0 @@ -let g:netrw_browse_split = 0 -let g:netrw_banner = 0 -let g:netrw_winsize = 25 - diff --git a/nvim/plugin/plenary.vim b/nvim/plugin/plenary.vim deleted file mode 100644 index c282c9a..0000000 --- a/nvim/plugin/plenary.vim +++ /dev/null @@ -1,2 +0,0 @@ -nmap <leader>tt <Plug>PlenaryTestFile - diff --git a/nvim/plugin/refactoring.vim b/nvim/plugin/refactoring.vim deleted file mode 100644 index 78f3756..0000000 --- a/nvim/plugin/refactoring.vim +++ /dev/null @@ -1,9 +0,0 @@ -lua require("theprimeagen") - -lua require("refactoring").setup({}) - -vnoremap <silent> <leader>rr :lua require("theprimeagen.telescope").refactors()<CR> -nnoremap <silent> <leader>rr :lua require("theprimeagen.telescope").refactors()<CR> -nnoremap <silent> <leader>df :lua require("refactoring").debug.printf({below = false})<CR> -nnoremap <silent> <leader>db :lua require("refactoring").debug.printf({below = true})<CR> - diff --git a/nvim/init.vim b/nvim_WIP/init.vim index 643814f..8e708cc 100644 --- a/nvim/init.vim +++ b/nvim_WIP/init.vim @@ -13,6 +13,24 @@ set wildignore+=**/android/* set wildignore+=**/ios/* set wildignore+=**/.git/* +local fn = vim.fn +local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +if fn.empty(fn.glob(install_path)) > 0 then + packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) +end + +return require('packer').startup(function(use) + -- My plugins here + -- use 'foo1/bar1.nvim' + -- use 'foo2/bar2.nvim' + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if packer_bootstrap then + require('packer').sync() + end +end) + call plug#begin('~/.vim/plugged') " Yes, I am a sneaky snek now @@ -23,7 +41,9 @@ Plug 'neovim/nvim-lspconfig' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/nvim-cmp' +Plug 'tzachar/cmp-tabnine', { 'do': './install.sh' } Plug 'onsails/lspkind-nvim' +Plug 'github/copilot.vim' Plug 'nvim-lua/lsp_extensions.nvim' " Plug 'nvim-lua/completion-nvim' @@ -45,7 +65,7 @@ Plug 'szw/vim-maximizer' Plug 'L3MON4D3/LuaSnip' Plug 'rafamadriz/friendly-snippets' -Plug 'simrat39/rust-tools.nvim' +Plug 'rust-lang/rust.vim' Plug 'darrikonn/vim-gofmt' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-rhubarb' @@ -53,12 +73,12 @@ Plug 'junegunn/gv.vim' Plug 'vim-utils/vim-man' Plug 'mbbill/undotree' Plug 'tpope/vim-dispatch' +Plug 'theprimeagen/vim-be-good' Plug 'gruvbox-community/gruvbox' Plug 'luisiacc/gruvbox-baby' Plug 'tpope/vim-projectionist' Plug 'tomlion/vim-solidity' - " telescope requirements... Plug 'nvim-lua/popup.nvim' Plug 'nvim-lua/plenary.nvim' @@ -75,13 +95,6 @@ Plug 'mhinz/vim-rfc' " prettier Plug 'sbdchd/neoformat' -" ThePrimeagen plugins -Plug 'theprimeagen/vim-be-good' -Plug 'ThePrimeagen/harpoon' -Plug 'ThePrimeagen/git-worktree.nvim' -Plug 'ThePrimeagen/refactoring.nvim' -Plug 'ThePrimeagen/jvim.nvim' - " should I try another status bar??? " Plug 'glepnir/galaxyline.nvim' , {'branch': 'main'} " Plug 'hoob3rt/lualine.nvim' @@ -92,8 +105,6 @@ call plug#end() lua require("theprimeagen") lua require'nvim-treesitter.configs'.setup { highlight = { enable = true }, incremental_selection = { enable = true }, textobjects = { enable = true }} -let g:vim_be_good_log_file = 1 -let g:vim_apm_log = 1 if executable('rg') let g:rg_derive_root='true' @@ -102,78 +113,36 @@ endif let loaded_matchparen = 1 let mapleader = " " -imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>' -inoremap <silent> <S-Tab> <cmd>lua require'luasnip'.jump(-1)<Cr> - -snoremap <silent> <Tab> <cmd>lua require('luasnip').jump(1)<Cr> -snoremap <silent> <S-Tab> <cmd>lua require('luasnip').jump(-1)<Cr> - -imap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>' -smap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>' - nnoremap <silent> Q <nop> nnoremap <silent> <C-f> :silent !tmux neww tmux-sessionizer<CR> -" Probably rename this, because its straight silly to be a worktree. -nnoremap <leader>; :lua require("theprimeagen.git-worktree").execute(vim.loop.cwd(), "just-build")<CR> - -nnoremap <leader>vwh :h <C-R>=expand("<cword>")<CR><CR> -nnoremap <leader>bs /<C-R>=escape(expand("<cWORD>"), "/")<CR><CR> nnoremap <leader>u :UndotreeShow<CR> -nnoremap <leader>pv :Ex<CR> -nnoremap <Leader><CR> :so ~/.config/nvim/init.vim<CR> -nnoremap <Leader>+ :vertical resize +5<CR> -nnoremap <Leader>- :vertical resize -5<CR> -nnoremap <Leader>rp :resize 100<CR> -nnoremap <Leader>ee oif err != nil {<CR>log.Fatalf("%+v\n", err)<CR>}<CR><esc>kkI<esc> -nnoremap <Leader>cpu a%" PRIu64 "<esc> -nnoremap <leader>s :%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left> -nnoremap <leader>gt <Plug>PlenaryTestFile -nnoremap <leader>vwm :lua require("vim-with-me").init()<CR> -nnoremap <leader>dwm :lua require("vim-with-me").disconnect()<CR> -nnoremap <leader>gll :let g:_search_term = expand("%")<CR><bar>:Gclog -- %<CR>:call search(g:_search_term)<CR> -nnoremap <leader>gln :cnext<CR>:call search(_search_term)<CR> -nnoremap <leader>glp :cprev<CR>:call search(_search_term)<CR> -nnoremap <leader>nf :!./scripts/format.py % - -nnoremap <leader>x :silent !chmod +x %<CR> - -vnoremap J :m '>+1<CR>gv=gv -vnoremap K :m '<-2<CR>gv=gv - -nnoremap Y yg$ -nnoremap n nzzzv -nnoremap N Nzzzv -nnoremap J mzJ`z - -" greatest remap ever -xnoremap <leader>p "_dP - -" next greatest remap ever : asbjornHaland -nnoremap <leader>y "+y -vnoremap <leader>y "+y -nmap <leader>Y "+Y - -nnoremap <leader>d "_d -vnoremap <leader>d "_d - -" vim TODO -nmap <Leader>tu <Plug>BujoChecknormal -nmap <Leader>th <Plug>BujoAddnormal -let g:bujo#todo_file_path = $HOME . "/.cache/bujo" - -nnoremap <Leader>ww ofunction wait(ms: number): Promise<void> {<CR>return new Promise(res => setTimeout(res, ms));<CR>}<esc>k=i{<CR> - -inoremap <C-c> <esc> +nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR> +nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR> +nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR> +nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR> +nnoremap <silent> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR> +nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR> +nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR> +nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR> +nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR> +nnoremap <silent> ga <cmd>lua vim.lsp.buf.code_action()<CR> + +" have a fixed column for the diagnostics to appear in +" this removes the jitter when warnings/errors flow in +set signcolumn=yes + +" Set updatetime for CursorHold +" 300ms of no cursor movement to trigger CursorHold +set updatetime=300 +" Show diagnostic popup on cursor hover +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) + +" Goto previous/next diagnostic warning/error +nnoremap <silent> g[ <cmd>lua vim.diagnostic.goto_prev()<CR> +nnoremap <silent> g] <cmd>lua vim.diagnostic.goto_next()<CR> -fun! EmptyRegisters() - let regs=split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"', '\zs') - for r in regs - call setreg(r, []) - endfor -endfun -" ES -com! W w +inoremap <C-c> <esc> nmap <leader>nn :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" @@ -190,3 +159,8 @@ augroup THE_PRIMEAGEN autocmd BufWritePre * %s/\s\+$//e autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints{} augroup END + +augroup fmt + autocmd! + autocmd BufWritePre * undojoin | Neoformat +augroup END
\ No newline at end of file diff --git a/nvim_WIP/lua/config/bufferline.lua b/nvim_WIP/lua/config/bufferline.lua new file mode 100644 index 0000000..a3f5877 --- /dev/null +++ b/nvim_WIP/lua/config/bufferline.lua @@ -0,0 +1,104 @@ +local map = require('config.utils').map +local bufferline = require 'bufferline' + +local bar_bg = '#1f1f1f' +local bar_fg = '#c9c9c9' +local elem_bg = '#2d2d2d' +local elem_fg = '#8c8c8c' +local selected_bg = '#444444' +local selected_fg = '#efefef' +local error_fg = '#ca241a' +local warning_fg = '#fabd2f' +local info_fg = '#83a5cb' +local pick_fg = '#870000' + +local colors = { + bar = { guifg = bar_fg, guibg = bar_bg }, + elem = { guifg = elem_fg, guibg = elem_bg }, + elem_inactive = { guifg = elem_fg, guibg = elem_bg }, + elem_selected = { guifg = selected_fg, guibg = selected_bg }, + separator = { guifg = bar_bg, guibg = elem_bg }, + separator_selected = { guifg = bar_bg, guibg = selected_bg }, + error = { guifg = error_fg, guibg = elem_bg, guisp = error_fg }, + error_selected = { guifg = error_fg, guibg = selected_bg, gui = '' }, + warning = { guifg = warning_fg, guibg = elem_bg, guisp = warning_fg }, + warning_selected = { guifg = warning_fg, guibg = selected_bg, gui = '' }, + info = { guifg = info_fg, guibg = elem_bg, guisp = info_fg }, + info_selected = { guifg = info_fg, guibg = selected_bg, gui = '' }, + pick = { guifg = pick_fg, guibg = elem_bg }, + pick_selected = { guifg = pick_fg, guibg = selected_bg }, +} + +local diagnostics_signs = { + ['error'] = '', + warning = '', + default = '', +} + +bufferline.setup { + options = { + always_show_bufferline = false, + diagnostics = 'nvim_lsp', + diagnostics_indicator = function(count, level, diagnostics_dict, context) + local s = ' ' + for e, n in pairs(diagnostics_dict) do + local sym = diagnostics_signs[e] or diagnostics_signs.default + s = s .. (#s > 1 and ' ' or '') .. sym .. ' ' .. n + end + return s + end, + separator_style = 'slant', + }, + highlights = { + background = colors.elem_inactive, + buffer_selected = colors.elem_selected, + buffer_visible = colors.elem_inactive, + close_button = colors.elem, + close_button_selected = colors.elem_selected, + close_button_visible = colors.elem, + diagnostic = colors.info, + diagnostic_selected = colors.info_selected, + diagnostic_visible = colors.info, + duplicate = colors.elem, + duplicate_selected = colors.elem_selected, + duplicate_visible = colors.elem, + error = colors.error, + error_diagnostic = colors.error, + error_diagnostic_selected = colors.error_selected, + error_selected = colors.error_selected, + fill = colors.bar, + hint = colors.info, + hint_diagnostic = colors.info, + hint_diagnostic_selected = colors.info_selected, + hint_diagnostic_visible = colors.info, + hint_selected = colors.info_selected, + hint_visible = colors.info, + info = colors.info, + info_diagnostic = colors.info, + info_diagnostic_selected = colors.info_selected, + info_diagnostic_visible = colors.info, + info_selected = colors.info_selected, + info_visible = colors.info, + modified = colors.elem, + modified_selected = colors.elem_selected, + modified_visible = colors.elem, + pick = colors.pick, + pick_selected = colors.pick_selected, + separator = colors.separator, + separator_selected = colors.separator_selected, + separator_visible = colors.separator, + tab = colors.elem, + tab_close = colors.bar, + tab_selected = colors.elem_selected, + warning = colors.warning, + warning_diagnostic = colors.warning, + warning_diagnostic_selected = colors.warning_selected, + warning_diagnostic_visible = colors.warning, + warning_selected = colors.warning_selected, + warning_visible = colors.warning, + }, +} + +local opts = { silent = true, nowait = true } +map('n', 'gb', '<cmd>BufferLinePick<cr>', opts) +map('n', '<leader>d', '<cmd>bdelete!<cr>', opts)
\ No newline at end of file diff --git a/nvim_WIP/lua/config/cmp.lua b/nvim_WIP/lua/config/cmp.lua new file mode 100644 index 0000000..1352750 --- /dev/null +++ b/nvim_WIP/lua/config/cmp.lua @@ -0,0 +1,51 @@ +local cmp = require("cmp") +local source_mapping = { + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + cmp_tabnine = "[TN]", + path = "[Path]", +} +local lspkind = require("lspkind") + +cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + + mapping = { + ['<C-p>'] = cmp.mapping.select_prev_item(), + ['<C-n>'] = cmp.mapping.select_next_item(), + -- Add tab support + ['<S-Tab>'] = cmp.mapping.select_prev_item(), + ['<Tab>'] = cmp.mapping.select_next_item(), + ['<C-d>'] = cmp.mapping.scroll_docs(-4), + ['<C-u>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.close(), + ['<CR>'] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }) + }, + + formatting = { + format = function(entry, vim_item) + vim_item.kind = lspkind.presets.default[vim_item.kind] + local menu = source_mapping[entry.source.name] + vim_item.menu = menu + return vim_item + end, + }, + -- Installed sources + sources = { + -- { name = 'path' }, + { name = 'nvim_lsp_signature_help' }, + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + }, +})
\ No newline at end of file diff --git a/nvim_WIP/lua/config/dap.lua b/nvim_WIP/lua/config/dap.lua new file mode 100644 index 0000000..0988239 --- /dev/null +++ b/nvim_WIP/lua/config/dap.lua @@ -0,0 +1,92 @@ + +local dap = require("dap"); + +dap.configurations.typescriptreact = { -- change to typescript if needed + { + type = "chrome", + request = "attach", + program = "${file}", + cwd = vim.fn.getcwd(), + sourceMaps = true, + protocol = "inspector", + port = 9222, + webRoot = "${workspaceFolder}" + } +} + +require('dap.ext.vscode').load_launchjs() + +-- Debugpy +dap.adapters.python = { + type = 'executable', + command = 'python', + args = { '-m', 'debugpy.adapter' }, +} + +dap.configurations.python = { + { + type = 'python', + request = 'launch', + name = 'Launch file', + program = '${file}', + pythonPath = function() + local venv_path = vim.fn.getenv 'VIRTUAL_ENVIRONMENT' + if venv_path ~= vim.NIL and venv_path ~= '' then + return venv_path .. '/bin/python' + else + return '/usr/bin/python' + end + end, + }, +} + +-- Neovim Lua +dap.adapters.nlua = function(callback, config) + callback { type = 'server', host = config.host, port = config.port } +end + +dap.configurations.lua = { + { + type = 'nlua', + request = 'attach', + name = 'Attach to running Neovim instance', + host = function() + local value = vim.fn.input 'Host [127.0.0.1]: ' + if value ~= '' then + return value + end + return '127.0.0.1' + end, + port = function() + local val = tonumber(vim.fn.input 'Port: ') + assert(val, 'Please provide a port number') + return val + end, + }, +} + +-- lldb +dap.adapters.lldb = { + type = 'executable', + command = '/usr/bin/lldb-vscode', + name = 'lldb', +} + +dap.configurations.cpp = { + { + name = 'Launch', + type = 'lldb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + runInTerminal = false, + }, +} + +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp + diff --git a/nvim_WIP/lua/config/dap_setup.lua b/nvim_WIP/lua/config/dap_setup.lua new file mode 100644 index 0000000..f8e08f2 --- /dev/null +++ b/nvim_WIP/lua/config/dap_setup.lua @@ -0,0 +1,10 @@ +local map = require('config.utils').map + +vim.cmd [[command! BreakpointToggle lua require('dap').toggle_breakpoint()]] +vim.cmd [[command! Debug lua require('dap').continue()]] +vim.cmd [[command! DapREPL lua require('dap').repl.open()]] + +map('n', '<F5>', [[<cmd>lua require'dap'.continue()<CR>]]) +map('n', '<F10>', [[<cmd>lua require'dap'.step_over()<CR>]]) +map('n', '<F11>', [[<cmd>lua require'dap'.step_into()<CR>]]) +map('n', '<F12>', [[<cmd>lua require'dap'.step_out()<CR>]])
\ No newline at end of file diff --git a/nvim_WIP/lua/config/lspconfig.lua b/nvim_WIP/lua/config/lspconfig.lua new file mode 100644 index 0000000..59eaeaa --- /dev/null +++ b/nvim_WIP/lua/config/lspconfig.lua @@ -0,0 +1,71 @@ + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true + +require("lspconfig").tsserver.setup(config()) + +require("lspconfig").ccls.setup(config()) + +require("lspconfig").jedi_language_server.setup(config()) + +require("lspconfig").svelte.setup(config()) + +require("lspconfig").solang.setup(config()) + +require("lspconfig").cssls.setup(config()) + + +local opts = { + tools = { + autoSetHints = true, + hover_with_actions = true, + runnables = { + use_telescope = true + }, + inlay_hints = { + show_parameter_hints = false, + parameter_hints_prefix = "", + other_hints_prefix = "", + }, + }, + + server = { + -- on_attach is a callback called when the language server attachs to the buffer (was commented?) + on_attach = on_attach, + settings = { + ["rust-analyzer"] = { + checkOnSave = { + command = "clippy" + }, + } + } + }, +} + +require('rust-tools').setup(opts) + +require("lspconfig").gopls.setup(config({ + cmd = { "gopls", "serve" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + }, + }, +})) + +local opts = { + -- whether to highlight the currently hovered symbol + -- disable if your cpu usage is higher than you want it + -- or you just hate the highlight + -- default: true + highlight_hovered_item = true, + + -- whether to show outline guides + -- default: true + show_guides = true, +} + +require("symbols-outline").setup(opts) diff --git a/nvim_WIP/lua/config/lspinstaller.lua b/nvim_WIP/lua/config/lspinstaller.lua new file mode 100644 index 0000000..fe6ac21 --- /dev/null +++ b/nvim_WIP/lua/config/lspinstaller.lua @@ -0,0 +1,18 @@ +local lsp_installer = require "nvim-lsp-installer" + +lsp_installer.settings({ + ui = { + icons = { + server_installed = "✓", + server_pending = "➜", + server_uninstalled = "✗" + } + } +}) + +lsp_installer.on_server_ready(function(server) + local opts = {} + + server:setup(opts) + vim.cmd [[ do User LspAttachBuffers ]] +end)
\ No newline at end of file diff --git a/nvim_WIP/lua/config/telescope.lua b/nvim_WIP/lua/config/telescope.lua new file mode 100644 index 0000000..c7d44e6 --- /dev/null +++ b/nvim_WIP/lua/config/telescope.lua @@ -0,0 +1,29 @@ +local telescope = require 'telescope' + +telescope.setup { + defaults = { + layout_strategy = 'flex', + scroll_strategy = 'cycle', + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', + }, + }, + pickers = { + lsp_references = { theme = 'dropdown' }, + lsp_code_actions = { theme = 'dropdown' }, + lsp_definitions = { theme = 'dropdown' }, + lsp_implementations = { theme = 'dropdown' }, + buffers = { + sort_lastused = true, + }, + }, +} + +-- Extensions +telescope.load_extension 'frecency' +telescope.load_extension 'fzf'
\ No newline at end of file diff --git a/nvim_WIP/lua/config/telescope_setup.lua b/nvim_WIP/lua/config/telescope_setup.lua new file mode 100644 index 0000000..3cef0c9 --- /dev/null +++ b/nvim_WIP/lua/config/telescope_setup.lua @@ -0,0 +1,9 @@ +local map = require('config.utils').map + +local silent = { silent = true } +-- Navigate buffers and repos +map('n', '<c-a>', [[<cmd>Telescope buffers show_all_buffers=true theme=get_dropdown<cr>]], silent) +map('n', '<c-e>', [[<cmd>Telescope frecency theme=get_dropdown<cr>]], silent) +map('n', '<c-s>', [[<cmd>Telescope git_files theme=get_dropdown<cr>]], silent) +map('n', '<c-d>', [[<cmd>Telescope find_files theme=get_dropdown<cr>]], silent) +map('n', '<c-g>', [[<cmd>Telescope live_grep theme=get_dropdown<cr>]], silent) diff --git a/nvim_WIP/lua/config/utils.lua b/nvim_WIP/lua/config/utils.lua new file mode 100644 index 0000000..9cc02c8 --- /dev/null +++ b/nvim_WIP/lua/config/utils.lua @@ -0,0 +1,26 @@ +local cmd = vim.cmd +local o_s = vim.o +local map_key = vim.api.nvim_set_keymap + +local function opt(o, v, scopes) + scopes = scopes or {o_s} + for _, s in ipairs(scopes) do s[o] = v end +end + +local function autocmd(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 + +local function map(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 + +return {opt = opt, autocmd = autocmd, map = map}
\ No newline at end of file diff --git a/nvim_WIP/lua/plugins.lua b/nvim_WIP/lua/plugins.lua new file mode 100644 index 0000000..5c72ed0 --- /dev/null +++ b/nvim_WIP/lua/plugins.lua @@ -0,0 +1,176 @@ +local fn = vim.fn +local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +if fn.empty(fn.glob(install_path)) > 0 then + packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) +end + +return require('packer').startup(function(use) + + -- plugins + + -- Packer + use '~/projects/personal/packer.nvim' + + use 'lewis6991/impatient.nvim' + + -- Async building & commands + use { 'tpope/vim-dispatch', cmd = { 'Dispatch', 'Make', 'Focus', 'Start' } } + + -- Search + use { + { + 'nvim-telescope/telescope.nvim', + requires = { + 'nvim-lua/popup.nvim', + 'nvim-lua/plenary.nvim', + 'telescope-frecency.nvim', + 'telescope-fzf-native.nvim', + }, + wants = { + 'popup.nvim', + 'plenary.nvim', + 'telescope-frecency.nvim', + 'telescope-fzf-native.nvim', + }, + setup = function() require('config.telescope_setup') end, + config = function() require('config.telescope') end, + cmd = 'Telescope', + module = 'telescope', + }, + { + 'nvim-telescope/telescope-frecency.nvim', + after = 'telescope.nvim', + requires = 'tami5/sqlite.lua', + }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + run = 'make', + }, + } + + -- Undo tree + use { + 'mbbill/undotree', + cmd = 'UndotreeToggle', + config = function() vim.g.undotree_SetFocusWhenToggle = 1 end, + } + + -- Git + use { + { 'tpope/vim-fugitive', cmd = { 'Git', 'Gstatus', 'Gblame', 'Gpush', 'Gpull' }, disable = true }, + { + 'lewis6991/gitsigns.nvim', + requires = { 'nvim-lua/plenary.nvim' }, + }, + { 'TimUntersberger/neogit', + cmd = 'Neogit', + config = function() require('neogit').setup {disable_commit_confirmation = true, disable_signs = true} end + }, + } + + -- linting + use { + { + 'neovim/nvim-lspconfig', + config = function() require('config.lspconfig') end, + }, + { + "williamboman/nvim-lsp-installer", + requires = 'nvim-lspconfig', + after = 'nvim-lspconfig', + config = function() require('config.lspinstaller') end, + }, + 'folke/trouble.nvim', + 'ray-x/lsp_signature.nvim', + 'kosayoda/nvim-lightbulb', + } + + -- Completion + use { + 'hrsh7th/nvim-cmp', + requires = { + 'L3MON4D3/LuaSnip', + { 'hrsh7th/cmp-buffer', after = 'nvim-cmp' }, + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-nvim-lsp-signature-help', + { 'onsails/lspkind-nvim', after = 'nvim-cmp' }, + { 'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp' }, + { 'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp' }, + { 'nvim-lua/lsp_extensions.nvim', after = 'nvim-cmp' }, + }, + config = function() require('config.cmp') end, + event = 'InsertEnter *', + } + + use({ + "folke/which-key.nvim", + config = function() require("which-key").setup({}) end, + }) + + -- Highlights + use { + 'nvim-treesitter/nvim-treesitter', + requires = { + 'nvim-treesitter/nvim-treesitter-refactor', + 'RRethy/nvim-treesitter-textsubjects', + }, + run = ':TSUpdate', + } + + + -- Debugger + use { + { + 'Pocco81/DAPInstall.nvim', + config = function() require("dap-install").config("chrome", {}) end, + }, + { + 'mfussenegger/nvim-dap', + setup = function() require('config.dap_setup') end, + after = 'dap-install', + config = function() require('config.dap') end, + module = 'dap', + }, + { + 'puremourning/vimspector', + requires = 'nvim-dap', + after = 'nvim-dap', + setup = function() vim.g.vimspector_enable_mappings = 'HUMAN' end, + }, + { + 'rcarriga/nvim-dap-ui', + requires = 'nvim-dap', + disable = true, + after = 'nvim-dap', + config = function() require('dapui').setup() end, + }, + } + + -- Profiling + use { 'dstein64/vim-startuptime', cmd = 'StartupTime', config = function() vim.g.startuptime_tries = 10 end } + + -- Refactoring + use { 'ThePrimeagen/refactoring.nvim', opt = true } + + -- Highlight colors + use { + 'norcalli/nvim-colorizer.lua', + ft = { 'css', 'javascript', 'vim', 'html' }, + config = function() require('colorizer').setup {'css', 'javascript', 'vim', 'html'} end, + } + + -- Buffer management + use { + 'akinsho/nvim-bufferline.lua', + requires = 'kyazdani42/nvim-web-devicons', + config = function() require('config.bufferline') end, + event = 'User ActuallyEditing', + } + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if packer_bootstrap then + require('packer').sync() + end +end) + diff --git a/nvim/plugin/git.vim b/nvim_WIP/plugin/git.vim index 11c26dd..af7f191 100644 --- a/nvim/plugin/git.vim +++ b/nvim_WIP/plugin/git.vim @@ -5,4 +5,3 @@ nnoremap <leader>grom :Git rebase origin/master<CR> nmap <leader>gh :diffget //3<CR> nmap <leader>gu :diffget //2<CR> nmap <leader>gs :G<CR> - diff --git a/nvim_WIP/plugin/lsp.vim b/nvim_WIP/plugin/lsp.vim new file mode 100644 index 0000000..51aec3d --- /dev/null +++ b/nvim_WIP/plugin/lsp.vim @@ -0,0 +1,2 @@ +set completeopt=menu,menuone,noselect +let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
\ No newline at end of file diff --git a/nvim/plugin/navigation.vim b/nvim_WIP/plugin/navigation.vim index 4db3e4c..89ee870 100644 --- a/nvim/plugin/navigation.vim +++ b/nvim_WIP/plugin/navigation.vim @@ -9,25 +9,25 @@ nnoremap <leader>j :lprev<CR>zz nnoremap <C-q> :call ToggleQFList(1)<CR> nnoremap <leader>q :call ToggleQFList(0)<CR> -let g:the_primeagen_qf_l = 0 -let g:the_primeagen_qf_g = 0 +let g:navigation_qf_l = 0 +let g:navigation_qf_g = 0 fun! ToggleQFList(global) if a:global - if g:the_primeagen_qf_g == 1 - let g:the_primeagen_qf_g = 0 + if g:navigation_qf_g == 1 + let g:navigation_qf_g = 0 cclose else - let g:the_primeagen_qf_g = 1 + let g:navigation_qf_g = 1 copen end else - if g:the_primeagen_qf_l == 1 - let g:the_primeagen_qf_l = 0 + if g:navigation_qf_l == 1 + let g:navigation_qf_l = 0 lclose else - let g:the_primeagen_qf_l = 1 + let g:navigation_qf_l = 1 lopen end endif -endfun +endfun
\ No newline at end of file diff --git a/nvim/plugin/sets.vim b/nvim_WIP/plugin/options.vim index b691eb2..6bc9b29 100644 --- a/nvim/plugin/sets.vim +++ b/nvim_WIP/plugin/options.vim @@ -1,4 +1,19 @@ -set guicursor= +" hello front end masters +set path+=** + +" Nice menu when typing `:find *.py` +set wildmode=longest,list,full +set wildmenu + +" Ignore files +set wildignore+=*.pyc +set wildignore+=*_build/* +set wildignore+=**/coverage/* +set wildignore+=**/node_modules/* +set wildignore+=**/android/* +set wildignore+=**/ios/* +set wildignore+=**/.git/* + set relativenumber set nohlsearch set hidden @@ -31,4 +46,4 @@ set updatetime=50 " Don't pass messages to |ins-completion-menu|. set shortmess+=c -set colorcolumn=80 +set colorcolumn=100
\ No newline at end of file diff --git a/nvim_WIP/plugin/refactoring.vim b/nvim_WIP/plugin/refactoring.vim new file mode 100644 index 0000000..b4b5b1e --- /dev/null +++ b/nvim_WIP/plugin/refactoring.vim @@ -0,0 +1,14 @@ + +lua require("theprimeagen") +lua require("refactoring").setup({}) + +vnoremap <silent> <leader>rr :lua require("theprimeagen.telescope").refactors()<CR> +vnoremap <silent> <leader>re :lua require("refactoring").refactor(106)<CR> + +nnoremap <silent> <leader>ri :lua require("refactoring").refactor(123)<CR> + +nnoremap <silent> <leader>dh :lua print(vim.inspect(require("refactoring").debug.get_path()))<CR> +nnoremap <silent> <leader>dg :lua require("refactoring").debug.printf({below = false})<CR> +nnoremap <silent> <leader>dm :lua require("refactoring").debug.printf({below = true})<CR> +nnoremap <silent> <leader>df :lua require("refactoring").debug.print_var({below = false})<CR> +nnoremap <silent> <leader>db :lua require("refactoring").debug.print_var({below = true})<CR>
\ No newline at end of file diff --git a/nvim/plugin/telescope.vim b/nvim_WIP/plugin/telescope.vim index fdd9603..fdd9603 100644 --- a/nvim/plugin/telescope.vim +++ b/nvim_WIP/plugin/telescope.vim diff --git a/nvim/plugin/vimspector.vim b/nvim_WIP/plugin/vimspector.vim index deba533..7dbef61 100644 --- a/nvim/plugin/vimspector.vim +++ b/nvim_WIP/plugin/vimspector.vim @@ -8,5 +8,4 @@ nnoremap <leader>m :MaximizerToggle!<CR> " <Plug>VimspectorStop " <Plug>VimspectorPause -" <Plug>VimspectorAddFunctionBreakpoint - +" <Plug>VimspectorAddFunctionBreakpoint
\ No newline at end of file diff --git a/scripts/yt.sh b/scripts/yt.sh new file mode 100755 index 0000000..e39d6f6 --- /dev/null +++ b/scripts/yt.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# originally by Kris Occhipinti +# https://www.youtube.com/watch?v=FsQuGplQvrw + +mpv.exe --ytdl-format=bestvideo+bestaudio/best --fs "$(powershell.exe -c "Get-Clipboard")" @@ -1,5 +1,9 @@ set -g mouse on -set -ga terminal-overrides ',*256color*:smcup@:rmcup@' + +set -g default-terminal "tmux-256color" +set -ga terminal-overrides ",alacritty:Tc" +set-option -sg escape-time 10 +set-option -g focus-events on unbind C-b set-option -g prefix C-a @@ -1,22 +1,26 @@ { "$help": "https://aka.ms/terminal-documentation", "$schema": "https://aka.ms/terminal-profiles-schema", - "actions": [ + "actions": + [ { - "command": { - "action": "openSettings", - "target": "settingsUI" + "command": + { + "action": "closeTab" }, - "keys": "ctrl+comma" + "keys": "ctrl+w" }, { - "command": { - "action": "closeTab" + "command": + { + "action": "openSettings", + "target": "settingsUI" }, - "keys": "ctrl+w" + "keys": "ctrl+comma" }, { - "command": { + "command": + { "action": "openSettings" }, "keys": "ctrl+shift+comma" @@ -26,20 +30,22 @@ "keys": "ctrl+v" }, { - "command": { - "action": "newTab", - "profile": "btm" - }, - "keys": "alt+`" - }, - { - "command": { + "command": + { "action": "openSettings", "target": "defaultsFile" }, "keys": "ctrl+alt+comma" }, { + "command": + { + "action": "newTab", + "profile": "btm" + }, + "keys": "alt+`" + }, + { "command": "unbound", "keys": "ctrl+f" }, @@ -48,7 +54,8 @@ "keys": "ctrl+t" }, { - "command": { + "command": + { "action": "commandPalette" }, "keys": "f1" @@ -56,17 +63,21 @@ ], "alwaysShowNotificationIcon": true, "confirmCloseAllTabs": false, - "defaultProfile": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}", - "disabledProfileSources": [ + "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", + "disabledProfileSources": + [ "Windows.Terminal.Azure" ], "experimental.rendering.forceFullRepaint": true, "initialCols": 100, "initialRows": 30, "multiLinePasteWarning": false, - "profiles": { - "defaults": { - "bellStyle": [ + "profiles": + { + "defaults": + { + "bellStyle": + [ "window", "taskbar" ], @@ -74,14 +85,16 @@ "colorScheme": "vscode-dark", "cursorColor": "#D4D4D4", "cursorShape": "filledBox", - "font": { + "font": + { "face": "FiraCode NF", "size": 11 }, "padding": "8", "useAcrylic": true }, - "list": [ + "list": + [ { "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}", "hidden": false, @@ -119,10 +132,23 @@ "guid": "{1a3bcafa-ff3b-46ba-bdf4-582e99ec9dfc}", "hidden": false, "name": "btm" + }, + { + "guid": "{b154058b-47bb-56d5-a1b0-06d98908dfa2}", + "hidden": false, + "name": "Developer Command Prompt for VS 2019 (2)", + "source": "Windows.Terminal.VisualStudio" + }, + { + "guid": "{f1a99e78-5690-5e40-b3ff-55031ae2cce5}", + "hidden": false, + "name": "Developer PowerShell for VS 2019 (2)", + "source": "Windows.Terminal.VisualStudio" } ] }, - "schemes": [ + "schemes": + [ { "background": "#0C0C0C", "black": "#0C0C0C", diff --git a/zsh/keybindings.zsh b/zsh/keybindings.zsh index 7eef985..df70112 100644 --- a/zsh/keybindings.zsh +++ b/zsh/keybindings.zsh @@ -103,7 +103,15 @@ for key kcap seq mode widget ( bindkey '^ ' autosuggest-accept bindkey '^[[Z' reverse-menu-complete -bindkey -s ^f "tmux-sessionizer\n" + +sessionizer () { + tmux-sessionizer + zle redisplay +} + +zle -N sessionizer +bindkey '^F' sessionizer +# bindkey -s ^f "tmux-sessionizer\n" # register ctrl+c as interupt function ctrl_c_intr() { @@ -120,4 +128,4 @@ autoload -Uz add-zsh-hook || return # register the functions as hooks add-zsh-hook preexec ctrl_c_intr -add-zsh-hook precmd ctrl_y_intr
\ No newline at end of file +add-zsh-hook precmd ctrl_y_intr |