Restructure config | Move some to a packer plugin | Lot of cleanup
* move teleacope files, updater and related utils to https://github.com/NvChad/core * restructure config file and directory structure * expose mappings for better escape * allow multiple mappings for some * improve merge table function for the same * move autocommands to a seperate file * rearrange everything alphabetically where sanely possible * rearrange packer plugin list on the basis of trigerred state config structure now . ├── init.lua ├── LICENSE ├── lua │ ├── chadrc.lua │ ├── colors │ │ ├── highlights.lua │ │ ├── init.lua │ │ └── themes │ │ ├── chadracula.lua │ │ ├── everforest.lua │ │ ├── gruvchad.lua │ │ ├── javacafe.lua │ │ ├── mountain.lua │ │ ├── norchad.lua │ │ ├── one-light.lua │ │ ├── onedark.lua │ │ ├── tokyonight.lua │ │ └── tomorrow-night.lua │ ├── core │ │ ├── autocmds.lua │ │ ├── init.lua │ │ ├── mappings.lua │ │ ├── options.lua │ │ └── utils.lua │ ├── default_config.lua │ └── plugins │ ├── configs │ │ ├── autopairs.lua │ │ ├── autosave.lua │ │ ├── bufferline.lua │ │ ├── chadsheet.lua │ │ ├── compe.lua │ │ ├── dashboard.lua │ │ ├── gitsigns.lua │ │ ├── icons.lua │ │ ├── lspconfig.lua │ │ ├── luasnip.lua │ │ ├── nvimtree.lua │ │ ├── others.lua │ │ ├── statusline.lua │ │ ├── telescope.lua │ │ ├── treesitter.lua │ │ └── zenmode.lua │ ├── init.lua │ └── packerInit.lua └── README.md
This commit is contained in:
		
							parent
							
								
									44ae0178f4
								
							
						
					
					
						commit
						9ffddb6b52
					
				
							
								
								
									
										14
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								init.lua
									
									
									
									
									
								
							| @ -1,12 +1,10 @@ | |||||||
| local chad_modules = { | local init_modules = { | ||||||
|    "options", |    "core", | ||||||
|    "mappings", |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| for i = 1, #chad_modules, 1 do | for _, module in ipairs(init_modules) do | ||||||
|    if not pcall(require, chad_modules[i]) then |    local ok, err = pcall(require, module) | ||||||
|       error("Error loading " .. chad_modules[i] .. "\n") |    if not ok then | ||||||
|  |       error("Error loading " .. module .. "\n\n" .. err) | ||||||
|    end |    end | ||||||
| end | end | ||||||
| 
 |  | ||||||
| require("mappings").misc() |  | ||||||
|  | |||||||
							
								
								
									
										264
									
								
								lua/chadrc.lua
									
									
									
									
									
								
							
							
						
						
									
										264
									
								
								lua/chadrc.lua
									
									
									
									
									
								
							| @ -1,161 +1,191 @@ | |||||||
| -- IMPORTANT NOTE : This is user config | -- IMPORTANT NOTE : This is the user config, can be edited. Will be preserved if updated with internal updater | ||||||
| 
 | 
 | ||||||
| local M = {} | local M = {} | ||||||
| 
 | 
 | ||||||
| M.ui = { | M.ui = { | ||||||
|  |    italic_comments = false, | ||||||
|  | 
 | ||||||
|  |    -- theme to be used, to see all available themes, open the theme switcher by <leader> + th | ||||||
|    theme = "onedark", |    theme = "onedark", | ||||||
| 
 | 
 | ||||||
|    -- theme toggle |    -- theme toggler, toggle between two themes, see theme_toggleer mappings | ||||||
|    theme_toggler = false, |    theme_toggler = { | ||||||
|    fav_themes = { |       enabled = false, | ||||||
|       "onedark", |       fav_themes = { | ||||||
|       "gruvchad", |          "onedark", | ||||||
|  |          "gruvchad", | ||||||
|  |       }, | ||||||
|    }, |    }, | ||||||
|    italic_comments = false, |  | ||||||
| 
 | 
 | ||||||
|    -- Enable this only if your terminal has the colorscheme set which nvchad uses |    -- Enable this only if your terminal has the colorscheme set which nvchad uses | ||||||
|    -- For Ex : if you have onedark set in nvchad , set onedark's bg color on your terminal |    -- For Ex : if you have onedark set in nvchad , set onedark's bg color on your terminal | ||||||
|    transparency = false, |    transparency = false, | ||||||
| 
 | 
 | ||||||
|    -- statusline related options |    -- plugin related ui options | ||||||
|    statusline = { |    plugin = { | ||||||
|       -- these are filetypes, not pattern matched |       -- statusline related options | ||||||
|       -- if a filetype is present in shown, it will always show the statusline, irrespective of filetypes in hidden |       statusline = { | ||||||
|       hidden = {}, |          -- these are filetypes, not pattern matched | ||||||
|       shown = { |          -- if a filetype is present in shown, it will always show the statusline, irrespective of filetypes in hidden | ||||||
|          -- "terminal" |          hidden = {}, | ||||||
|  |          shown = { | ||||||
|  |             -- "terminal" | ||||||
|  |          }, | ||||||
|  |          -- default, round , slant , block , arrow | ||||||
|  |          style = "default", | ||||||
|       }, |       }, | ||||||
|       style = "default", -- default, round , slant , block , arrow |  | ||||||
|    }, |    }, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| M.options = { | M.options = { | ||||||
|    permanent_undo = true, |    clipboard = "unnamedplus", | ||||||
|    ruler = false, |    cmdheight = 1, | ||||||
|  |    expandtab = true, | ||||||
|    hidden = true, |    hidden = true, | ||||||
|    ignorecase = true, |    ignorecase = true, | ||||||
|  |    insert_nav = true, -- navigation in insertmode | ||||||
|  |    mapleader = " ", | ||||||
|    mouse = "a", |    mouse = "a", | ||||||
|    cmdheight = 1, |  | ||||||
|    updatetime = 250, |  | ||||||
|    timeoutlen = 400, |  | ||||||
|    clipboard = "unnamedplus", |  | ||||||
|    number = true, |    number = true, | ||||||
|    -- relative numbers in normal mode tool at the bottom of options.lua |    -- relative numbers in normal mode tool at the bottom of options.lua | ||||||
|    relativenumber = false, |  | ||||||
|    numberwidth = 2, |    numberwidth = 2, | ||||||
|    expandtab = true, |    permanent_undo = true, | ||||||
|    shiftwidth = 2, |    shiftwidth = 2, | ||||||
|    smartindent = true, |    smartindent = true, | ||||||
|    mapleader = " ", |    timeoutlen = 400, | ||||||
|    autosave = false, |    relativenumber = false, | ||||||
|    enable_insertNav = true, -- navigation in insertmode |    ruler = false, | ||||||
|  |    updatetime = 250, | ||||||
|    -- used for updater |    -- used for updater | ||||||
|    update_url = "https://github.com/NvChad/NvChad", |    update_url = "https://github.com/NvChad/NvChad", | ||||||
|    update_branch = "main", |    update_branch = "main", | ||||||
|  | 
 | ||||||
|  |    -- these are plugin related options | ||||||
|  |    plugin = { | ||||||
|  |       autosave = false, -- autosave on changed text or insert mode leave | ||||||
|  |       -- timeout to be used for using escape with a key combination, see mappings.plugin.better_escape | ||||||
|  |       esc_insertmode_timeout = 300, | ||||||
|  |    }, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| -- enable and disable plugins (false for disable) | -- enable and disable plugins (false for disable) | ||||||
| M.plugin_status = { | M.plugin_status = { | ||||||
|    -- UI |    autosave = true, -- to autosave files | ||||||
|    nvim_bufferline = true, |    blankline = true, -- beautified blank lines | ||||||
|    galaxyline = true, |    bufferline = true, -- buffer shown as tabs | ||||||
|    nvim_colorizer = true, |    cheatsheet = true, -- fuzzy search your commands/keymappings | ||||||
|    dashboard_nvim = true, |    colorizer = true, | ||||||
|    blankline = true, |    comment = true, -- universal commentor | ||||||
|    truezen_nvim = true, |    dashboard = true, -- a nice looking dashboard | ||||||
|    better_esc = true, |    esc_insertmode = true, -- escape from insert mode using custom keys | ||||||
|    -- lsp stuff |    galaxyline = true, -- statusline | ||||||
|    lspkind = true, |    gitsigns = true, -- gitsigns in statusline | ||||||
|    lspsignature = true, |    lspkind = true, -- lsp enhancements | ||||||
|    -- git stuff |    lspsignature = true, -- lsp enhancements | ||||||
|    gitsigns = true, |    neoformat = true, -- universal formatter | ||||||
|    vim_fugitive = true, |    neoscroll = true, -- smooth scroll | ||||||
|    -- misc |    telescope_media = true, -- see media files in telescope picker | ||||||
|    neoformat = true, |    truezen = true, -- no distraction mode for nvim | ||||||
|    vim_matchup = true, |    vim_fugitive = true, -- git in nvim | ||||||
|    autosave_nvim = true, |    vim_matchup = true, -- % magic, match it but improved | ||||||
|    nvim_comment = true, |  | ||||||
|    neoscroll_nvim = true, |  | ||||||
|    telescope_media = true, |  | ||||||
|    cheatsheet = true, |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| -- make sure you dont use same keys twice | -- make sure you dont use same keys twice | ||||||
| M.mappings = { | M.mappings = { | ||||||
|    -- plugin specific |    -- close current focused buffer | ||||||
|    truezen = { |    close_buffer = "<leader>x", | ||||||
|       ataraxisMode = "<leader>zz", |    copy_whole_file = "<C-a>", -- copy all contents of the current buffer | ||||||
|       minimalisticmode = "<leader>zm", | 
 | ||||||
|       focusmode = "<leader>zf", |    -- navigation in insert mode, only if enabled in options | ||||||
|    }, |  | ||||||
|    comment_nvim = { |  | ||||||
|       comment_toggle = "<leader>/", |  | ||||||
|    }, |  | ||||||
|    nvimtree = { |  | ||||||
|       treetoggle = "<C-n>", -- file manager |  | ||||||
|    }, |  | ||||||
|    neoformat = { |  | ||||||
|       format = "<leader>fm", |  | ||||||
|    }, |  | ||||||
|    dashboard = { |  | ||||||
|       open = "<leader>db", |  | ||||||
|       newfile = "<leader>fn", |  | ||||||
|       bookmarks = "<leader>bm", |  | ||||||
|       sessionload = "<leader>l", |  | ||||||
|       sessionsave = "<leader>s", |  | ||||||
|    }, |  | ||||||
|    telescope = { |  | ||||||
|       live_grep = "<leader>fw", |  | ||||||
|       git_status = "<leader>gt", |  | ||||||
|       git_commits = "<leader>cm", |  | ||||||
|       find_files = "<leader>ff", |  | ||||||
|       buffers = "<leader>fb", |  | ||||||
|       help_tags = "<leader>fh", |  | ||||||
|       oldfiles = "<leader>fo", |  | ||||||
|       themes = "<leader>th", |  | ||||||
|    }, |  | ||||||
|    telescope_media = { |  | ||||||
|       media_files = "<leader>fp", |  | ||||||
|    }, |  | ||||||
|    chadsheet = { |  | ||||||
|       default_keys = "<leader>dk", |  | ||||||
|       user_keys = "<leader>uk", |  | ||||||
|    }, |  | ||||||
|    bufferline = { |  | ||||||
|       new_buffer = "<S-t>", |  | ||||||
|       newtab = "<C-t>b", |  | ||||||
|       close = "<S-x>", -- close a buffer with custom func in utils.lua |  | ||||||
|       cycleNext = "<TAB>", -- next buffer |  | ||||||
|       cyclePrev = "<S-Tab>", -- previous buffer |  | ||||||
|    }, |  | ||||||
|    fugitive = { |  | ||||||
|       Git = "<leader>gs", |  | ||||||
|       diffget_2 = "<leader>gh", |  | ||||||
|       diffget_3 = "<leader>gl", |  | ||||||
|       git_blame = "<leader>gb", |  | ||||||
|    }, |  | ||||||
|    terms = { -- below are NvChad mappings, not plugin mappings |  | ||||||
|       esc_termmode = "jk", |  | ||||||
|       esc_hide_termmode = "JK", |  | ||||||
|       pick_term = "<leader>W", -- note: this is a telescope extension |  | ||||||
|       new_wind = "<leader>w", |  | ||||||
|       new_vert = "<leader>v", |  | ||||||
|       new_hori = "<leader>h", |  | ||||||
|    }, |  | ||||||
|    -- navigation in insert mode |  | ||||||
|    insert_nav = { |    insert_nav = { | ||||||
|       forward = "<C-l>", |  | ||||||
|       backward = "<C-h>", |       backward = "<C-h>", | ||||||
|       top_of_line = "<C-a>", |  | ||||||
|       end_of_line = "<C-e>", |       end_of_line = "<C-e>", | ||||||
|       prev_line = "<C-j>", |       forward = "<C-l>", | ||||||
|       next_line = "<C-k>", |       next_line = "<C-k>", | ||||||
|  |       prev_line = "<C-j>", | ||||||
|  |       top_of_line = "<C-a>", | ||||||
|    }, |    }, | ||||||
|    misc = { | 
 | ||||||
|       copywhole_file = "<C-a>", |    line_number_toggle = "<leader>n", -- show or hide line number | ||||||
|       toggle_linenr = "<leader>n", -- show or hide line number |    new_buffer = "<S-t>", -- open a new buffer | ||||||
|       theme_toggle = "<leader>x", |    new_tab = "<C-t>b", -- open a new vim tab | ||||||
|       update_nvchad = "<leader>uu", |    save_file = "<C-s>", -- save file using :w | ||||||
|  |    theme_toggler = "<leader>tt", -- for theme toggler, see in ui.theme_toggler | ||||||
|  | 
 | ||||||
|  |    -- terminal related mappings | ||||||
|  |    terminal = { | ||||||
|  |       -- multiple mappings can be given for esc_termmode and esc_hide_termmode | ||||||
|  |       -- get out of terminal mode | ||||||
|  |       esc_termmode = { "jk" }, -- multiple mappings allowed | ||||||
|  |       -- get out of terminal mode and hide it | ||||||
|  |       -- it does not close it, see pick_term mapping to see hidden terminals | ||||||
|  |       esc_hide_termmode = { "JK" }, -- multiple mappings allowed | ||||||
|  |       -- show hidden terminal buffers in a telescope picker | ||||||
|  |       pick_term = "<leader>W", | ||||||
|  |       -- below three are for spawning terminals | ||||||
|  |       new_horizontal = "<leader>h", | ||||||
|  |       new_vertical = "<leader>v", | ||||||
|  |       new_window = "<leader>w", | ||||||
|  |    }, | ||||||
|  | 
 | ||||||
|  |    -- update nvchad from nvchad, chadness 101 | ||||||
|  |    update_nvchad = "<leader>uu", | ||||||
|  | 
 | ||||||
|  |    -- all plugins related mappings | ||||||
|  |    -- to get short info about a plugin, see the respective string in plugin_status, if not present, then info here | ||||||
|  |    plugin = { | ||||||
|  |       bufferline = { | ||||||
|  |          next_buffer = "<TAB>", -- next buffer | ||||||
|  |          prev_buffer = "<S-Tab>", -- previous buffer | ||||||
|  |       }, | ||||||
|  |       chadsheet = { | ||||||
|  |          default_keys = "<leader>dk", | ||||||
|  |          user_keys = "<leader>uk", | ||||||
|  |       }, | ||||||
|  |       comment = { | ||||||
|  |          toggle = "<leader>/", -- trigger comment on a single/selected lines/number prefix | ||||||
|  |       }, | ||||||
|  |       dashboard = { | ||||||
|  |          bookmarks = "<leader>bm", | ||||||
|  |          new_file = "<leader>fn", -- basically create a new buffer | ||||||
|  |          open = "<leader>db", -- open dashboard | ||||||
|  |          session_load = "<leader>l", -- load a saved session | ||||||
|  |          session_save = "<leader>s", -- save a session | ||||||
|  |       }, | ||||||
|  |       -- note: this is an edditional mapping to escape, escape key will still work | ||||||
|  |       better_escape = { | ||||||
|  |          esc_insertmode = { "jk" }, -- multiple mappings allowed | ||||||
|  |       }, | ||||||
|  |       nvimtree = { | ||||||
|  |          toggle = "<C-n>", -- file manager | ||||||
|  |       }, | ||||||
|  |       neoformat = { | ||||||
|  |          format = "<leader>fm", | ||||||
|  |       }, | ||||||
|  |       telescope = { | ||||||
|  |          buffers = "<leader>fb", | ||||||
|  |          find_files = "<leader>ff", | ||||||
|  |          git_commits = "<leader>cm", | ||||||
|  |          git_status = "<leader>gt", | ||||||
|  |          help_tags = "<leader>fh", | ||||||
|  |          live_grep = "<leader>fw", | ||||||
|  |          oldfiles = "<leader>fo", | ||||||
|  |          themes = "<leader>th", | ||||||
|  |       }, | ||||||
|  |       telescope_media = { | ||||||
|  |          media_files = "<leader>fp", | ||||||
|  |       }, | ||||||
|  |       truezen = { -- distraction free modes mapping, hide statusline, tabline, line numbers | ||||||
|  |          ataraxis_mode = "<leader>zz", -- center | ||||||
|  |          focus_mode = "<leader>zf", | ||||||
|  |          minimalistic_mode = "<leader>zm", -- as it is | ||||||
|  |       }, | ||||||
|  |       vim_fugitive = { | ||||||
|  |          diff_get_2 = "<leader>gh", | ||||||
|  |          diff_get_3 = "<leader>gl", | ||||||
|  |          git = "<leader>gs", | ||||||
|  |          git_blame = "<leader>gb", | ||||||
|  |       }, | ||||||
|    }, |    }, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,60 +1,55 @@ | |||||||
| local cmd = vim.cmd | local cmd = vim.cmd | ||||||
| 
 | 
 | ||||||
| local global_theme = "themes/" .. vim.g.nvchad_theme | local colors = require("colors").get() | ||||||
| local colors = require(global_theme) |  | ||||||
| 
 | 
 | ||||||
| local white = colors.white |  | ||||||
| local darker_black = colors.darker_black |  | ||||||
| local black = colors.black | local black = colors.black | ||||||
| local black2 = colors.black2 | local black2 = colors.black2 | ||||||
| local one_bg = colors.one_bg | local blue = colors.blue | ||||||
| local one_bg2 = colors.one_bg2 | local darker_black = colors.darker_black | ||||||
|  | local folder_bg = colors.folder_bg | ||||||
|  | local green = colors.green | ||||||
| local grey = colors.grey | local grey = colors.grey | ||||||
| local grey_fg = colors.grey_fg | local grey_fg = colors.grey_fg | ||||||
| local red = colors.red |  | ||||||
| local line = colors.line | local line = colors.line | ||||||
| local green = colors.green |  | ||||||
| local nord_blue = colors.nord_blue | local nord_blue = colors.nord_blue | ||||||
| local blue = colors.blue | local one_bg = colors.one_bg | ||||||
| local yellow = colors.yellow | local one_bg2 = colors.one_bg2 | ||||||
| local purple = colors.purple |  | ||||||
| local pmenu_bg = colors.pmenu_bg | local pmenu_bg = colors.pmenu_bg | ||||||
| local folder_bg = colors.folder_bg | local purple = colors.purple | ||||||
|  | local red = colors.red | ||||||
|  | local white = colors.white | ||||||
|  | local yellow = colors.yellow | ||||||
| 
 | 
 | ||||||
| -- for guifg , bg | local ui = require("core.utils").load_config().ui | ||||||
| 
 |  | ||||||
| local function fg(group, color) |  | ||||||
|    cmd("hi " .. group .. " guifg=" .. color) |  | ||||||
| end |  | ||||||
| 
 | 
 | ||||||
| local function bg(group, color) | local function bg(group, color) | ||||||
|    cmd("hi " .. group .. " guibg=" .. color) |    cmd("hi " .. group .. " guibg=" .. color) | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | local function fg(group, color) | ||||||
|  |    cmd("hi " .. group .. " guifg=" .. color) | ||||||
|  | end | ||||||
|  | 
 | ||||||
| local function fg_bg(group, fgcol, bgcol) | local function fg_bg(group, fgcol, bgcol) | ||||||
|    cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol) |    cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol) | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| -- blankline |  | ||||||
| 
 |  | ||||||
| fg("IndentBlanklineChar", line) |  | ||||||
| 
 |  | ||||||
| -- misc -- |  | ||||||
| fg("LineNr", grey) |  | ||||||
| 
 |  | ||||||
| -- Comments | -- Comments | ||||||
| local ui = require("utils").load_config().ui |  | ||||||
| 
 |  | ||||||
| if ui.italic_comments then | if ui.italic_comments then | ||||||
|    cmd("hi Comment gui=italic guifg=" .. grey_fg) |    fg("Comment", grey_fg .. " gui=italic") | ||||||
| else | else | ||||||
|    fg("Comment", grey_fg) |    fg("Comment", grey_fg) | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| fg("NvimInternalError", red) | cmd "hi clear CursorLine" -- disable cusror line | ||||||
| fg("VertSplit", line) | fg("cursorlinenr", white) -- line number | ||||||
|  | 
 | ||||||
|  | -- same it bg, so it doesn't appear | ||||||
| fg("EndOfBuffer", black) | fg("EndOfBuffer", black) | ||||||
| -- fg_bg("Visual",light_grey, colors.lightbg) | 
 | ||||||
|  | -- For floating windows | ||||||
|  | fg("FloatBorder", blue) | ||||||
|  | bg("NormalFloat", one_bg) | ||||||
| 
 | 
 | ||||||
| -- Pmenu | -- Pmenu | ||||||
| bg("Pmenu", one_bg) | bg("Pmenu", one_bg) | ||||||
| @ -62,74 +57,79 @@ bg("PmenuSbar", one_bg2) | |||||||
| bg("PmenuSel", pmenu_bg) | bg("PmenuSel", pmenu_bg) | ||||||
| bg("PmenuThumb", nord_blue) | bg("PmenuThumb", nord_blue) | ||||||
| 
 | 
 | ||||||
|  | -- misc | ||||||
|  | fg("LineNr", grey) | ||||||
|  | 
 | ||||||
|  | fg("NvimInternalError", red) | ||||||
|  | 
 | ||||||
| -- inactive statuslines as thin splitlines | -- inactive statuslines as thin splitlines | ||||||
| cmd("hi! StatusLineNC gui=underline guifg=" .. line) | fg("StatusLineNC", line .. " gui=underline") | ||||||
| 
 | 
 | ||||||
| -- line n.o | fg("VertSplit", line) | ||||||
| cmd "hi clear CursorLine" | -- fg_bg("Visual",light_grey, colors.lightbg) | ||||||
| fg("cursorlinenr", white) |  | ||||||
| 
 | 
 | ||||||
| -- git signs --- | if ui.transparency then | ||||||
|  |    bg("Normal", "NONE") | ||||||
|  |    bg("Folded", "NONE") | ||||||
|  |    fg("Folded", "NONE") | ||||||
|  |    fg("Comment", grey) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | ----- plugin related highlights ----- | ||||||
|  | 
 | ||||||
|  | -- dashboard -- | ||||||
|  | fg("DashboardCenter", grey_fg) | ||||||
|  | fg("DashboardFooter", grey_fg) | ||||||
|  | fg("DashboardHeader", grey_fg) | ||||||
|  | fg("DashboardShortcut", grey_fg) | ||||||
|  | 
 | ||||||
|  | -- git signs -- | ||||||
| fg_bg("DiffAdd", nord_blue, "none") | fg_bg("DiffAdd", nord_blue, "none") | ||||||
| fg_bg("DiffChange", grey_fg, "none") | fg_bg("DiffChange", grey_fg, "none") | ||||||
| fg_bg("DiffModified", nord_blue, "none") | fg_bg("DiffModified", nord_blue, "none") | ||||||
| 
 | 
 | ||||||
| -- NvimTree | -- indent blankline plugin -- | ||||||
| fg("NvimTreeFolderIcon", folder_bg) | fg("IndentBlanklineChar", line) | ||||||
| fg("NvimTreeFolderName", folder_bg) |  | ||||||
| fg("NvimTreeGitDirty", red) |  | ||||||
| fg("NvimTreeOpenedFolderName", blue) |  | ||||||
| fg("NvimTreeEmptyFolderName", blue) |  | ||||||
| fg("NvimTreeIndentMarker", one_bg2) |  | ||||||
| fg("NvimTreeVertSplit", darker_black) |  | ||||||
| bg("NvimTreeVertSplit", darker_black) |  | ||||||
| fg("NvimTreeEndOfBuffer", darker_black) |  | ||||||
| 
 |  | ||||||
| cmd("hi NvimTreeRootFolder gui=underline guifg=" .. red) |  | ||||||
| bg("NvimTreeNormal", darker_black) |  | ||||||
| fg_bg("NvimTreeStatuslineNc", darker_black, darker_black) |  | ||||||
| fg_bg("NvimTreeWindowPicker", red, black2) |  | ||||||
| 
 |  | ||||||
| -- telescope |  | ||||||
| fg("TelescopeBorder", line) |  | ||||||
| fg("TelescopePromptBorder", line) |  | ||||||
| fg("TelescopeResultsBorder", line) |  | ||||||
| fg("TelescopePreviewBorder", grey) |  | ||||||
| 
 |  | ||||||
| -- LspDiagnostics --- |  | ||||||
| 
 | 
 | ||||||
|  | -- LspDiagnostics -- | ||||||
| -- error / warnings | -- error / warnings | ||||||
| fg("LspDiagnosticsSignError", red) | fg("LspDiagnosticsSignError", red) | ||||||
| fg("LspDiagnosticsVirtualTextError", red) |  | ||||||
| fg("LspDiagnosticsSignWarning", yellow) | fg("LspDiagnosticsSignWarning", yellow) | ||||||
|  | fg("LspDiagnosticsVirtualTextError", red) | ||||||
| fg("LspDiagnosticsVirtualTextWarning", yellow) | fg("LspDiagnosticsVirtualTextWarning", yellow) | ||||||
| 
 | 
 | ||||||
| -- info | -- info | ||||||
| fg("LspDiagnosticsSignInformation", green) | fg("LspDiagnosticsSignInformation", green) | ||||||
| fg("LspDiagnosticsVirtualTextInformation", green) | fg("LspDiagnosticsVirtualTextInformation", green) | ||||||
| 
 | 
 | ||||||
| -- hint | -- hints | ||||||
| fg("LspDiagnosticsSignHint", purple) | fg("LspDiagnosticsSignHint", purple) | ||||||
| fg("LspDiagnosticsVirtualTextHint", purple) | fg("LspDiagnosticsVirtualTextHint", purple) | ||||||
| 
 | 
 | ||||||
| -- dashboard | -- NvimTree -- | ||||||
| 
 | fg("NvimTreeEmptyFolderName", blue) | ||||||
| fg("DashboardHeader", grey_fg) | fg("NvimTreeEndOfBuffer", darker_black) | ||||||
| fg("DashboardCenter", grey_fg) | fg("NvimTreeFolderIcon", folder_bg) | ||||||
| fg("DashboardShortcut", grey_fg) | fg("NvimTreeFolderName", folder_bg) | ||||||
| fg("DashboardFooter", grey_fg) | fg("NvimTreeGitDirty", red) | ||||||
| 
 | fg("NvimTreeIndentMarker", one_bg2) | ||||||
| if require("utils").load_config().ui.transparency then | bg("NvimTreeNormal", darker_black) | ||||||
|    bg("Normal", "NONE") | fg("NvimTreeOpenedFolderName", blue) | ||||||
|    bg("Folded", "NONE") | fg("NvimTreeRootFolder", red .. " gui=underline") -- enable underline for root folder in nvim tree | ||||||
|    fg("Folded", "NONE") | fg_bg("NvimTreeStatuslineNc", darker_black, darker_black) | ||||||
|  | fg("NvimTreeVertSplit", darker_black) | ||||||
|  | bg("NvimTreeVertSplit", darker_black) | ||||||
|  | fg_bg("NvimTreeWindowPicker", red, black2) | ||||||
|  | -- disable some highlight in nvim tree if transparency enabled | ||||||
|  | if ui.transparency then | ||||||
|    bg("NvimTreeNormal", "NONE") |    bg("NvimTreeNormal", "NONE") | ||||||
|  |    bg("NvimTreeStatusLineNC", "NONE") | ||||||
|    bg("NvimTreeVertSplit", "NONE") |    bg("NvimTreeVertSplit", "NONE") | ||||||
|    fg("NvimTreeVertSplit", grey) |    fg("NvimTreeVertSplit", grey) | ||||||
|    bg("NvimTreeStatusLineNC", "NONE") |  | ||||||
|    fg("Comment", grey) |  | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| -- For floating windows | -- telescope -- | ||||||
| bg("NormalFloat", one_bg) | fg("TelescopeBorder", line) | ||||||
| fg("FloatBorder", blue) | fg("TelescopePreviewBorder", grey) | ||||||
|  | fg("TelescopePromptBorder", line) | ||||||
|  | fg("TelescopeResultsBorder", line) | ||||||
							
								
								
									
										36
									
								
								lua/colors/init.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								lua/colors/init.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | |||||||
|  | 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" | ||||||
|  |    else | ||||||
|  |       return false | ||||||
|  |    end | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | -- returns a table of colors for givem or current theme | ||||||
|  | M.get = function(theme) | ||||||
|  |    if not theme then | ||||||
|  |       theme = vim.g.nvchad_theme | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    return require("colors.themes." .. theme) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | return M | ||||||
							
								
								
									
										17
									
								
								lua/core/autocmds.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								lua/core/autocmds.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | |||||||
|  | -- 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 | ||||||
|  | vim.cmd [[ au TermOpen term://* setlocal nonumber norelativenumber | setfiletype terminal ]] | ||||||
|  | 
 | ||||||
|  | -- Don't show status line on certain windows | ||||||
|  | vim.cmd [[ autocmd BufEnter,BufWinEnter,WinEnter,CmdwinEnter,TermEnter * 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 ]] | ||||||
							
								
								
									
										15
									
								
								lua/core/init.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								lua/core/init.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | |||||||
|  | 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 | ||||||
|  | 
 | ||||||
|  | -- set all the non plugin mappings | ||||||
|  | require("core.mappings").misc() | ||||||
							
								
								
									
										202
									
								
								lua/core/mappings.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								lua/core/mappings.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,202 @@ | |||||||
|  | local config = require("core.utils").load_config() | ||||||
|  | local maps = config.mappings | ||||||
|  | local plugin_maps = maps.plugin | ||||||
|  | local cmd = vim.cmd | ||||||
|  | 
 | ||||||
|  | local function map(mode, lhs, rhs, opts) | ||||||
|  |    local options = { noremap = true, silent = true } | ||||||
|  |    if opts then | ||||||
|  |       options = vim.tbl_extend("force", options, opts) | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    -- if list of keys provided then run set for all of them | ||||||
|  |    if type(lhs) == "table" then | ||||||
|  |       for _, key in ipairs(lhs) do | ||||||
|  |          vim.api.nvim_set_keymap(mode, key, rhs, options) | ||||||
|  |       end | ||||||
|  |    else | ||||||
|  |       vim.api.nvim_set_keymap(mode, lhs, rhs, options) | ||||||
|  |    end | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | local opt, M = {}, {} | ||||||
|  | 
 | ||||||
|  | -- these mappings will only be called during initialization | ||||||
|  | M.misc = function() | ||||||
|  |    local function non_config_mappings() | ||||||
|  |       -- dont copy any deleted text , this is disabled by default so uncomment the below mappings if you want them | ||||||
|  |       -- map("n", "dd", [=[ "_dd ]=], opt) | ||||||
|  |       -- map("v", "dd", [=[ "_dd ]=], opt) | ||||||
|  |       -- map("v", "x", [=[ "_x ]=], opt) | ||||||
|  |       -- todo: this should be configurable via chadrc | ||||||
|  | 
 | ||||||
|  |       -- Don't copy the replaced text after pasting in visual mode | ||||||
|  |       map("v", "p", '"_dP', opt) | ||||||
|  | 
 | ||||||
|  |       -- 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 | ||||||
|  |       map("", "j", 'v:count ? "j" : "gj"', { expr = true }) | ||||||
|  |       map("", "k", 'v:count ? "k" : "gk"', { expr = true }) | ||||||
|  |       map("", "<Down>", 'v:count ? "j" : "gj"', { expr = true }) | ||||||
|  |       map("", "<Up>", 'v:count ? "k" : "gk"', { expr = true }) | ||||||
|  | 
 | ||||||
|  |       -- use ESC to turn off search highlighting | ||||||
|  |       map("n", "<Esc>", ":noh <CR>", opt) | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    local function optional_mappings() | ||||||
|  |       -- navigation within insert mode | ||||||
|  |       if config.options.insert_nav then | ||||||
|  |          local inav = maps.insert_nav | ||||||
|  | 
 | ||||||
|  |          map("i", inav.backward, "<Left>", opt) | ||||||
|  |          map("i", inav.end_of_line, "<End>", opt) | ||||||
|  |          map("i", inav.forward, "<Right>", opt) | ||||||
|  |          map("i", inav.next_line, "<Up>", opt) | ||||||
|  |          map("i", inav.prev_line, "<Down>", opt) | ||||||
|  |          map("i", inav.top_of_line, "<ESC>^i", opt) | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|  |       -- check the theme toggler | ||||||
|  |       if config.ui.theme_toggler then | ||||||
|  |          map( | ||||||
|  |             "n", | ||||||
|  |             maps.theme_toggler, | ||||||
|  |             ":lua require('nvchad').toggle_theme(require('core.utils').load_config().ui.theme_toggler.fav_themes) <CR>", | ||||||
|  |             opt | ||||||
|  |          ) | ||||||
|  |       end | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    local function required_mappings() | ||||||
|  |       map("n", maps.close_buffer, ":lua require('core.utils').close_buffer() <CR>", opt) -- close  buffer | ||||||
|  |       map("n", maps.copy_whole_file, ":%y+ <CR>", opt) -- copy whole file content | ||||||
|  |       map("n", maps.new_buffer, ":enew <CR>", opt) -- new buffer | ||||||
|  |       map("n", maps.new_tab, ":tabnew <CR>", opt) -- new tabs | ||||||
|  |       map("n", maps.line_number_toggle, ":set nu! <CR>", opt) -- toggle numbers | ||||||
|  |       map("n", maps.save_file, ":w <CR>", opt) -- 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>", opt) | ||||||
|  |       -- hide a term from within terminal mode | ||||||
|  |       map("t", term_maps.esc_hide_termmode, "<C-\\><C-n> :lua require('core.utils').close_buffer() <CR>", opt) | ||||||
|  |       -- pick a hidden term | ||||||
|  |       map("n", term_maps.pick_term, ":Telescope terms <CR>", opt) | ||||||
|  |       -- 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>", | ||||||
|  |          opt | ||||||
|  |       ) | ||||||
|  |       map("n", term_maps.new_vertical, ":execute 'vnew +terminal' | let b:term_type = 'vert' | startinsert <CR>", opt) | ||||||
|  |       map("n", term_maps.new_window, ":execute 'terminal' | let b:term_type = 'wind' | startinsert <CR>", opt) | ||||||
|  |       -- terminal mappings end -- | ||||||
|  | 
 | ||||||
|  |       -- Add Packer commands because we are not loading it at startup | ||||||
|  |       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.update_nvchad, ":NvChadUpdate <CR>", opt) | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    non_config_mappings() | ||||||
|  |    optional_mappings() | ||||||
|  |    required_mappings() | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | -- below are all plugin related mappinsg | ||||||
|  | 
 | ||||||
|  | M.better_escape = function() | ||||||
|  |    vim.g.better_escape_shortcut = plugin_maps.better_escape.esc_insertmode or { "" } | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.bufferline = function() | ||||||
|  |    local m = plugin_maps.bufferline | ||||||
|  | 
 | ||||||
|  |    map("n", m.next_buffer, ":BufferLineCycleNext <CR>", opt) | ||||||
|  |    map("n", m.prev_buffer, ":BufferLineCyclePrev <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.chadsheet = function() | ||||||
|  |    local m = plugin_maps.chadsheet | ||||||
|  | 
 | ||||||
|  |    map("n", m.default_keys, ":lua require('cheatsheet').show_cheatsheet_telescope() <CR>", opt) | ||||||
|  |    map( | ||||||
|  |       "n", | ||||||
|  |       m.user_keys, | ||||||
|  |       ":lua require('cheatsheet').show_cheatsheet_telescope{bundled_cheatsheets = false, bundled_plugin_cheatsheets = false } <CR>", | ||||||
|  |       opt | ||||||
|  |    ) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.comment = function() | ||||||
|  |    local m = plugin_maps.comment.toggle | ||||||
|  |    map("n", m, ":CommentToggle <CR>", opt) | ||||||
|  |    map("v", m, ":CommentToggle <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.dashboard = function() | ||||||
|  |    local m = plugin_maps.dashboard | ||||||
|  | 
 | ||||||
|  |    map("n", m.bookmarks, ":DashboardJumpMarks <CR>", opt) | ||||||
|  |    map("n", m.new_file, ":DashboardNewFile <CR>", opt) | ||||||
|  |    map("n", m.open, ":Dashboard <CR>", opt) | ||||||
|  |    map("n", m.session_load, ":SessionLoad <CR>", opt) | ||||||
|  |    map("n", m.session_save, ":SessionSave <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.nvimtree = function() | ||||||
|  |    map("n", plugin_maps.nvimtree.toggle, ":NvimTreeToggle <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.neoformat = function() | ||||||
|  |    map("n", plugin_maps.neoformat.format, ":Neoformat <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.telescope = function() | ||||||
|  |    local m = plugin_maps.telescope | ||||||
|  | 
 | ||||||
|  |    map("n", m.buffers, ":Telescope buffers <CR>", opt) | ||||||
|  |    map("n", m.find_files, ":Telescope find_files <CR>", opt) | ||||||
|  |    map("n", m.git_commits, ":Telescope git_commits <CR>", opt) | ||||||
|  |    map("n", m.git_status, ":Telescope git_status <CR>", opt) | ||||||
|  |    map("n", m.help_tags, ":Telescope help_tags <CR>", opt) | ||||||
|  |    map("n", m.live_grep, ":Telescope live_grep <CR>", opt) | ||||||
|  |    map("n", m.oldfiles, ":Telescope oldfiles <CR>", opt) | ||||||
|  |    map("n", m.themes, ":Telescope themes <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.telescope_media = function() | ||||||
|  |    local m = plugin_maps.telescope_media | ||||||
|  | 
 | ||||||
|  |    map("n", m.media_files, ":Telescope media_files <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.truezen = function() | ||||||
|  |    local m = plugin_maps.truezen | ||||||
|  | 
 | ||||||
|  |    map("n", m.ataraxis_mode, ":TZAtaraxis <CR>", opt) | ||||||
|  |    map("n", m.focus_mode, ":TZFocus <CR>", opt) | ||||||
|  |    map("n", m.minimalistic_mode, ":TZMinimalist <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.vim_fugitive = function() | ||||||
|  |    local m = plugin_maps.vim_fugitive | ||||||
|  | 
 | ||||||
|  |    map("n", m.git, ":Git <CR>", opt) | ||||||
|  |    map("n", m.git_blame, ":Git blame <CR>", opt) | ||||||
|  |    map("n", m.diff_get_2, ":diffget //2 <CR>", opt) | ||||||
|  |    map("n", m.diff_get_3, ":diffget //3 <CR>", opt) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | return M | ||||||
| @ -4,87 +4,71 @@ local g = vim.g | |||||||
| -- export user config as a global varibale | -- export user config as a global varibale | ||||||
| g.nvchad_user_config = "chadrc" | g.nvchad_user_config = "chadrc" | ||||||
| 
 | 
 | ||||||
| local options = require("utils").load_config().options | local options = require("core.utils").load_config().options | ||||||
| 
 | 
 | ||||||
| opt.completeopt = { "menuone", "noselect" } |  | ||||||
| opt.undofile = options.permanent_undo |  | ||||||
| opt.ruler = options.ruler |  | ||||||
| opt.hidden = options.hidden |  | ||||||
| opt.ignorecase = options.ignorecase |  | ||||||
| opt.splitbelow = true |  | ||||||
| opt.splitright = true |  | ||||||
| opt.termguicolors = true |  | ||||||
| opt.cul = true |  | ||||||
| opt.mouse = options.mouse |  | ||||||
| opt.signcolumn = "yes" |  | ||||||
| opt.cmdheight = options.cmdheight |  | ||||||
| opt.updatetime = options.updatetime -- update interval for gitsigns |  | ||||||
| opt.timeoutlen = options.timeoutlen |  | ||||||
| opt.clipboard = options.clipboard | opt.clipboard = options.clipboard | ||||||
|  | opt.cmdheight = options.cmdheight | ||||||
|  | opt.completeopt = { "menuone", "noselect" } | ||||||
|  | opt.cul = true -- cursor line | ||||||
| 
 | 
 | ||||||
| -- disable nvim intro | -- Indentline | ||||||
| opt.shortmess:append "sI" | 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 | -- disable tilde on end of buffer: https://github.com/  neovim/neovim/pull/8546#issuecomment-643643758 | ||||||
| opt.fillchars = { eob = " " } | opt.fillchars = { eob = " " } | ||||||
| 
 | 
 | ||||||
|  | opt.hidden = options.hidden | ||||||
|  | opt.ignorecase = options.ignorecase | ||||||
|  | opt.mouse = options.mouse | ||||||
|  | 
 | ||||||
| -- Numbers | -- Numbers | ||||||
| opt.number = options.number | opt.number = options.number | ||||||
| opt.numberwidth = options.numberwidth | opt.numberwidth = options.numberwidth | ||||||
| opt.relativenumber = options.relativenumber | opt.relativenumber = options.relativenumber | ||||||
|  | opt.ruler = options.ruler | ||||||
| 
 | 
 | ||||||
| -- Indenline | -- disable nvim intro | ||||||
| opt.expandtab = options.expandtab | opt.shortmess:append "sI" | ||||||
| opt.shiftwidth = options.shiftwidth | opt.signcolumn = "yes" | ||||||
| opt.smartindent = options.smartindent | opt.splitbelow = true | ||||||
|  | opt.splitright = true | ||||||
|  | opt.termguicolors = true | ||||||
|  | opt.timeoutlen = options.timeoutlen | ||||||
|  | opt.undofile = options.permanent_undo | ||||||
|  | 
 | ||||||
|  | -- 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 | -- go to previous/next line with h,l,left arrow and right arrow | ||||||
| -- when cursor reaches end/beginning of line | -- when cursor reaches end/beginning of line | ||||||
| opt.whichwrap:append "<>hl" | opt.whichwrap:append "<>hl" | ||||||
| 
 | 
 | ||||||
| g.mapleader = options.mapleader | g.mapleader = options.mapleader | ||||||
| g.auto_save = options.autosave |  | ||||||
| 
 | 
 | ||||||
| -- disable builtin vim plugins | -- disable some builtin vim plugins | ||||||
| local disabled_built_ins = { | local disabled_built_ins = { | ||||||
|  |    "2html_plugin", | ||||||
|  |    "getscript", | ||||||
|  |    "getscriptPlugin", | ||||||
|  |    "gzip", | ||||||
|  |    "logipat", | ||||||
|    "netrw", |    "netrw", | ||||||
|    "netrwPlugin", |    "netrwPlugin", | ||||||
|    "netrwSettings", |    "netrwSettings", | ||||||
|    "netrwFileHandlers", |    "netrwFileHandlers", | ||||||
|    "gzip", |    "matchit", | ||||||
|    "zip", |  | ||||||
|    "zipPlugin", |  | ||||||
|    "tar", |    "tar", | ||||||
|    "tarPlugin", |    "tarPlugin", | ||||||
|    "getscript", |  | ||||||
|    "getscriptPlugin", |  | ||||||
|    "vimball", |  | ||||||
|    "vimballPlugin", |  | ||||||
|    "2html_plugin", |  | ||||||
|    "logipat", |  | ||||||
|    "rrhelper", |    "rrhelper", | ||||||
|    "spellfile_plugin", |    "spellfile_plugin", | ||||||
|    "matchit", |    "vimball", | ||||||
|  |    "vimballPlugin", | ||||||
|  |    "zip", | ||||||
|  |    "zipPlugin", | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| for _, plugin in pairs(disabled_built_ins) do | for _, plugin in pairs(disabled_built_ins) do | ||||||
|    g["loaded_" .. plugin] = 1 |    g["loaded_" .. plugin] = 1 | ||||||
| end | end | ||||||
| 
 |  | ||||||
| -- 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 |  | ||||||
| vim.cmd [[ au TermOpen term://* setlocal nonumber norelativenumber | setfiletype terminal ]] |  | ||||||
| 
 |  | ||||||
| -- Don't show status line on certain windows |  | ||||||
| vim.cmd [[ autocmd BufEnter,BufWinEnter,WinEnter,CmdwinEnter,TermEnter * lua require("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 ]] |  | ||||||
							
								
								
									
										265
									
								
								lua/core/utils.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										265
									
								
								lua/core/utils.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,265 @@ | |||||||
|  | local M = {} | ||||||
|  | 
 | ||||||
|  | M.close_buffer = function(bufexpr, 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 | ||||||
|  |          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, type = 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)) | ||||||
|  |             -- swtich to another buff | ||||||
|  |             -- TODO switch to next bufffer, 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().ui.plugin.statusline.hidden | ||||||
|  |    local shown = require("core.utils").load_config().ui.plugin.statusline.shown | ||||||
|  |    local api = vim.api | ||||||
|  |    local buftype = api.nvim_buf_get_option("%", "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 | ||||||
|  |    else | ||||||
|  |       api.nvim_set_option("laststatus", 2) | ||||||
|  |    end | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | -- Base code: https://gist.github.com/revolucas/184aec7998a6be5d2f61b984fac1d7f7 | ||||||
|  | -- Changes over it: preserving table 1 contents and also update with table b, without duplicating | ||||||
|  | -- 1st arg - base table | ||||||
|  | -- 2nd arg - table to merge | ||||||
|  | -- 3rg arg - list of nodes as a table, if the node is found replace the from table2 to result, rather than adding the value | ||||||
|  | -- e.g: merge_table(t1, t2, { ['plugin']['truezen']['mappings'] }) | ||||||
|  | M.merge_table = function(into, from, nodes_to_replace) | ||||||
|  |    -- make sure both are table | ||||||
|  |    if type(into) ~= "table" or type(from) ~= "table" then | ||||||
|  |       return into | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    local stack, seen = {}, {} | ||||||
|  |    local table1, table2 = into, from | ||||||
|  | 
 | ||||||
|  |    if type(nodes_to_replace) == "table" then | ||||||
|  |       -- function that will be executed with loadstring | ||||||
|  |       local base_fn = [[ | ||||||
|  | return function(table1, table2) | ||||||
|  |    local t1, t2 = table1_node or false , table2_node or false | ||||||
|  |    if t1 and t2 then | ||||||
|  |       table1_node = table2_node | ||||||
|  |    end | ||||||
|  |    return table1 | ||||||
|  | end]] | ||||||
|  |       for _, node in ipairs(nodes_to_replace) do | ||||||
|  |          -- replace the _node in base_fn to actual given node value | ||||||
|  |          local fn = base_fn:gsub("_node", node) | ||||||
|  |          -- if the node if found, it is replaced, otherwise table 1 is returned | ||||||
|  |          table1 = loadstring(fn)()(table1, table2) | ||||||
|  |       end | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    while true do | ||||||
|  |       for k, v in pairs(table2) do | ||||||
|  |          if type(v) == "table" and type(table1[k]) == "table" then | ||||||
|  |             table.insert(stack, { table1[k], table2[k] }) | ||||||
|  |          else | ||||||
|  |             local present = seen[v] or false | ||||||
|  |             if not present then | ||||||
|  |                if type(k) == "number" then | ||||||
|  |                   -- add the value to seen table until value is found | ||||||
|  |                   -- only do when key is number we just want to append to subtables | ||||||
|  |                   -- todo: maybe improve this | ||||||
|  | 
 | ||||||
|  |                   for _, value in pairs(table1) do | ||||||
|  |                      if value == v then | ||||||
|  |                         present = true | ||||||
|  |                         break | ||||||
|  |                      end | ||||||
|  |                   end | ||||||
|  |                   seen[v] = true | ||||||
|  |                   if not present then | ||||||
|  |                      table1[#table1 + 1] = v | ||||||
|  |                   end | ||||||
|  |                else | ||||||
|  |                   table1[k] = v | ||||||
|  |                end | ||||||
|  |             end | ||||||
|  |          end | ||||||
|  |       end | ||||||
|  |       if #stack > 0 then | ||||||
|  |          local t = stack[#stack] | ||||||
|  |          table1, table2 = t[1], t[2] | ||||||
|  |          stack[#stack] = nil | ||||||
|  |       else | ||||||
|  |          break | ||||||
|  |       end | ||||||
|  |    end | ||||||
|  |    return into | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | -- load config | ||||||
|  | -- 1st arg = boolean - whether to force reload | ||||||
|  | -- Modifies _G._NVCHAD_CONFIG global variable | ||||||
|  | M.load_config = function(reload) | ||||||
|  |    -- only do the stuff below one time, otherwise just return the set config | ||||||
|  |    if _G._NVCHAD_CONFIG_CONTENTS ~= nil and not (reload or false) then | ||||||
|  |       return _G._NVCHAD_CONFIG_CONTENTS | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    -- these are the table value which will be always prioritiezed to take user config value | ||||||
|  |    local to_replace = { | ||||||
|  |       "['mappings']['plugin']['esc_insertmode']", | ||||||
|  |       "['mappings']['terminal']['esc_termmode']", | ||||||
|  |       "['mappings']['terminal']['esc_hide_termmode']", | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    local default_config = "default_config" | ||||||
|  |    local config_name = vim.g.nvchad_user_config or "chadrc" | ||||||
|  |    local config_file = vim.fn.stdpath "config" .. "/lua/" .. config_name .. ".lua" | ||||||
|  | 
 | ||||||
|  |    -- unload the modules if force reload | ||||||
|  |    if reload then | ||||||
|  |       package.loaded[default_config or false] = nil | ||||||
|  |       package.loaded[config_name or false] = nil | ||||||
|  |    end | ||||||
|  | 
 | ||||||
|  |    -- don't enclose in pcall, it better break when default config is faulty | ||||||
|  |    _G._NVCHAD_CONFIG_CONTENTS = require(default_config) | ||||||
|  | 
 | ||||||
|  |    -- user config is not required to run nvchad but a optional | ||||||
|  |    -- Make sure the config doesn't break the whole system if user config is not present or in bad state or not a table | ||||||
|  |    -- print warning texts if user config file is  present | ||||||
|  |    -- check if the user config is present | ||||||
|  |    if vim.fn.empty(vim.fn.glob(config_file)) < 1 then | ||||||
|  |       local present, config = pcall(require, config_name) | ||||||
|  |       if present then | ||||||
|  |          -- make sure the returned value is table | ||||||
|  |          if type(config) == "table" then | ||||||
|  |             -- data = require(config_name) | ||||||
|  |             _G._NVCHAD_CONFIG_CONTENTS = require("core.utils").merge_table( | ||||||
|  |                _G._NVCHAD_CONFIG_CONTENTS, | ||||||
|  |                config, | ||||||
|  |                to_replace | ||||||
|  |             ) | ||||||
|  |          else | ||||||
|  |             print("Warning: " .. config_name .. " sourced successfully but did not return a lua table.") | ||||||
|  |          end | ||||||
|  |       else | ||||||
|  |          print("Warning: " .. config_file .. " is present but sourcing failed.") | ||||||
|  |       end | ||||||
|  |    end | ||||||
|  |    return _G._NVCHAD_CONFIG_CONTENTS | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | return M | ||||||
| @ -3,162 +3,190 @@ | |||||||
| local M = {} | local M = {} | ||||||
| 
 | 
 | ||||||
| M.ui = { | M.ui = { | ||||||
|  |    italic_comments = false, | ||||||
|  | 
 | ||||||
|  |    -- theme to be used, to see all available themes, open the theme switcher by <leader> + th | ||||||
|    theme = "onedark", |    theme = "onedark", | ||||||
| 
 | 
 | ||||||
|    -- theme toggle |    -- theme toggler, toggle between two themes, see theme_toggleer mappings | ||||||
|    theme_toggler = false, |    theme_toggler = { | ||||||
|    fav_themes = { |       enabled = false, | ||||||
|       "onedark", |       fav_themes = { | ||||||
|       "gruvchad", |          "onedark", | ||||||
|  |          "gruvchad", | ||||||
|  |       }, | ||||||
|    }, |    }, | ||||||
|    italic_comments = false, |  | ||||||
| 
 | 
 | ||||||
|    -- Enable this only if your terminal has the colorscheme set which nvchad uses |    -- Enable this only if your terminal has the colorscheme set which nvchad uses | ||||||
|    -- For Ex : if you have onedark set in nvchad , set onedark's bg color on your terminal |    -- For Ex : if you have onedark set in nvchad , set onedark's bg color on your terminal | ||||||
|    transparency = false, |    transparency = false, | ||||||
| 
 | 
 | ||||||
|    -- statusline related options |    -- plugin related ui options | ||||||
|    statusline = { |    plugin = { | ||||||
|       -- these are filetypes, not pattern matched |       -- statusline related options | ||||||
|       -- if a filetype is present in shown, it will always show the statusline, irrespective of filetypes in hidden |       statusline = { | ||||||
|       hidden = { |          -- these are filetypes, not pattern matched | ||||||
|          "NvimTree", |          -- if a filetype is present in shown, it will always show the statusline, irrespective of filetypes in hidden | ||||||
|          "terminal", |          hidden = { | ||||||
|  |             "NvimTree", | ||||||
|  |             "terminal", | ||||||
|  |          }, | ||||||
|  |          shown = {}, | ||||||
|  |          -- default, round , slant , block , arrow | ||||||
|  |          style = "default", | ||||||
|       }, |       }, | ||||||
|       shown = {}, |  | ||||||
|       style = "default", -- default, round , slant , block , arrow |  | ||||||
|    }, |    }, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| M.options = { | M.options = { | ||||||
|    permanent_undo = true, |    clipboard = "unnamedplus", | ||||||
|    ruler = false, |    cmdheight = 1, | ||||||
|  |    expandtab = true, | ||||||
|    hidden = true, |    hidden = true, | ||||||
|    ignorecase = true, |    ignorecase = true, | ||||||
|  |    insert_nav = true, -- navigation in insertmode | ||||||
|  |    mapleader = " ", | ||||||
|    mouse = "a", |    mouse = "a", | ||||||
|    cmdheight = 1, |  | ||||||
|    updatetime = 250, |  | ||||||
|    timeoutlen = 400, |  | ||||||
|    clipboard = "unnamedplus", |  | ||||||
|    number = true, |    number = true, | ||||||
|    -- relative numbers in normal mode tool at the bottom of options.lua |    -- relative numbers in normal mode tool at the bottom of options.lua | ||||||
|    relativenumber = false, |  | ||||||
|    numberwidth = 2, |    numberwidth = 2, | ||||||
|    expandtab = true, |    permanent_undo = true, | ||||||
|    shiftwidth = 2, |    shiftwidth = 2, | ||||||
|    smartindent = true, |    smartindent = true, | ||||||
|    mapleader = " ", |    timeoutlen = 400, | ||||||
|    autosave = false, |    relativenumber = false, | ||||||
|    enable_insertNav = true, -- navigation in insertmode |    ruler = false, | ||||||
|  |    updatetime = 250, | ||||||
|    -- used for updater |    -- used for updater | ||||||
|    update_url = "https://github.com/NvChad/NvChad", |    update_url = "https://github.com/NvChad/NvChad", | ||||||
|    update_branch = "main", |    update_branch = "main", | ||||||
|  | 
 | ||||||
|  |    -- these are plugin related options | ||||||
|  |    plugin = { | ||||||
|  |       autosave = false, -- autosave on changed text or insert mode leave | ||||||
|  |       -- timeout to be used for using escape with a key combination, see mappings.plugin.better_escape | ||||||
|  |       esc_insertmode_timeout = 300, | ||||||
|  |    }, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| -- enable and disable plugins (false for disable) | -- enable and disable plugins (false for disable) | ||||||
| M.plugin_status = { | M.plugin_status = { | ||||||
|    -- UI |    autosave = true, -- to autosave files | ||||||
|    nvim_bufferline = true, |    blankline = true, -- beautified blank lines | ||||||
|    galaxyline = true, |    bufferline = true, -- buffer shown as tabs | ||||||
|    nvim_colorizer = true, |    cheatsheet = true, -- fuzzy search your commands/keymappings | ||||||
|    dashboard_nvim = true, |    colorizer = true, | ||||||
|    blankline = true, |    comment = true, -- universal commentor | ||||||
|    truezen_nvim = true, |    dashboard = true, -- a nice looking dashboard | ||||||
|    better_esc = true, |    esc_insertmode = true, -- escape from insert mode using custom keys | ||||||
|    -- lsp stuff |    galaxyline = true, -- statusline | ||||||
|    lspkind = true, |    gitsigns = true, -- gitsigns in statusline | ||||||
|    lspsignature = true, |    lspkind = true, -- lsp enhancements | ||||||
|    -- git stuff |    lspsignature = true, -- lsp enhancements | ||||||
|    gitsigns = true, |    neoformat = true, -- universal formatter | ||||||
|    vim_fugitive = true, |    neoscroll = true, -- smooth scroll | ||||||
|    -- misc |    telescope_media = true, -- see media files in telescope picker | ||||||
|    neoformat = true, |    truezen = true, -- no distraction mode for nvim | ||||||
|    vim_matchup = true, |    vim_fugitive = true, -- git in nvim | ||||||
|    autosave_nvim = true, |    vim_matchup = true, -- % magic, match it but improved | ||||||
|    nvim_comment = true, |  | ||||||
|    neoscroll_nvim = true, |  | ||||||
|    telescope_media = true, |  | ||||||
|    cheatsheet = true, |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| -- make sure you dont use same keys twice | -- make sure you dont use same keys twice | ||||||
| M.mappings = { | M.mappings = { | ||||||
|    -- plugin specific |    -- close current focused buffer | ||||||
|    truezen = { |    close_buffer = "<leader>x", | ||||||
|       ataraxisMode = "<leader>zz", |    copy_whole_file = "<C-a>", -- copy all contents of the current buffer | ||||||
|       minimalisticmode = "<leader>zm", | 
 | ||||||
|       focusmode = "<leader>zf", |    -- navigation in insert mode, only if enabled in options | ||||||
|    }, |  | ||||||
|    comment_nvim = { |  | ||||||
|       comment_toggle = "<leader>/", |  | ||||||
|    }, |  | ||||||
|    nvimtree = { |  | ||||||
|       treetoggle = "<C-n>", -- file manager |  | ||||||
|    }, |  | ||||||
|    neoformat = { |  | ||||||
|       format = "<leader>fm", |  | ||||||
|    }, |  | ||||||
|    dashboard = { |  | ||||||
|       open = "<leader>db", |  | ||||||
|       newfile = "<leader>fn", |  | ||||||
|       bookmarks = "<leader>bm", |  | ||||||
|       sessionload = "<leader>l", |  | ||||||
|       sessionsave = "<leader>s", |  | ||||||
|    }, |  | ||||||
|    telescope = { |  | ||||||
|       live_grep = "<leader>fw", |  | ||||||
|       git_status = "<leader>gt", |  | ||||||
|       git_commits = "<leader>cm", |  | ||||||
|       find_files = "<leader>ff", |  | ||||||
|       buffers = "<leader>fb", |  | ||||||
|       help_tags = "<leader>fh", |  | ||||||
|       oldfiles = "<leader>fo", |  | ||||||
|       themes = "<leader>th", |  | ||||||
|    }, |  | ||||||
|    telescope_media = { |  | ||||||
|       media_files = "<leader>fp", |  | ||||||
|    }, |  | ||||||
|    chadsheet = { |  | ||||||
|       default_keys = "<leader>dk", |  | ||||||
|       user_keys = "<leader>uk", |  | ||||||
|    }, |  | ||||||
|    bufferline = { |  | ||||||
|       new_buffer = "<S-t>", |  | ||||||
|       newtab = "<C-t>b", |  | ||||||
|       close = "<S-x>", -- close a buffer with custom func in utils.lua |  | ||||||
|       cycleNext = "<TAB>", -- next buffer |  | ||||||
|       cyclePrev = "<S-Tab>", -- previous buffer |  | ||||||
|    }, |  | ||||||
|    fugitive = { |  | ||||||
|       Git = "<leader>gs", |  | ||||||
|       diffget_2 = "<leader>gh", |  | ||||||
|       diffget_3 = "<leader>gl", |  | ||||||
|       git_blame = "<leader>gb", |  | ||||||
|    }, |  | ||||||
|    terms = { -- below are NvChad mappings, not plugin mappings |  | ||||||
|       esc_termmode = "jk", |  | ||||||
|       esc_hide_termmode = "JK", |  | ||||||
|       pick_term = "<leader>W", -- note: this is a telescope extension |  | ||||||
|       new_wind = "<leader>w", |  | ||||||
|       new_vert = "<leader>v", |  | ||||||
|       new_hori = "<leader>h", |  | ||||||
|    }, -- navigation in insert mode |  | ||||||
|    insert_nav = { |    insert_nav = { | ||||||
|       forward = "<C-l>", |  | ||||||
|       backward = "<C-h>", |       backward = "<C-h>", | ||||||
|       top_of_line = "<C-a>", |  | ||||||
|       end_of_line = "<C-e>", |       end_of_line = "<C-e>", | ||||||
|       prev_line = "<C-j>", |       forward = "<C-l>", | ||||||
|       next_line = "<C-k>", |       next_line = "<C-k>", | ||||||
|  |       prev_line = "<C-j>", | ||||||
|  |       top_of_line = "<C-a>", | ||||||
|    }, |    }, | ||||||
|    -- non plugin | 
 | ||||||
|    misc = { |    line_number_toggle = "<leader>n", -- show or hide line number | ||||||
|       esc_Termmode = "jk", -- get out of terminal mode |    new_buffer = "<S-t>", -- open a new buffer | ||||||
|       close_buffer = "<leader>x", -- close current focused buffer |    new_tab = "<C-t>b", -- open a new vim tab | ||||||
|       copywhole_file = "<C-a>", |    save_file = "<C-s>", -- save file using :w | ||||||
|       toggle_linenr = "<leader>n", -- show or hide line number |    theme_toggler = "<leader>tt", -- for theme toggler, see in ui.theme_toggler | ||||||
|       theme_toggle = "<leader>tt", | 
 | ||||||
|       update_nvchad = "<leader>uu", |    -- terminal related mappings | ||||||
|  |    terminal = { | ||||||
|  |       -- multiple mappings can be given for esc_termmode and esc_hide_termmode | ||||||
|  |       -- get out of terminal mode | ||||||
|  |       esc_termmode = { "jk" }, -- multiple mappings allowed | ||||||
|  |       -- get out of terminal mode and hide it | ||||||
|  |       -- it does not close it, see pick_term mapping to see hidden terminals | ||||||
|  |       esc_hide_termmode = { "JK" }, -- multiple mappings allowed | ||||||
|  |       -- show hidden terminal buffers in a telescope picker | ||||||
|  |       pick_term = "<leader>W", | ||||||
|  |       -- below three are for spawning terminals | ||||||
|  |       new_horizontal = "<leader>h", | ||||||
|  |       new_vertical = "<leader>v", | ||||||
|  |       new_window = "<leader>w", | ||||||
|  |    }, | ||||||
|  | 
 | ||||||
|  |    -- update nvchad from nvchad, chadness 101 | ||||||
|  |    update_nvchad = "<leader>uu", | ||||||
|  | 
 | ||||||
|  |    -- all plugins related mappings | ||||||
|  |    -- to get short info about a plugin, see the respective string in plugin_status, if not present, then info here | ||||||
|  |    plugin = { | ||||||
|  |       bufferline = { | ||||||
|  |          next_buffer = "<TAB>", -- next buffer | ||||||
|  |          prev_buffer = "<S-Tab>", -- previous buffer | ||||||
|  |       }, | ||||||
|  |       chadsheet = { | ||||||
|  |          default_keys = "<leader>dk", | ||||||
|  |          user_keys = "<leader>uk", | ||||||
|  |       }, | ||||||
|  |       comment = { | ||||||
|  |          toggle = "<leader>/", -- trigger comment on a single/selected lines/number prefix | ||||||
|  |       }, | ||||||
|  |       dashboard = { | ||||||
|  |          bookmarks = "<leader>bm", | ||||||
|  |          new_file = "<leader>fn", -- basically create a new buffer | ||||||
|  |          open = "<leader>db", -- open dashboard | ||||||
|  |          session_load = "<leader>l", -- load a saved session | ||||||
|  |          session_save = "<leader>s", -- save a session | ||||||
|  |       }, | ||||||
|  |       -- note: this is an edditional mapping to escape, escape key will still work | ||||||
|  |       better_escape = { | ||||||
|  |          esc_insertmode = { "jk" }, -- multiple mappings allowed | ||||||
|  |       }, | ||||||
|  |       nvimtree = { | ||||||
|  |          toggle = "<C-n>", -- file manager | ||||||
|  |       }, | ||||||
|  |       neoformat = { | ||||||
|  |          format = "<leader>fm", | ||||||
|  |       }, | ||||||
|  |       telescope = { | ||||||
|  |          buffers = "<leader>fb", | ||||||
|  |          find_files = "<leader>ff", | ||||||
|  |          git_commits = "<leader>cm", | ||||||
|  |          git_status = "<leader>gt", | ||||||
|  |          help_tags = "<leader>fh", | ||||||
|  |          live_grep = "<leader>fw", | ||||||
|  |          oldfiles = "<leader>fo", | ||||||
|  |          themes = "<leader>th", | ||||||
|  |       }, | ||||||
|  |       telescope_media = { | ||||||
|  |          media_files = "<leader>fp", | ||||||
|  |       }, | ||||||
|  |       truezen = { -- distraction free modes mapping, hide statusline, tabline, line numbers | ||||||
|  |          ataraxis_mode = "<leader>zz", -- center | ||||||
|  |          focus_mode = "<leader>zf", | ||||||
|  |          minimalistic_mode = "<leader>zm", -- as it is | ||||||
|  |       }, | ||||||
|  |       vim_fugitive = { | ||||||
|  |          diff_get_2 = "<leader>gh", | ||||||
|  |          diff_get_3 = "<leader>gl", | ||||||
|  |          git = "<leader>gs", | ||||||
|  |          git_blame = "<leader>gb", | ||||||
|  |       }, | ||||||
|    }, |    }, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										188
									
								
								lua/mappings.lua
									
									
									
									
									
								
							
							
						
						
									
										188
									
								
								lua/mappings.lua
									
									
									
									
									
								
							| @ -1,188 +0,0 @@ | |||||||
| local user_map = require("utils").load_config().mappings |  | ||||||
| local miscMap = user_map.misc |  | ||||||
| 
 |  | ||||||
| local cmd = vim.cmd |  | ||||||
| 
 |  | ||||||
| local function map(mode, lhs, rhs, opts) |  | ||||||
|    local options = { noremap = true, silent = true } |  | ||||||
|    if opts then |  | ||||||
|       options = vim.tbl_extend("force", options, opts) |  | ||||||
|    end |  | ||||||
|    vim.api.nvim_set_keymap(mode, lhs, rhs, options) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| local M = {} |  | ||||||
| local opt = {} |  | ||||||
| 
 |  | ||||||
| -- these mappings will only be called during initialization |  | ||||||
| M.misc = function() |  | ||||||
|    -- dont copy any deleted text , this is disabled by default so uncomment the below mappings if you want them |  | ||||||
|    -- map("n", "dd", [=[ "_dd ]=], opt) |  | ||||||
|    -- map("v", "dd", [=[ "_dd ]=], opt) |  | ||||||
|    -- map("v", "x", [=[ "_x ]=], opt) |  | ||||||
|    -- todo: this should be configurable via chadrc |  | ||||||
| 
 |  | ||||||
|    -- Don't copy the replaced text after pasting in visual mode |  | ||||||
|    map("v", "p", '"_dP', opt) |  | ||||||
| 
 |  | ||||||
|    -- 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 |  | ||||||
|    map("", "j", 'v:count ? "j" : "gj"', { expr = true }) |  | ||||||
|    map("", "k", 'v:count ? "k" : "gk"', { expr = true }) |  | ||||||
|    map("", "<Down>", 'v:count ? "j" : "gj"', { expr = true }) |  | ||||||
|    map("", "<Up>", 'v:count ? "k" : "gk"', { expr = true }) |  | ||||||
| 
 |  | ||||||
|    -- copy whole file content |  | ||||||
|    map("n", miscMap.copywhole_file, ":%y+<CR>", opt) |  | ||||||
| 
 |  | ||||||
|    -- toggle numbers |  | ||||||
|    map("n", miscMap.toggle_linenr, ":set nu!<CR>", opt) |  | ||||||
| 
 |  | ||||||
|    -- terminals |  | ||||||
|    local function terms() |  | ||||||
|       local m = user_map.terms |  | ||||||
| 
 |  | ||||||
|       -- get out of terminal mode |  | ||||||
|       map("t", m.esc_termmode, "<C-\\><C-n>", opt) |  | ||||||
|       -- hide a term from within terminal mode |  | ||||||
|       map("t", m.esc_hide_termmode, "<C-\\><C-n> :lua require('utils').close_buffer() <CR>", opt) |  | ||||||
|       -- pick a hidden term |  | ||||||
|       map("n", m.pick_term, ":Telescope terms <CR>", opt) |  | ||||||
| 
 |  | ||||||
|       -- Open terminals |  | ||||||
|       -- TODO this opens on top of an existing vert/hori term, fixme |  | ||||||
|       map("n", m.new_wind, ":execute 'terminal' | let b:term_type = 'wind' | startinsert <CR>", opt) |  | ||||||
|       map("n", m.new_vert, ":execute 'vnew +terminal' | let b:term_type = 'vert' | startinsert <CR>", opt) |  | ||||||
|       map("n", m.new_hori, ":execute 15 .. 'new +terminal' | let b:term_type = 'hori' | startinsert <CR>", opt) |  | ||||||
|    end |  | ||||||
|    terms() |  | ||||||
| 
 |  | ||||||
|    -- ctrl + s to save file |  | ||||||
|    map("n", "<C-s>", ":w <CR>", opt) |  | ||||||
| 
 |  | ||||||
|    -- use ESC to turn off search highlighting |  | ||||||
|    map("n", "<Esc>", ":noh<CR>", opt) |  | ||||||
| 
 |  | ||||||
|    -- navigation within insert mode |  | ||||||
|    local check_insertNav = require("utils").load_config().options.enable_insertNav |  | ||||||
| 
 |  | ||||||
|    if check_insertNav == true then |  | ||||||
|       local m = user_map.insert_nav |  | ||||||
| 
 |  | ||||||
|       map("i", m.forward, "<Right>", opt) |  | ||||||
|       map("i", m.backward, "<Left>", opt) |  | ||||||
|       map("i", m.top_of_line, "<ESC>^i", opt) |  | ||||||
|       map("i", m.end_of_line, "<End>", opt) |  | ||||||
|       map("i", m.next_line, "<Up>", opt) |  | ||||||
|       map("i", m.prev_line, "<Down>", opt) |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    -- check the theme toggler |  | ||||||
|    local theme_toggler = require("utils").load_config().ui.theme_toggler |  | ||||||
|    if theme_toggler == true then |  | ||||||
|       local m = user_map.misc.theme_toggle |  | ||||||
| 
 |  | ||||||
|       map("n", m, ":lua require('utils').toggle_theme(require('utils').load_config().ui.fav_themes)<CR>", opt) |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    -- Packer commands till because we are not loading it at startup |  | ||||||
|    cmd "silent! command PackerCompile lua require 'pluginList' require('packer').compile()" |  | ||||||
|    cmd "silent! command PackerInstall lua require 'pluginList' require('packer').install()" |  | ||||||
|    cmd "silent! command PackerStatus lua require 'pluginList' require('packer').status()" |  | ||||||
|    cmd "silent! command PackerSync lua require 'pluginList' require('packer').sync()" |  | ||||||
|    cmd "silent! command PackerUpdate lua require 'pluginList' require('packer').update()" |  | ||||||
| 
 |  | ||||||
|    -- add NvChadUpdate command and mapping |  | ||||||
|    cmd "silent! command! NvChadUpdate lua require('utils').update_nvchad()" |  | ||||||
|    map("n", user_map.misc.update_nvchad, ":NvChadUpdate<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.bufferline = function() |  | ||||||
|    local m = user_map.bufferline |  | ||||||
| 
 |  | ||||||
|    map("n", m.new_buffer, ":enew<CR>", opt) -- new buffer |  | ||||||
|    map("n", m.newtab, ":tabnew<CR>", opt) -- new tab |  | ||||||
|    map("n", m.close, ":lua require('utils').close_buffer() <CR>", opt) -- close  buffer |  | ||||||
| 
 |  | ||||||
|    -- move between tabs |  | ||||||
| 
 |  | ||||||
|    map("n", m.cycleNext, ":BufferLineCycleNext<CR>", opt) |  | ||||||
|    map("n", m.cyclePrev, ":BufferLineCyclePrev<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.chadsheet = function() |  | ||||||
|    local m = user_map.chadsheet |  | ||||||
| 
 |  | ||||||
|    map("n", m.default_keys, ":lua require('cheatsheet').show_cheatsheet_telescope()<CR>", opt) |  | ||||||
|    map( |  | ||||||
|       "n", |  | ||||||
|       m.user_keys, |  | ||||||
|       ":lua require('cheatsheet').show_cheatsheet_telescope{bundled_cheatsheets = false, bundled_plugin_cheatsheets = false }<CR>", |  | ||||||
|       opt |  | ||||||
|    ) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.comment_nvim = function() |  | ||||||
|    local m = user_map.comment_nvim.comment_toggle |  | ||||||
|    map("n", m, ":CommentToggle<CR>", opt) |  | ||||||
|    map("v", m, ":CommentToggle<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.dashboard = function() |  | ||||||
|    local m = user_map.dashboard |  | ||||||
| 
 |  | ||||||
|    map("n", m.open, ":Dashboard<CR>", opt) |  | ||||||
|    map("n", m.newfile, ":DashboardNewFile<CR>", opt) |  | ||||||
|    map("n", m.bookmarks, ":DashboardJumpMarks<CR>", opt) |  | ||||||
|    map("n", m.sessionload, ":SessionLoad<CR>", opt) |  | ||||||
|    map("n", m.sessionsave, ":SessionSave<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.fugitive = function() |  | ||||||
|    local m = user_map.fugitive |  | ||||||
| 
 |  | ||||||
|    map("n", m.Git, ":Git<CR>", opt) |  | ||||||
|    map("n", m.diffget_2, ":diffget //2<CR>", opt) |  | ||||||
|    map("n", m.diffget_3, ":diffget //3<CR>", opt) |  | ||||||
|    map("n", m.git_blame, ":Git blame<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.nvimtree = function() |  | ||||||
|    local m = user_map.nvimtree.treetoggle |  | ||||||
| 
 |  | ||||||
|    map("n", m, ":NvimTreeToggle<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.neoformat = function() |  | ||||||
|    local m = user_map.neoformat.format |  | ||||||
|    map("n", m, ":Neoformat<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.truezen = function() |  | ||||||
|    local m = user_map.truezen |  | ||||||
| 
 |  | ||||||
|    map("n", m.ataraxisMode, ":TZAtaraxis<CR>", opt) |  | ||||||
|    map("n", m.minimalisticmode, ":TZMinimalist<CR>", opt) |  | ||||||
|    map("n", m.focusmode, ":TZFocus<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.telescope = function() |  | ||||||
|    local m = user_map.telescope |  | ||||||
| 
 |  | ||||||
|    map("n", m.live_grep, ":Telescope live_grep<CR>", opt) |  | ||||||
|    map("n", m.git_status, ":Telescope git_status <CR>", opt) |  | ||||||
|    map("n", m.git_commits, ":Telescope git_commits <CR>", opt) |  | ||||||
|    map("n", m.find_files, ":Telescope find_files <CR>", opt) |  | ||||||
|    map("n", m.buffers, ":Telescope buffers<CR>", opt) |  | ||||||
|    map("n", m.help_tags, ":Telescope help_tags<CR>", opt) |  | ||||||
|    map("n", m.oldfiles, ":Telescope oldfiles<CR>", opt) |  | ||||||
|    map("n", m.themes, ":Telescope themes<CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.telescope_media = function() |  | ||||||
|    local m = user_map.telescope_media |  | ||||||
|    map("n", m.media_files, ":Telescope media_files <CR>", opt) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| return M |  | ||||||
| @ -1,25 +0,0 @@ | |||||||
| local present, chadsheet = pcall(require, "cheatsheet") |  | ||||||
| 
 |  | ||||||
| if not present then |  | ||||||
|    return |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| local mappings = require("utils").load_config().mappings |  | ||||||
| 
 |  | ||||||
| -- add user mappings to the cheetsheet |  | ||||||
| for section, data in pairs(mappings) do |  | ||||||
|    for description, keymap in pairs(data) do |  | ||||||
|       chadsheet.add_cheat(description, keymap, section) |  | ||||||
|    end |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| require("cheatsheet").setup { |  | ||||||
| 
 |  | ||||||
|    bundled_cheatsheets = { |  | ||||||
|       enabled = { "default" }, |  | ||||||
|       disabled = { "unicode", "nerd-fonts" }, |  | ||||||
|    }, |  | ||||||
| 
 |  | ||||||
|    bundled_plugin_cheatsheets = false, |  | ||||||
|    include_only_installed_plugins = true, |  | ||||||
| } |  | ||||||
| @ -7,6 +7,6 @@ end | |||||||
| 
 | 
 | ||||||
| autopairs.setup() | autopairs.setup() | ||||||
| autopairs_completion.setup { | autopairs_completion.setup { | ||||||
|    map_cr = true, |  | ||||||
|    map_complete = true, -- insert () func completion |    map_complete = true, -- insert () func completion | ||||||
|  |    map_cr = true, | ||||||
| } | } | ||||||
| @ -5,7 +5,7 @@ if not present then | |||||||
| end | end | ||||||
| 
 | 
 | ||||||
| autosave.setup { | autosave.setup { | ||||||
|    enabled = vim.g.auto_save, -- takes boolean value from init.lua |    enabled = vim.g.auto_save or false, -- takes boolean value from init.lua | ||||||
|    execution_message = "autosaved at : " .. vim.fn.strftime "%H:%M:%S", |    execution_message = "autosaved at : " .. vim.fn.strftime "%H:%M:%S", | ||||||
|    events = { "InsertLeave", "TextChanged" }, |    events = { "InsertLeave", "TextChanged" }, | ||||||
|    conditions = { |    conditions = { | ||||||
| @ -13,7 +13,7 @@ autosave.setup { | |||||||
|       filetype_is_not = {}, |       filetype_is_not = {}, | ||||||
|       modifiable = true, |       modifiable = true, | ||||||
|    }, |    }, | ||||||
|    write_all_buffers = false, |  | ||||||
|    on_off_commands = true, |  | ||||||
|    clean_command_line_interval = 2500, |    clean_command_line_interval = 2500, | ||||||
|  |    on_off_commands = true, | ||||||
|  |    write_all_buffers = false, | ||||||
| } | } | ||||||
| @ -1,5 +1,4 @@ | |||||||
| local global_theme = "themes/" .. vim.g.nvchad_theme | local colors = require("colors").get() | ||||||
| local colors = require(global_theme) |  | ||||||
| 
 | 
 | ||||||
| local present, bufferline = pcall(require, "bufferline") | local present, bufferline = pcall(require, "bufferline") | ||||||
| if not present then | if not present then | ||||||
| @ -43,24 +42,71 @@ bufferline.setup { | |||||||
|       end, |       end, | ||||||
|    }, |    }, | ||||||
|    highlights = { |    highlights = { | ||||||
|       fill = { |  | ||||||
|          guifg = colors.grey_fg, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       background = { |       background = { | ||||||
|          guifg = colors.grey_fg, |          guifg = colors.grey_fg, | ||||||
|          guibg = colors.black2, |          guibg = colors.black2, | ||||||
|       }, |       }, | ||||||
|  | 
 | ||||||
|       -- buffers |       -- buffers | ||||||
|       buffer_visible = { |  | ||||||
|          guifg = colors.light_grey, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       buffer_selected = { |       buffer_selected = { | ||||||
|          guifg = colors.white, |          guifg = colors.white, | ||||||
|          guibg = colors.black, |          guibg = colors.black, | ||||||
|          gui = "bold", |          gui = "bold", | ||||||
|       }, |       }, | ||||||
|  |       buffer_visible = { | ||||||
|  |          guifg = colors.light_grey, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|  | 
 | ||||||
|  |       -- close buttons | ||||||
|  |       close_button = { | ||||||
|  |          guifg = colors.light_grey, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|  |       close_button_visible = { | ||||||
|  |          guifg = colors.light_grey, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|  |       close_button_selected = { | ||||||
|  |          guifg = colors.red, | ||||||
|  |          guibg = colors.black, | ||||||
|  |       }, | ||||||
|  |       fill = { | ||||||
|  |          guifg = colors.grey_fg, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|  |       indicator_selected = { | ||||||
|  |          guifg = colors.black, | ||||||
|  |          guibg = colors.black, | ||||||
|  |       }, | ||||||
|  | 
 | ||||||
|  |       -- modified | ||||||
|  |       modified = { | ||||||
|  |          guifg = colors.red, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|  |       modified_visible = { | ||||||
|  |          guifg = colors.red, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|  |       modified_selected = { | ||||||
|  |          guifg = colors.green, | ||||||
|  |          guibg = colors.black, | ||||||
|  |       }, | ||||||
|  | 
 | ||||||
|  |       -- separators | ||||||
|  |       separator = { | ||||||
|  |          guifg = colors.black2, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|  |       separator_visible = { | ||||||
|  |          guifg = colors.black2, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|  |       separator_selected = { | ||||||
|  |          guifg = colors.black2, | ||||||
|  |          guibg = colors.black2, | ||||||
|  |       }, | ||||||
|       -- tabs |       -- tabs | ||||||
|       tab = { |       tab = { | ||||||
|          guifg = colors.light_grey, |          guifg = colors.light_grey, | ||||||
| @ -74,49 +120,5 @@ bufferline.setup { | |||||||
|          guifg = colors.red, |          guifg = colors.red, | ||||||
|          guibg = colors.black, |          guibg = colors.black, | ||||||
|       }, |       }, | ||||||
|       indicator_selected = { |  | ||||||
|          guifg = colors.black, |  | ||||||
|          guibg = colors.black, |  | ||||||
|       }, |  | ||||||
|       -- separators |  | ||||||
|       separator = { |  | ||||||
|          guifg = colors.black2, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       separator_visible = { |  | ||||||
|          guifg = colors.black2, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       separator_selected = { |  | ||||||
|          guifg = colors.black2, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       -- modified |  | ||||||
|       modified = { |  | ||||||
|          guifg = colors.red, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       modified_visible = { |  | ||||||
|          guifg = colors.red, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       modified_selected = { |  | ||||||
|          guifg = colors.green, |  | ||||||
|          guibg = colors.black, |  | ||||||
|       }, |  | ||||||
|       -- close buttons |  | ||||||
| 
 |  | ||||||
|       close_button = { |  | ||||||
|          guifg = colors.light_grey, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       close_button_visible = { |  | ||||||
|          guifg = colors.light_grey, |  | ||||||
|          guibg = colors.black2, |  | ||||||
|       }, |  | ||||||
|       close_button_selected = { |  | ||||||
|          guifg = colors.red, |  | ||||||
|          guibg = colors.black, |  | ||||||
|       }, |  | ||||||
|    }, |    }, | ||||||
| } | } | ||||||
							
								
								
									
										44
									
								
								lua/plugins/configs/chadsheet.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								lua/plugins/configs/chadsheet.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,44 @@ | |||||||
|  | local present, chadsheet = pcall(require, "cheatsheet") | ||||||
|  | 
 | ||||||
|  | if not present then | ||||||
|  |    return | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | local mappings = require("core.utils").load_config().mappings | ||||||
|  | 
 | ||||||
|  | -- add user mappings to the cheetsheet | ||||||
|  | -- improve this function to not hardcode plugin | ||||||
|  | local function add_to_chadsheet(section, keymap, desc) | ||||||
|  |    if section == "plugin" then | ||||||
|  |       for sec, key in pairs(mappings.plugin) do | ||||||
|  |          add_to_chadsheet(sec, key, sec) | ||||||
|  |       end | ||||||
|  |    else | ||||||
|  |       if type(keymap) == "table" then | ||||||
|  |          for sec, key in pairs(keymap) do | ||||||
|  |             if type(sec) == "number" then | ||||||
|  |                add_to_chadsheet(section, key, desc or section) | ||||||
|  |             else | ||||||
|  |                add_to_chadsheet(sec, key, desc or section) | ||||||
|  |             end | ||||||
|  |          end | ||||||
|  |       else | ||||||
|  |          chadsheet.add_cheat(section, keymap, desc or "Misc") | ||||||
|  |       end | ||||||
|  |    end | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | for section, keymap in pairs(mappings) do | ||||||
|  |    add_to_chadsheet(section, keymap) | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | require("cheatsheet").setup { | ||||||
|  | 
 | ||||||
|  |    bundled_cheatsheets = { | ||||||
|  |       enabled = { "default" }, | ||||||
|  |       disabled = { "unicode", "nerd-fonts" }, | ||||||
|  |    }, | ||||||
|  | 
 | ||||||
|  |    bundled_plugin_cheatsheets = false, | ||||||
|  |    include_only_installed_plugins = true, | ||||||
|  | } | ||||||
| @ -5,21 +5,22 @@ end | |||||||
| 
 | 
 | ||||||
| compe.setup { | compe.setup { | ||||||
|    enabled = true, |    enabled = true, | ||||||
|  | 
 | ||||||
|    autocomplete = true, |    autocomplete = true, | ||||||
|    debug = false, |    debug = false, | ||||||
|    min_length = 1, |    documentation = true, | ||||||
|    preselect = "enable", |  | ||||||
|    throttle_time = 80, |  | ||||||
|    source_timeout = 200, |  | ||||||
|    incomplete_delay = 400, |    incomplete_delay = 400, | ||||||
|    max_abbr_width = 100, |    max_abbr_width = 100, | ||||||
|    max_kind_width = 100, |    max_kind_width = 100, | ||||||
|    max_menu_width = 100, |    max_menu_width = 100, | ||||||
|    documentation = true, |    min_length = 1, | ||||||
|  |    preselect = "enable", | ||||||
|  |    source_timeout = 200, | ||||||
|    source = { |    source = { | ||||||
|       buffer = { kind = "", true }, |       buffer = { kind = "", true }, | ||||||
|       luasnip = { kind = "", true }, |       luasnip = { kind = "", true }, | ||||||
|       nvim_lsp = true, |       nvim_lsp = true, | ||||||
|       nvim_lua = true, |       nvim_lua = true, | ||||||
|    }, |    }, | ||||||
|  |    throttle_time = 80, | ||||||
| } | } | ||||||
| @ -1,7 +1,7 @@ | |||||||
| local g = vim.g | local g = vim.g | ||||||
| local fn = vim.fn | local fn = vim.fn | ||||||
| 
 | 
 | ||||||
| local plugins_count = fn.len(fn.globpath("~/.local/share/nvim/site/pack/packer/start", "*", 0, 1)) | -- local plugins_count = fn.len(fn.globpath("~/.local/share/nvim/site/pack/packer/start", "*", 0, 1)) | ||||||
| 
 | 
 | ||||||
| g.dashboard_disable_at_vimenter = 1 -- dashboard is disabled by default | g.dashboard_disable_at_vimenter = 1 -- dashboard is disabled by default | ||||||
| g.dashboard_disable_statusline = 1 | g.dashboard_disable_statusline = 1 | ||||||
| @ -4,18 +4,10 @@ if not present then | |||||||
| end | end | ||||||
| 
 | 
 | ||||||
| gitsigns.setup { | gitsigns.setup { | ||||||
|    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 = "DiffChange", text = "~", numhl = "GitSignsChangeNr" }, |  | ||||||
|    }, |  | ||||||
|    numhl = false, |  | ||||||
|    keymaps = { |    keymaps = { | ||||||
|       -- Default keymap options |       -- Default keymap options | ||||||
|       noremap = true, |  | ||||||
|       buffer = true, |       buffer = true, | ||||||
|  |       noremap = true, | ||||||
|       ["n ]c"] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns\".next_hunk()<CR>'" }, |       ["n ]c"] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns\".next_hunk()<CR>'" }, | ||||||
|       ["n [c"] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns\".prev_hunk()<CR>'" }, |       ["n [c"] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns\".prev_hunk()<CR>'" }, | ||||||
|       ["n <leader>hs"] = '<cmd>lua require"gitsigns".stage_hunk()<CR>', |       ["n <leader>hs"] = '<cmd>lua require"gitsigns".stage_hunk()<CR>', | ||||||
| @ -24,9 +16,19 @@ gitsigns.setup { | |||||||
|       ["n <leader>hp"] = '<cmd>lua require"gitsigns".preview_hunk()<CR>', |       ["n <leader>hp"] = '<cmd>lua require"gitsigns".preview_hunk()<CR>', | ||||||
|       ["n <leader>hb"] = '<cmd>lua require"gitsigns".blame_line()<CR>', |       ["n <leader>hb"] = '<cmd>lua require"gitsigns".blame_line()<CR>', | ||||||
|    }, |    }, | ||||||
|  |    numhl = false, | ||||||
|  | 
 | ||||||
|  |    sign_priority = 5, | ||||||
|  |    signs = { | ||||||
|  |       add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" }, | ||||||
|  |       change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" }, | ||||||
|  |       changedelete = { hl = "DiffChange", text = "~", numhl = "GitSignsChangeNr" }, | ||||||
|  |       delete = { hl = "DiffDelete", text = "_", numhl = "GitSignsDeleteNr" }, | ||||||
|  |       topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, | ||||||
|  |    }, | ||||||
|  | 
 | ||||||
|  |    status_formatter = nil, -- Use default | ||||||
|    watch_index = { |    watch_index = { | ||||||
|       interval = 100, |       interval = 100, | ||||||
|    }, |    }, | ||||||
|    sign_priority = 5, |  | ||||||
|    status_formatter = nil, -- Use default |  | ||||||
| } | } | ||||||
| @ -3,16 +3,10 @@ if not present then | |||||||
|    return |    return | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| local global_theme = "themes/" .. vim.g.nvchad_theme | local colors = require("colors").get() | ||||||
| local colors = require(global_theme) |  | ||||||
| 
 | 
 | ||||||
| icons.setup { | icons.setup { | ||||||
|    override = { |    override = { | ||||||
|       html = { |  | ||||||
|          icon = "", |  | ||||||
|          color = colors.baby_pink, |  | ||||||
|          name = "html", |  | ||||||
|       }, |  | ||||||
|       c = { |       c = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.blue, |          color = colors.blue, | ||||||
| @ -23,35 +17,50 @@ icons.setup { | |||||||
|          color = colors.blue, |          color = colors.blue, | ||||||
|          name = "css", |          name = "css", | ||||||
|       }, |       }, | ||||||
|       js = { |       deb = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.sun, |          color = colors.cyan, | ||||||
|          name = "js", |          name = "deb", | ||||||
|       }, |       }, | ||||||
|       ts = { |       Dockerfile = { | ||||||
|          icon = "ﯤ", |          icon = "", | ||||||
|          color = colors.teal, |          color = colors.cyan, | ||||||
|          name = "ts", |          name = "Dockerfile", | ||||||
|       }, |       }, | ||||||
|       kt = { |       html = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.orange, |          color = colors.baby_pink, | ||||||
|          name = "kt", |          name = "html", | ||||||
|       }, |       }, | ||||||
|       png = { |       jpeg = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.dark_purple, |          color = colors.dark_purple, | ||||||
|          name = "png", |          name = "jpeg", | ||||||
|       }, |       }, | ||||||
|       jpg = { |       jpg = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.dark_purple, |          color = colors.dark_purple, | ||||||
|          name = "jpg", |          name = "jpg", | ||||||
|       }, |       }, | ||||||
|       jpeg = { |       js = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.dark_purple, |          color = colors.sun, | ||||||
|          name = "jpeg", |          name = "js", | ||||||
|  |       }, | ||||||
|  |       kt = { | ||||||
|  |          icon = "", | ||||||
|  |          color = colors.orange, | ||||||
|  |          name = "kt", | ||||||
|  |       }, | ||||||
|  |       lock = { | ||||||
|  |          icon = "", | ||||||
|  |          color = colors.red, | ||||||
|  |          name = "lock", | ||||||
|  |       }, | ||||||
|  |       lua = { | ||||||
|  |          icon = "", | ||||||
|  |          color = colors.blue, | ||||||
|  |          name = "lua", | ||||||
|       }, |       }, | ||||||
|       mp3 = { |       mp3 = { | ||||||
|          icon = "", |          icon = "", | ||||||
| @ -68,20 +77,10 @@ icons.setup { | |||||||
|          color = colors.white, |          color = colors.white, | ||||||
|          name = "out", |          name = "out", | ||||||
|       }, |       }, | ||||||
|       Dockerfile = { |       png = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.cyan, |          color = colors.dark_purple, | ||||||
|          name = "Dockerfile", |          name = "png", | ||||||
|       }, |  | ||||||
|       rb = { |  | ||||||
|          icon = "", |  | ||||||
|          color = colors.pink, |  | ||||||
|          name = "rb", |  | ||||||
|       }, |  | ||||||
|       vue = { |  | ||||||
|          icon = "﵂", |  | ||||||
|          color = colors.vibrant_green, |  | ||||||
|          name = "vue", |  | ||||||
|       }, |       }, | ||||||
|       py = { |       py = { | ||||||
|          icon = "", |          icon = "", | ||||||
| @ -93,35 +92,35 @@ icons.setup { | |||||||
|          color = colors.blue, |          color = colors.blue, | ||||||
|          name = "toml", |          name = "toml", | ||||||
|       }, |       }, | ||||||
|       lock = { |       ts = { | ||||||
|          icon = "", |          icon = "ﯤ", | ||||||
|          color = colors.red, |          color = colors.teal, | ||||||
|          name = "lock", |          name = "ts", | ||||||
|       }, |       }, | ||||||
|       zip = { |       rb = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.sun, |          color = colors.pink, | ||||||
|          name = "zip", |          name = "rb", | ||||||
|       }, |  | ||||||
|       xz = { |  | ||||||
|          icon = "", |  | ||||||
|          color = colors.sun, |  | ||||||
|          name = "xz", |  | ||||||
|       }, |  | ||||||
|       deb = { |  | ||||||
|          icon = "", |  | ||||||
|          color = colors.cyan, |  | ||||||
|          name = "deb", |  | ||||||
|       }, |       }, | ||||||
|       rpm = { |       rpm = { | ||||||
|          icon = "", |          icon = "", | ||||||
|          color = colors.orange, |          color = colors.orange, | ||||||
|          name = "rpm", |          name = "rpm", | ||||||
|       }, |       }, | ||||||
|       lua = { |       vue = { | ||||||
|          icon = "", |          icon = "﵂", | ||||||
|          color = colors.blue, |          color = colors.vibrant_green, | ||||||
|          name = "lua", |          name = "vue", | ||||||
|  |       }, | ||||||
|  |       xz = { | ||||||
|  |          icon = "", | ||||||
|  |          color = colors.sun, | ||||||
|  |          name = "xz", | ||||||
|  |       }, | ||||||
|  |       zip = { | ||||||
|  |          icon = "", | ||||||
|  |          color = colors.sun, | ||||||
|  |          name = "zip", | ||||||
|       }, |       }, | ||||||
|    }, |    }, | ||||||
| } | } | ||||||
| @ -10,13 +10,13 @@ local function on_attach(client, bufnr) | |||||||
|    local opts = { noremap = true, silent = true } |    local opts = { noremap = true, silent = true } | ||||||
| 
 | 
 | ||||||
|    -- lsp Mappings. |    -- lsp Mappings. | ||||||
|  |    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) |  | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts) |  | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts) | ||||||
|  |    vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap( |    vim.api.nvim_buf_set_keymap( | ||||||
|       bufnr, |       bufnr, | ||||||
|       "n", |       "n", | ||||||
| @ -24,13 +24,13 @@ local function on_attach(client, bufnr) | |||||||
|       "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", |       "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", | ||||||
|       opts |       opts | ||||||
|    ) |    ) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts) |  | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) |  | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) | ||||||
|  |    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts) | ||||||
|    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts) |    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts) | ||||||
|  |    vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts) | ||||||
| 
 | 
 | ||||||
|    -- Set some keybinds conditional on server capabilities |    -- Set some keybinds conditional on server capabilities | ||||||
|    if client.resolved_capabilities.document_formatting then |    if client.resolved_capabilities.document_formatting then | ||||||
| @ -95,9 +95,9 @@ function lspSymbol(name, icon) | |||||||
| end | end | ||||||
| 
 | 
 | ||||||
| lspSymbol("Error", "") | lspSymbol("Error", "") | ||||||
| lspSymbol("Warning", "") |  | ||||||
| lspSymbol("Information", "") | lspSymbol("Information", "") | ||||||
| lspSymbol("Hint", "") | lspSymbol("Hint", "") | ||||||
|  | lspSymbol("Warning", "") | ||||||
| 
 | 
 | ||||||
| vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { | vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { | ||||||
|    virtual_text = { |    virtual_text = { | ||||||
| @ -53,11 +53,11 @@ _G.completions = function() | |||||||
|    return npairs.check_break_line_char() |    return npairs.check_break_line_char() | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", { expr = true }) | vim.api.nvim_set_keymap("i", "<CR>", "v:lua.completions()", { expr = true }) | ||||||
| vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", { expr = true }) |  | ||||||
| vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) | vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) | ||||||
| vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) | vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", { expr = true }) | ||||||
| vim.api.nvim_set_keymap("i", "<CR>", "v:lua.completions()", { expr = true }) | vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", { expr = true }) | ||||||
|  | vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", { expr = true }) | ||||||
| 
 | 
 | ||||||
| luasnip.config.set_config { | luasnip.config.set_config { | ||||||
|    history = true, |    history = true, | ||||||
| @ -8,53 +8,54 @@ local g = vim.g | |||||||
| 
 | 
 | ||||||
| vim.o.termguicolors = true | vim.o.termguicolors = true | ||||||
| 
 | 
 | ||||||
| g.nvim_tree_side = "left" | g.nvim_tree_add_trailing = 0 -- append a trailing slash to folder names | ||||||
| g.nvim_tree_width = 25 | g.nvim_tree_allow_resize = 1 | ||||||
| g.nvim_tree_ignore = { ".git", "node_modules", ".cache" } | g.nvim_tree_auto_close = 0 -- closes tree when it's the last window | ||||||
| g.nvim_tree_gitignore = 1 |  | ||||||
| g.nvim_tree_auto_ignore_ft = { "dashboard" } -- don't open tree on specific fiypes. | g.nvim_tree_auto_ignore_ft = { "dashboard" } -- don't open tree on specific fiypes. | ||||||
| g.nvim_tree_auto_open = 0 | g.nvim_tree_auto_open = 0 | ||||||
| g.nvim_tree_auto_close = 0 -- closes tree when it's the last window |  | ||||||
| g.nvim_tree_quit_on_open = 0 -- closes tree when file's opened |  | ||||||
| g.nvim_tree_follow = 1 |  | ||||||
| g.nvim_tree_indent_markers = 1 |  | ||||||
| g.nvim_tree_hide_dotfiles = 1 |  | ||||||
| g.nvim_tree_git_hl = 1 |  | ||||||
| g.nvim_tree_highlight_opened_files = 0 |  | ||||||
| g.nvim_tree_root_folder_modifier = table.concat { ":t:gs?$?/..", string.rep(" ", 1000), "?:gs?^??" } |  | ||||||
| g.nvim_tree_tab_open = 0 |  | ||||||
| g.nvim_tree_allow_resize = 1 |  | ||||||
| g.nvim_tree_add_trailing = 0 -- append a trailing slash to folder names |  | ||||||
| g.nvim_tree_disable_netrw = 1 | g.nvim_tree_disable_netrw = 1 | ||||||
|  | g.nvim_tree_follow = 1 | ||||||
|  | g.nvim_tree_git_hl = 1 | ||||||
|  | g.nvim_tree_gitignore = 1 | ||||||
|  | g.nvim_tree_hide_dotfiles = 1 | ||||||
|  | g.nvim_tree_highlight_opened_files = 0 | ||||||
| g.nvim_tree_hijack_netrw = 0 | g.nvim_tree_hijack_netrw = 0 | ||||||
|  | g.nvim_tree_indent_markers = 1 | ||||||
|  | g.nvim_tree_ignore = { ".git", "node_modules", ".cache" } | ||||||
|  | g.nvim_tree_quit_on_open = 0 -- closes tree when file's opened | ||||||
|  | g.nvim_tree_root_folder_modifier = table.concat { ":t:gs?$?/..", string.rep(" ", 1000), "?:gs?^??" } | ||||||
|  | g.nvim_tree_side = "left" | ||||||
|  | g.nvim_tree_tab_open = 0 | ||||||
| g.nvim_tree_update_cwd = 1 | g.nvim_tree_update_cwd = 1 | ||||||
|  | g.nvim_tree_width = 25 | ||||||
| 
 | 
 | ||||||
| g.nvim_tree_show_icons = { | g.nvim_tree_show_icons = { | ||||||
|    git = 1, |  | ||||||
|    folders = 1, |    folders = 1, | ||||||
|    files = 1, |  | ||||||
|    -- folder_arrows= 1 |    -- folder_arrows= 1 | ||||||
|  |    files = 1, | ||||||
|  |    git = 1, | ||||||
| } | } | ||||||
|  | 
 | ||||||
| g.nvim_tree_icons = { | g.nvim_tree_icons = { | ||||||
|    default = "", |    default = "", | ||||||
|    symlink = "", |    symlink = "", | ||||||
|    git = { |    git = { | ||||||
|       unstaged = "✗", |  | ||||||
|       staged = "✓", |  | ||||||
|       unmerged = "", |  | ||||||
|       renamed = "➜", |  | ||||||
|       untracked = "★", |  | ||||||
|       deleted = "", |       deleted = "", | ||||||
|       ignored = "◌", |       ignored = "◌", | ||||||
|  |       renamed = "➜", | ||||||
|  |       staged = "✓", | ||||||
|  |       unmerged = "", | ||||||
|  |       unstaged = "✗", | ||||||
|  |       untracked = "★", | ||||||
|    }, |    }, | ||||||
|    folder = { |    folder = { | ||||||
|       -- disable indent_markers option to get arrows working or if you want both arrows and indent then just add the arrow icons in front            ofthe default and opened folders below! |       -- disable indent_markers option to get arrows working or if you want both arrows and indent then just add the arrow icons in front            ofthe default and opened folders below! | ||||||
|       -- arrow_open = "", |       -- arrow_open = "", | ||||||
|       -- arrow_closed = "", |       -- arrow_closed = "", | ||||||
|       default = "", |       default = "", | ||||||
|       open = "", |  | ||||||
|       empty = "", --  |       empty = "", --  | ||||||
|       empty_open = "", |       empty_open = "", | ||||||
|  |       open = "", | ||||||
|       symlink = "", |       symlink = "", | ||||||
|       symlink_open = "", |       symlink_open = "", | ||||||
|    }, |    }, | ||||||
| @ -1,5 +1,21 @@ | |||||||
| local M = {} | local M = {} | ||||||
| 
 | 
 | ||||||
|  | M.better_escape = function() | ||||||
|  |    local config = require("core.utils").load_config() | ||||||
|  |    vim.g.better_escape_interval = config.options.plugin.esc_insertmode_timeout or 300 | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | M.blankline = function() | ||||||
|  |    vim.g.indentLine_enabled = 1 | ||||||
|  |    vim.g.indent_blankline_char = "▏" | ||||||
|  | 
 | ||||||
|  |    vim.g.indent_blankline_filetype_exclude = { "help", "terminal", "dashboard", "packer" } | ||||||
|  |    vim.g.indent_blankline_buftype_exclude = { "terminal" } | ||||||
|  | 
 | ||||||
|  |    vim.g.indent_blankline_show_trailing_blankline_indent = false | ||||||
|  |    vim.g.indent_blankline_show_first_indent_level = false | ||||||
|  | end | ||||||
|  | 
 | ||||||
| M.colorizer = function() | M.colorizer = function() | ||||||
|    local present, colorizer = pcall(require, "colorizer") |    local present, colorizer = pcall(require, "colorizer") | ||||||
|    if present then |    if present then | ||||||
| @ -15,11 +31,6 @@ M.comment = function() | |||||||
|    end |    end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| M.escape = function() |  | ||||||
|    vim.g.better_escape_interval = 300 |  | ||||||
|    vim.g.better_escape_shortcut = { "jk" } |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.lspkind = function() | M.lspkind = function() | ||||||
|    local present, lspkind = pcall(require, "lspkind") |    local present, lspkind = pcall(require, "lspkind") | ||||||
|    if present then |    if present then | ||||||
| @ -33,17 +44,6 @@ M.neoscroll = function() | |||||||
|    end) |    end) | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| M.blankline = function() |  | ||||||
|    vim.g.indentLine_enabled = 1 |  | ||||||
|    vim.g.indent_blankline_char = "▏" |  | ||||||
| 
 |  | ||||||
|    vim.g.indent_blankline_filetype_exclude = { "help", "terminal", "dashboard", "packer" } |  | ||||||
|    vim.g.indent_blankline_buftype_exclude = { "terminal" } |  | ||||||
| 
 |  | ||||||
|    vim.g.indent_blankline_show_trailing_blankline_indent = false |  | ||||||
|    vim.g.indent_blankline_show_first_indent_level = false |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.signature = function() | M.signature = function() | ||||||
|    local present, lspsignature = pcall(require, "lsp_signature") |    local present, lspsignature = pcall(require, "lsp_signature") | ||||||
|    if present then |    if present then | ||||||
| @ -1,5 +1,4 @@ | |||||||
| local global_theme = "themes/" .. vim.g.nvchad_theme | local colors = require("colors").get() | ||||||
| local colors = require(global_theme) |  | ||||||
| 
 | 
 | ||||||
| local present1, gl = pcall(require, "galaxyline") | local present1, gl = pcall(require, "galaxyline") | ||||||
| local present2, condition = pcall(require, "galaxyline.condition") | local present2, condition = pcall(require, "galaxyline.condition") | ||||||
| @ -20,6 +19,22 @@ local icon_styles = { | |||||||
|       position_icon = " ", |       position_icon = " ", | ||||||
|    }, |    }, | ||||||
| 
 | 
 | ||||||
|  |    arrow = { | ||||||
|  |       left = "", | ||||||
|  |       right = "", | ||||||
|  |       main_icon = "  ", | ||||||
|  |       vi_mode_icon = " ", | ||||||
|  |       position_icon = " ", | ||||||
|  |    }, | ||||||
|  | 
 | ||||||
|  |    block = { | ||||||
|  |       left = " ", | ||||||
|  |       right = " ", | ||||||
|  |       main_icon = "   ", | ||||||
|  |       vi_mode_icon = "   ", | ||||||
|  |       position_icon = "  ", | ||||||
|  |    }, | ||||||
|  | 
 | ||||||
|    round = { |    round = { | ||||||
|       left = "", |       left = "", | ||||||
|       right = "", |       right = "", | ||||||
| @ -35,25 +50,9 @@ local icon_styles = { | |||||||
|       vi_mode_icon = " ", |       vi_mode_icon = " ", | ||||||
|       position_icon = " ", |       position_icon = " ", | ||||||
|    }, |    }, | ||||||
| 
 |  | ||||||
|    block = { |  | ||||||
|       left = " ", |  | ||||||
|       right = " ", |  | ||||||
|       main_icon = "   ", |  | ||||||
|       vi_mode_icon = "   ", |  | ||||||
|       position_icon = "  ", |  | ||||||
|    }, |  | ||||||
| 
 |  | ||||||
|    arrow = { |  | ||||||
|       left = "", |  | ||||||
|       right = "", |  | ||||||
|       main_icon = "  ", |  | ||||||
|       vi_mode_icon = " ", |  | ||||||
|       position_icon = " ", |  | ||||||
|    }, |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| local user_statusline_style = require("utils").load_config().ui.statusline.style | local user_statusline_style = require("core.utils").load_config().ui.plugin.statusline.style | ||||||
| local statusline_style = icon_styles[user_statusline_style] | local statusline_style = icon_styles[user_statusline_style] | ||||||
| 
 | 
 | ||||||
| local left_separator = statusline_style.left | local left_separator = statusline_style.left | ||||||
| @ -65,21 +65,23 @@ telescope.setup { | |||||||
|    }, |    }, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| -- NvChad pickers | if | ||||||
| -- load the theme_switcher extension |    not pcall(function() | ||||||
| require("telescope").load_extension "themes" |       -- NvChad pickers | ||||||
| -- load the term_picker extension |       -- load the theme_switcher extension | ||||||
| require("telescope").load_extension "terms" |       telescope.load_extension "themes" | ||||||
|  |       -- load the term_picker extension | ||||||
|  |       telescope.load_extension "terms" | ||||||
| 
 | 
 | ||||||
| if not pcall(function() |       telescope.load_extension "fzf" | ||||||
|    telescope.load_extension "fzf" |       telescope.load_extension "media_files" | ||||||
|    telescope.load_extension "media_files" |    end) | ||||||
| end) then | then | ||||||
|    -- This should only trigger when in need of PackerSync, so better do it |    -- This should only trigger when in need of PackerSync, so better do it | ||||||
|    print "After completion of PackerCompile, restart neovim." |    print "After completion of PackerCompile, restart neovim." | ||||||
|    -- Trigger packer compile on PackerComplete, so it properly waits for PackerSync |    -- Trigger packer compile on PackerComplete, so it properly waits for PackerSync | ||||||
|    vim.cmd 'autocmd User PackerComplete ++once lua print "Waiting for PackerCompile.." require("packer").compile()' |    vim.cmd 'autocmd User PackerComplete ++once lua print "Waiting for PackerCompile.." require("packer").compile()' | ||||||
|    vim.cmd 'autocmd User PackerCompileDone ++once echo "Packer Compile done, restart neovim."' |    vim.cmd 'autocmd User PackerCompileDone ++once echo "Packer Compile done, restart neovim."' | ||||||
|    require "pluginList" |    require "plugins" | ||||||
|    require("packer").update("telescope-fzf-native.nvim", "telescope-media-files.nvim") |    require("packer").update("core", "telescope-fzf-native.nvim", "telescope-media-files.nvim") | ||||||
| end | end | ||||||
| @ -6,11 +6,11 @@ end | |||||||
| true_zen.setup { | true_zen.setup { | ||||||
|    ui = { |    ui = { | ||||||
|       bottom = { |       bottom = { | ||||||
|  |          cmdheight = 1, | ||||||
|          laststatus = 0, |          laststatus = 0, | ||||||
|          ruler = false, |          ruler = false, | ||||||
|          showmode = false, |          showmode = false, | ||||||
|          showcmd = false, |          showcmd = false, | ||||||
|          cmdheight = 1, |  | ||||||
|       }, |       }, | ||||||
|       top = { |       top = { | ||||||
|          showtabline = 0, |          showtabline = 0, | ||||||
| @ -1,28 +1,39 @@ | |||||||
| local plugin_status = require("utils").load_config().plugin_status | local present, packer = pcall(require, "plugins.packerInit") | ||||||
| 
 | 
 | ||||||
| local present, _ = pcall(require, "packerInit") | if not present then | ||||||
| local packer |  | ||||||
| 
 |  | ||||||
| if present then |  | ||||||
|    packer = require "packer" |  | ||||||
| else |  | ||||||
|    return false |    return false | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| local use = packer.use | local use = packer.use | ||||||
| 
 | 
 | ||||||
| return packer.startup(function() | return packer.startup(function() | ||||||
|  |    local plugin_status = require("core.utils").load_config().plugin_status | ||||||
|  | 
 | ||||||
|  |    -- this is arranged on the basis of when a plugin starts | ||||||
|  | 
 | ||||||
|  |    -- this is the nvchad core repo containing utilities for some features like theme swticher, no need to lazy load | ||||||
|  |    use { | ||||||
|  |       "Nvchad/core", | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|    use { |    use { | ||||||
|       "wbthomason/packer.nvim", |       "wbthomason/packer.nvim", | ||||||
|       event = "VimEnter", |       event = "VimEnter", | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    use { |    use { | ||||||
|       "jdhao/better-escape.vim", |       "NvChad/nvim-base16.lua", | ||||||
|       disable = not plugin_status.better_esc, |       after = "packer.nvim", | ||||||
|       event = "InsertEnter", |  | ||||||
|       config = function() |       config = function() | ||||||
|          require("plugins.others").escape() |          require("colors").init() | ||||||
|  |       end, | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    use { | ||||||
|  |       "kyazdani42/nvim-web-devicons", | ||||||
|  |       after = "nvim-base16.lua", | ||||||
|  |       config = function() | ||||||
|  |          require "plugins.configs.icons" | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
| @ -31,36 +42,99 @@ return packer.startup(function() | |||||||
|       disable = not plugin_status.galaxyline, |       disable = not plugin_status.galaxyline, | ||||||
|       after = "nvim-web-devicons", |       after = "nvim-web-devicons", | ||||||
|       config = function() |       config = function() | ||||||
|          require "plugins.statusline" |          require "plugins.configs.statusline" | ||||||
|       end, |  | ||||||
|    } |  | ||||||
|    use { |  | ||||||
|       "akinsho/bufferline.nvim", |  | ||||||
|       disable = not plugin_status.nvim_bufferline, |  | ||||||
|       after = "galaxyline.nvim", |  | ||||||
|       config = function() |  | ||||||
|          require "plugins.bufferline" |  | ||||||
|       end, |  | ||||||
|       setup = function() |  | ||||||
|          require("mappings").bufferline() |  | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    -- color related stuff |  | ||||||
|    use { |    use { | ||||||
|       "NvChad/nvim-base16.lua", |       "akinsho/bufferline.nvim", | ||||||
|       after = "packer.nvim", |       disable = not plugin_status.bufferline, | ||||||
|  |       after = "galaxyline.nvim", | ||||||
|       config = function() |       config = function() | ||||||
|          require "theme" |          require "plugins.configs.bufferline" | ||||||
|  |       end, | ||||||
|  |       setup = function() | ||||||
|  |          require("core.mappings").bufferline() | ||||||
|  |       end, | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    use { | ||||||
|  |       "nvim-lua/plenary.nvim", | ||||||
|  |       after = "bufferline.nvim", | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    -- git stuff | ||||||
|  |    use { | ||||||
|  |       "lewis6991/gitsigns.nvim", | ||||||
|  |       disable = not plugin_status.gitsigns, | ||||||
|  |       after = "plenary.nvim", | ||||||
|  |       config = function() | ||||||
|  |          require "plugins.configs.gitsigns" | ||||||
|  |       end, | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    use { | ||||||
|  |       "nvim-telescope/telescope.nvim", | ||||||
|  |       after = "plenary.nvim", | ||||||
|  |       requires = { | ||||||
|  |          { | ||||||
|  |             "sudormrfbin/cheatsheet.nvim", | ||||||
|  |             disable = not plugin_status.cheatsheet, | ||||||
|  |             after = "telescope.nvim", | ||||||
|  |             config = function() | ||||||
|  |                require "plugins.configs.chadsheet" | ||||||
|  |             end, | ||||||
|  |             setup = function() | ||||||
|  |                require("core.mappings").chadsheet() | ||||||
|  |             end, | ||||||
|  |          }, | ||||||
|  |          { | ||||||
|  |             "nvim-telescope/telescope-fzf-native.nvim", | ||||||
|  |             run = "make", | ||||||
|  |          }, | ||||||
|  |          { | ||||||
|  |             "nvim-telescope/telescope-media-files.nvim", | ||||||
|  |             disable = not plugin_status.telescope_media, | ||||||
|  |             setup = function() | ||||||
|  |                require("core.mappings").telescope_media() | ||||||
|  |             end, | ||||||
|  |          }, | ||||||
|  |       }, | ||||||
|  |       config = function() | ||||||
|  |          require "plugins.configs.telescope" | ||||||
|  |       end, | ||||||
|  |       setup = function() | ||||||
|  |          require("core.mappings").telescope() | ||||||
|  |       end, | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    -- load autosave only if its globally enabled | ||||||
|  |    use { | ||||||
|  |       disable = not plugin_status.autosave, | ||||||
|  |       "Pocco81/AutoSave.nvim", | ||||||
|  |       config = function() | ||||||
|  |          require "plugins.configs.autosave" | ||||||
|  |       end, | ||||||
|  |       cond = function() | ||||||
|  |          return require("core.utils").load_config().options.plugin.autosave == true | ||||||
|  |       end, | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    use { | ||||||
|  |       "lukas-reineke/indent-blankline.nvim", | ||||||
|  |       disable = not plugin_status.blankline, | ||||||
|  |       event = "BufRead", | ||||||
|  |       config = function() | ||||||
|  |          require("plugins.configs.others").blankline() | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    use { |    use { | ||||||
|       "norcalli/nvim-colorizer.lua", |       "norcalli/nvim-colorizer.lua", | ||||||
|       disable = not plugin_status.nvim_colorizer, |       disable = not plugin_status.colorizer, | ||||||
|       event = "BufRead", |       event = "BufRead", | ||||||
|       config = function() |       config = function() | ||||||
|          require("plugins.others").colorizer() |          require("plugins.configs.others").colorizer() | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
| @ -69,7 +143,7 @@ return packer.startup(function() | |||||||
|       "nvim-treesitter/nvim-treesitter", |       "nvim-treesitter/nvim-treesitter", | ||||||
|       event = "BufRead", |       event = "BufRead", | ||||||
|       config = function() |       config = function() | ||||||
|          require "plugins.treesitter" |          require "plugins.configs.treesitter" | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
| @ -82,16 +156,7 @@ return packer.startup(function() | |||||||
|       "neovim/nvim-lspconfig", |       "neovim/nvim-lspconfig", | ||||||
|       after = "nvim-lspinstall", |       after = "nvim-lspinstall", | ||||||
|       config = function() |       config = function() | ||||||
|          require "plugins.lspconfig" |          require "plugins.configs.lspconfig" | ||||||
|       end, |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    use { |  | ||||||
|       "onsails/lspkind-nvim", |  | ||||||
|       disable = not plugin_status.lspkind, |  | ||||||
|       event = "BufEnter", |  | ||||||
|       config = function() |  | ||||||
|          require("plugins.others").lspkind() |  | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
| @ -100,7 +165,28 @@ return packer.startup(function() | |||||||
|       disable = not plugin_status.lspsignature, |       disable = not plugin_status.lspsignature, | ||||||
|       after = "nvim-lspconfig", |       after = "nvim-lspconfig", | ||||||
|       config = function() |       config = function() | ||||||
|          require("plugins.others").signature() |          require("plugins.configs.others").signature() | ||||||
|  |       end, | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    use { | ||||||
|  |       "onsails/lspkind-nvim", | ||||||
|  |       disable = not plugin_status.lspkind, | ||||||
|  |       event = "BufEnter", | ||||||
|  |       config = function() | ||||||
|  |          require("plugins.configs.others").lspkind() | ||||||
|  |       end, | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    use { | ||||||
|  |       "jdhao/better-escape.vim", | ||||||
|  |       disable = not plugin_status.esc_insertmode, | ||||||
|  |       event = "InsertEnter", | ||||||
|  |       config = function() | ||||||
|  |          require("plugins.configs.others").better_escape() | ||||||
|  |       end, | ||||||
|  |       setup = function() | ||||||
|  |          require("core.mappings").better_escape() | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
| @ -109,7 +195,7 @@ return packer.startup(function() | |||||||
|       "hrsh7th/nvim-compe", |       "hrsh7th/nvim-compe", | ||||||
|       event = "InsertEnter", |       event = "InsertEnter", | ||||||
|       config = function() |       config = function() | ||||||
|          require "plugins.compe" |          require "plugins.configs.compe" | ||||||
|       end, |       end, | ||||||
|       wants = "LuaSnip", |       wants = "LuaSnip", | ||||||
|       requires = { |       requires = { | ||||||
| @ -118,7 +204,7 @@ return packer.startup(function() | |||||||
|             wants = "friendly-snippets", |             wants = "friendly-snippets", | ||||||
|             event = "InsertCharPre", |             event = "InsertCharPre", | ||||||
|             config = function() |             config = function() | ||||||
|                require "plugins.luasnip" |                require "plugins.configs.luasnip" | ||||||
|             end, |             end, | ||||||
|          }, |          }, | ||||||
|          { |          { | ||||||
| @ -128,91 +214,12 @@ return packer.startup(function() | |||||||
|       }, |       }, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    use { |  | ||||||
|       "sbdchd/neoformat", |  | ||||||
|       disable = not plugin_status.neoformat, |  | ||||||
|       cmd = "Neoformat", |  | ||||||
|       setup = function() |  | ||||||
|          require("mappings").neoformat() |  | ||||||
|       end, |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    -- file managing , picker etc |  | ||||||
|    use { |  | ||||||
|       "kyazdani42/nvim-tree.lua", |  | ||||||
|       cmd = "NvimTreeToggle", |  | ||||||
|       config = function() |  | ||||||
|          require "plugins.nvimtree" |  | ||||||
|       end, |  | ||||||
|       setup = function() |  | ||||||
|          require("mappings").nvimtree() |  | ||||||
|       end, |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    use { |  | ||||||
|       "kyazdani42/nvim-web-devicons", |  | ||||||
|       after = "nvim-base16.lua", |  | ||||||
|       config = function() |  | ||||||
|          require "plugins.icons" |  | ||||||
|       end, |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    use { |  | ||||||
|       "nvim-lua/plenary.nvim", |  | ||||||
|       after = "bufferline.nvim", |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    use { |  | ||||||
|       "nvim-telescope/telescope.nvim", |  | ||||||
|       after = "plenary.nvim", |  | ||||||
|       requires = { |  | ||||||
|          { |  | ||||||
|             "nvim-telescope/telescope-fzf-native.nvim", |  | ||||||
|             run = "make", |  | ||||||
|          }, |  | ||||||
|          { |  | ||||||
|             "nvim-telescope/telescope-media-files.nvim", |  | ||||||
|             disable = not plugin_status.telescope_media, |  | ||||||
|             setup = function() |  | ||||||
|                require("mappings").telescope_media() |  | ||||||
|             end, |  | ||||||
|          }, |  | ||||||
|          { |  | ||||||
|             "sudormrfbin/cheatsheet.nvim", |  | ||||||
|             disable = not plugin_status.cheatsheet, |  | ||||||
|             after = "telescope.nvim", |  | ||||||
|             config = function() |  | ||||||
|                require "plugins.chadsheet" |  | ||||||
|             end, |  | ||||||
|             setup = function() |  | ||||||
|                require("mappings").chadsheet() |  | ||||||
|             end, |  | ||||||
|          }, |  | ||||||
|       }, |  | ||||||
|       config = function() |  | ||||||
|          require "plugins.telescope" |  | ||||||
|       end, |  | ||||||
|       setup = function() |  | ||||||
|          require("mappings").telescope() |  | ||||||
|       end, |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    -- git stuff |  | ||||||
|    use { |  | ||||||
|       "lewis6991/gitsigns.nvim", |  | ||||||
|       disable = not plugin_status.gitsigns, |  | ||||||
|       after = "plenary.nvim", |  | ||||||
|       config = function() |  | ||||||
|          require "plugins.gitsigns" |  | ||||||
|       end, |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    -- misc plugins |    -- misc plugins | ||||||
|    use { |    use { | ||||||
|       "windwp/nvim-autopairs", |       "windwp/nvim-autopairs", | ||||||
|       after = "nvim-compe", |       after = "nvim-compe", | ||||||
|       config = function() |       config = function() | ||||||
|          require "plugins.autopairs" |          require "plugins.configs.autopairs" | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
| @ -222,21 +229,19 @@ return packer.startup(function() | |||||||
|       event = "CursorMoved", |       event = "CursorMoved", | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    -- smooth scroll | ||||||
|    use { |    use { | ||||||
|       "terrortylor/nvim-comment", |       "karb94/neoscroll.nvim", | ||||||
|       disable = not plugin_status.nvim_comment, |       disable = not plugin_status.neoscroll, | ||||||
|       cmd = "CommentToggle", |       event = "WinScrolled", | ||||||
|       config = function() |       config = function() | ||||||
|          require("plugins.others").comment() |          require("plugins.configs.others").neoscroll() | ||||||
|       end, |  | ||||||
|       setup = function() |  | ||||||
|          require("mappings").comment_nvim() |  | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    use { |    use { | ||||||
|       "glepnir/dashboard-nvim", |       "glepnir/dashboard-nvim", | ||||||
|       disable = not plugin_status.dashboard_nvim, |       disable = not plugin_status.dashboard, | ||||||
|       cmd = { |       cmd = { | ||||||
|          "Dashboard", |          "Dashboard", | ||||||
|          "DashboardNewFile", |          "DashboardNewFile", | ||||||
| @ -244,58 +249,61 @@ return packer.startup(function() | |||||||
|          "SessionLoad", |          "SessionLoad", | ||||||
|          "SessionSave", |          "SessionSave", | ||||||
|       }, |       }, | ||||||
|  |       config = function() | ||||||
|  |          require "plugins.configs.dashboard" | ||||||
|  |       end, | ||||||
|       setup = function() |       setup = function() | ||||||
|          require "plugins.dashboard" |          require("core.mappings").dashboard() | ||||||
|          require("mappings").dashboard() |  | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    -- load autosave only if its globally enabled |  | ||||||
|    use { |    use { | ||||||
|       disable = not plugin_status.autosave_nvim, |       "sbdchd/neoformat", | ||||||
|       "Pocco81/AutoSave.nvim", |       disable = not plugin_status.neoformat, | ||||||
|       config = function() |       cmd = "Neoformat", | ||||||
|          require "plugins.autosave" |       setup = function() | ||||||
|       end, |          require("core.mappings").neoformat() | ||||||
|       cond = function() |  | ||||||
|          return vim.g.auto_save == true |  | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    -- smooth scroll |    --   use "alvan/vim-closetag" -- for html autoclosing tag | ||||||
|    use { |    use { | ||||||
|       "karb94/neoscroll.nvim", |       "terrortylor/nvim-comment", | ||||||
|       disable = not plugin_status.neoscroll_nvim, |       disable = not plugin_status.comment, | ||||||
|       event = "WinScrolled", |       cmd = "CommentToggle", | ||||||
|       config = function() |       config = function() | ||||||
|          require("plugins.others").neoscroll() |          require("plugins.configs.others").comment() | ||||||
|  |       end, | ||||||
|  |       setup = function() | ||||||
|  |          require("core.mappings").comment() | ||||||
|  |       end, | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    -- file managing , picker etc | ||||||
|  |    use { | ||||||
|  |       "kyazdani42/nvim-tree.lua", | ||||||
|  |       cmd = "NvimTreeToggle", | ||||||
|  |       config = function() | ||||||
|  |          require "plugins.configs.nvimtree" | ||||||
|  |       end, | ||||||
|  |       setup = function() | ||||||
|  |          require("core.mappings").nvimtree() | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    use { |    use { | ||||||
|       "Pocco81/TrueZen.nvim", |       "Pocco81/TrueZen.nvim", | ||||||
|       disable = not plugin_status.truezen_nvim, |       disable = not plugin_status.truezen, | ||||||
|       cmd = { |       cmd = { | ||||||
|          "TZAtaraxis", |          "TZAtaraxis", | ||||||
|          "TZMinimalist", |          "TZMinimalist", | ||||||
|          "TZFocus", |          "TZFocus", | ||||||
|       }, |       }, | ||||||
|       config = function() |       config = function() | ||||||
|          require "plugins.zenmode" |          require "plugins.configs.zenmode" | ||||||
|       end, |       end, | ||||||
|       setup = function() |       setup = function() | ||||||
|          require("mappings").truezen() |          require("core.mappings").truezen() | ||||||
|       end, |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    --   use "alvan/vim-closetag" -- for html autoclosing tag |  | ||||||
| 
 |  | ||||||
|    use { |  | ||||||
|       "lukas-reineke/indent-blankline.nvim", |  | ||||||
|       disable = not plugin_status.blankline, |  | ||||||
|       event = "BufRead", |  | ||||||
|       setup = function() |  | ||||||
|          require("plugins.others").blankline() |  | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
| @ -306,7 +314,7 @@ return packer.startup(function() | |||||||
|          "Git", |          "Git", | ||||||
|       }, |       }, | ||||||
|       setup = function() |       setup = function() | ||||||
|          require("mappings").fugitive() |          require("core.mappings").vim_fugitive() | ||||||
|       end, |       end, | ||||||
|    } |    } | ||||||
| end) | end) | ||||||
| @ -29,7 +29,7 @@ if not present then | |||||||
|    end |    end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| return packer.init { | packer.init { | ||||||
|    display = { |    display = { | ||||||
|       open_fn = function() |       open_fn = function() | ||||||
|          return require("packer.util").float { border = "single" } |          return require("packer.util").float { border = "single" } | ||||||
| @ -43,3 +43,5 @@ return packer.init { | |||||||
|    compile_on_sync = true, |    compile_on_sync = true, | ||||||
|    --    auto_reload_compiled = true |    --    auto_reload_compiled = true | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | return packer | ||||||
| @ -1,143 +0,0 @@ | |||||||
| -- This file can be loaded as a telescope extension |  | ||||||
| local M = {} |  | ||||||
| 
 |  | ||||||
| -- Custom theme picker |  | ||||||
| -- Most of the code is copied from telescope buffer builtin |  | ||||||
| -- Src: https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/builtin/internal.lua |  | ||||||
| M.term_picker = function(opts) |  | ||||||
|    local pickers, finders, previewers, make_entry, actions, action_state, utils, conf |  | ||||||
|    if pcall(require, "telescope") then |  | ||||||
|       pickers = require "telescope.pickers" |  | ||||||
|       finders = require "telescope.finders" |  | ||||||
|       previewers = require "telescope.previewers" |  | ||||||
| 
 |  | ||||||
|       make_entry = require "telescope.make_entry" |  | ||||||
|       actions = require "telescope.actions" |  | ||||||
|       action_state = require "telescope.actions.state" |  | ||||||
|       utils = require "telescope.utils" |  | ||||||
|       conf = require("telescope.config").values |  | ||||||
|    else |  | ||||||
|       error "Cannot find telescope!" |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    local filter = vim.tbl_filter |  | ||||||
| 
 |  | ||||||
|    local local_utils = require "utils" |  | ||||||
| 
 |  | ||||||
|    -- buffer number and name |  | ||||||
|    local bufnr = vim.api.nvim_get_current_buf() |  | ||||||
|    local bufname = vim.api.nvim_buf_get_name(bufnr) |  | ||||||
| 
 |  | ||||||
|    local bufnrs = filter(function(b) |  | ||||||
|       local present_type, type = pcall(function() |  | ||||||
|          return vim.api.nvim_buf_get_var(b, "term_type") |  | ||||||
|       end) |  | ||||||
| 
 |  | ||||||
|       if not present_type then |  | ||||||
|          -- let's only terms that we created |  | ||||||
|          return false |  | ||||||
|       end |  | ||||||
| 
 |  | ||||||
|       -- if 1 ~= vim.fn.buflisted(b) then |  | ||||||
|       --    return false |  | ||||||
|       -- end |  | ||||||
|       -- only hide unloaded buffers if opts.show_all_buffers is false, keep them listed if true or nil |  | ||||||
|       if opts.show_all_buffers == false and not vim.api.nvim_buf_is_loaded(b) then |  | ||||||
|          return false |  | ||||||
|       end |  | ||||||
|       if opts.ignore_current_buffer and b == vim.api.nvim_get_current_buf() then |  | ||||||
|          return false |  | ||||||
|       end |  | ||||||
|       return true |  | ||||||
|    end, vim.api.nvim_list_bufs()) |  | ||||||
|    if not next(bufnrs) then |  | ||||||
|       return |  | ||||||
|    end |  | ||||||
|    if opts.sort_mru then |  | ||||||
|       table.sort(bufnrs, function(a, b) |  | ||||||
|          return vim.fn.getbufinfo(a)[1].lastused > vim.fn.getbufinfo(b)[1].lastused |  | ||||||
|       end) |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    local buffers = {} |  | ||||||
|    local default_selection_idx = 1 |  | ||||||
|    for _, bufnr in ipairs(bufnrs) do |  | ||||||
|       local flag = bufnr == vim.fn.bufnr "" and "%" or (bufnr == vim.fn.bufnr "#" and "#" or " ") |  | ||||||
| 
 |  | ||||||
|       if opts.sort_lastused and not opts.ignore_current_buffer and flag == "#" then |  | ||||||
|          default_selection_idx = 2 |  | ||||||
|       end |  | ||||||
| 
 |  | ||||||
|       local element = { |  | ||||||
|          bufnr = bufnr, |  | ||||||
|          flag = flag, |  | ||||||
|          info = vim.fn.getbufinfo(bufnr)[1], |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       if opts.sort_lastused and (flag == "#" or flag == "%") then |  | ||||||
|          local idx = ((buffers[1] ~= nil and buffers[1].flag == "%") and 2 or 1) |  | ||||||
|          table.insert(buffers, idx, element) |  | ||||||
|       else |  | ||||||
|          table.insert(buffers, element) |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    if not opts.bufnr_width then |  | ||||||
|       local max_bufnr = math.max(unpack(bufnrs)) |  | ||||||
|       opts.bufnr_width = #tostring(max_bufnr) |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    pickers.new(opts, { |  | ||||||
|       prompt_title = "Terminal buffers", |  | ||||||
|       finder = finders.new_table { |  | ||||||
|          results = buffers, |  | ||||||
|          entry_maker = opts.entry_maker or make_entry.gen_from_buffer(opts), |  | ||||||
|       }, |  | ||||||
|       previewer = conf.grep_previewer(opts), |  | ||||||
|       sorter = conf.generic_sorter(opts), |  | ||||||
|       default_selection_index = default_selection_idx, |  | ||||||
|       attach_mappings = function(prompt_bufnr) |  | ||||||
|          actions.select_default:replace(function() |  | ||||||
|             local entry = action_state.get_selected_entry() |  | ||||||
|             actions.close(prompt_bufnr) |  | ||||||
| 
 |  | ||||||
|             local buf = entry.bufnr |  | ||||||
| 
 |  | ||||||
|             local chad_term, type = pcall(function() |  | ||||||
|                return vim.api.nvim_buf_get_var(buf, "term_type") |  | ||||||
|             end) |  | ||||||
| 
 |  | ||||||
|             -- TODO buffer checks/error detection (make sure we do get a buf) |  | ||||||
| 
 |  | ||||||
|             if chad_term then |  | ||||||
|                if type == "wind" then |  | ||||||
|                   -- swtich to term buff & show in bufferline |  | ||||||
|                   vim.cmd(string.format("b %d | setlocal bl", buf)) |  | ||||||
|                   -- vim.cmd('startinsert') TODO fix this |  | ||||||
|                elseif type == "vert" then |  | ||||||
|                   vim.cmd(string.format("vsp #%d", buf)) |  | ||||||
|                   -- vim.cmd('startinsert') TODO fix this |  | ||||||
|                elseif type == "hori" then |  | ||||||
|                   -- TODO change 15 to a chad config var number |  | ||||||
|                   vim.cmd(string.format("15 sp #%d ", buf)) |  | ||||||
|                   -- vim.cmd('startinsert') TODO fix this |  | ||||||
|                end |  | ||||||
|             end |  | ||||||
|          end) |  | ||||||
| 
 |  | ||||||
|          return true |  | ||||||
|       end, |  | ||||||
|    }):find() |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- register term picker as terms to telescope |  | ||||||
| local present, telescope = pcall(require, "telescope") |  | ||||||
| if present then |  | ||||||
|    return telescope.register_extension { |  | ||||||
|       exports = { |  | ||||||
|          terms = M.term_picker, |  | ||||||
|       }, |  | ||||||
|    } |  | ||||||
| else |  | ||||||
|    error "Cannot find telescope!" |  | ||||||
| end |  | ||||||
| @ -1,142 +0,0 @@ | |||||||
| -- This file can be loaded as a telescope extension |  | ||||||
| local M = {} |  | ||||||
| 
 |  | ||||||
| -- Custom theme picker |  | ||||||
| -- Most of the code is copied from telescope colorscheme plugin, mostly for preview creation |  | ||||||
| M.theme_switcher = function(opts) |  | ||||||
|    local pickers, finders, previewers, actions, action_state, utils, conf |  | ||||||
|    if pcall(require, "telescope") then |  | ||||||
|       pickers = require "telescope.pickers" |  | ||||||
|       finders = require "telescope.finders" |  | ||||||
|       previewers = require "telescope.previewers" |  | ||||||
| 
 |  | ||||||
|       actions = require "telescope.actions" |  | ||||||
|       action_state = require "telescope.actions.state" |  | ||||||
|       utils = require "telescope.utils" |  | ||||||
|       conf = require("telescope.config").values |  | ||||||
|    else |  | ||||||
|       error "Cannot find telescope!" |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    local local_utils = require "utils" |  | ||||||
|    local reload_theme = local_utils.reload_theme |  | ||||||
| 
 |  | ||||||
|    -- get a table of available themes |  | ||||||
|    local themes = local_utils.list_themes() |  | ||||||
|    if next(themes) ~= nil then |  | ||||||
|       -- save this to use it for later to restore if theme not changed |  | ||||||
|       local current_theme = vim.g.nvchad_theme |  | ||||||
|       local new_theme = "" |  | ||||||
|       local change = false |  | ||||||
| 
 |  | ||||||
|       -- buffer number and name |  | ||||||
|       local bufnr = vim.api.nvim_get_current_buf() |  | ||||||
|       local bufname = vim.api.nvim_buf_get_name(bufnr) |  | ||||||
| 
 |  | ||||||
|       local previewer |  | ||||||
| 
 |  | ||||||
|       -- in case its not a normal buffer |  | ||||||
|       if vim.fn.buflisted(bufnr) ~= 1 then |  | ||||||
|          local deleted = false |  | ||||||
|          local function del_win(win_id) |  | ||||||
|             if win_id and vim.api.nvim_win_is_valid(win_id) then |  | ||||||
|                utils.buf_delete(vim.api.nvim_win_get_buf(win_id)) |  | ||||||
|                pcall(vim.api.nvim_win_close, win_id, true) |  | ||||||
|             end |  | ||||||
|          end |  | ||||||
| 
 |  | ||||||
|          previewer = previewers.new { |  | ||||||
|             preview_fn = function(_, entry, status) |  | ||||||
|                if not deleted then |  | ||||||
|                   deleted = true |  | ||||||
|                   del_win(status.preview_win) |  | ||||||
|                   del_win(status.preview_border_win) |  | ||||||
|                end |  | ||||||
|                reload_theme(entry.value) |  | ||||||
|             end, |  | ||||||
|          } |  | ||||||
|       else |  | ||||||
|          -- show current buffer content in previewer |  | ||||||
|          previewer = previewers.new_buffer_previewer { |  | ||||||
|             get_buffer_by_name = function() |  | ||||||
|                return bufname |  | ||||||
|             end, |  | ||||||
|             define_preview = function(self, entry) |  | ||||||
|                if vim.loop.fs_stat(bufname) then |  | ||||||
|                   conf.buffer_previewer_maker(bufname, self.state.bufnr, { bufname = self.state.bufname }) |  | ||||||
|                else |  | ||||||
|                   local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) |  | ||||||
|                   vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines) |  | ||||||
|                end |  | ||||||
|                reload_theme(entry.value) |  | ||||||
|             end, |  | ||||||
|          } |  | ||||||
|       end |  | ||||||
| 
 |  | ||||||
|       local picker = pickers.new { |  | ||||||
|          prompt_title = "Set NvChad color", |  | ||||||
|          finder = finders.new_table(themes), |  | ||||||
|          previewer = previewer, |  | ||||||
|          sorter = conf.generic_sorter(opts), |  | ||||||
|          attach_mappings = function() |  | ||||||
|             actions.select_default:replace( |  | ||||||
|                -- if a entry is selected, change current_theme to that |  | ||||||
|                function(prompt_bufnr) |  | ||||||
|                   local selection = action_state.get_selected_entry() |  | ||||||
|                   new_theme = selection.value |  | ||||||
|                   change = true |  | ||||||
|                   actions.close(prompt_bufnr) |  | ||||||
|                end |  | ||||||
|             ) |  | ||||||
|             return true |  | ||||||
|          end, |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       -- rewrite picker.close_windows |  | ||||||
|       local close_windows = picker.close_windows |  | ||||||
|       picker.close_windows = function(status) |  | ||||||
|          close_windows(status) |  | ||||||
|          -- now apply the theme, if success, then ask for default theme change |  | ||||||
|          local final_theme |  | ||||||
|          if change then |  | ||||||
|             final_theme = new_theme |  | ||||||
|          else |  | ||||||
|             final_theme = current_theme |  | ||||||
|          end |  | ||||||
| 
 |  | ||||||
|          if reload_theme(final_theme) then |  | ||||||
|             if change then |  | ||||||
|                -- ask for confirmation to set as default theme |  | ||||||
|                local ans = string.lower(vim.fn.input("Set " .. new_theme .. " as default theme ? [y/N] ")) == "y" |  | ||||||
|                local_utils.clear_cmdline() |  | ||||||
|                if ans then |  | ||||||
|                   local_utils.change_theme(current_theme, final_theme) |  | ||||||
|                else |  | ||||||
|                   -- will be used in restoring nvchad theme var |  | ||||||
|                   final_theme = current_theme |  | ||||||
|                end |  | ||||||
|             end |  | ||||||
|          else |  | ||||||
|             final_theme = current_theme |  | ||||||
|          end |  | ||||||
|          -- set nvchad_theme global var |  | ||||||
|          vim.g.nvchad_theme = final_theme |  | ||||||
|       end |  | ||||||
|       -- launch the telescope picker |  | ||||||
|       picker:find() |  | ||||||
|    else |  | ||||||
|       print("No themes found in " .. vim.fn.stdpath "config" .. "/lua/themes") |  | ||||||
|    end |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- register theme swticher as themes to telescope |  | ||||||
| local present, telescope = pcall(require, "telescope") |  | ||||||
| if present then |  | ||||||
|    return telescope.register_extension { |  | ||||||
|       exports = { |  | ||||||
|          themes = M.theme_switcher, |  | ||||||
|       }, |  | ||||||
|    } |  | ||||||
| else |  | ||||||
|    error "Cannot find telescope!" |  | ||||||
| end |  | ||||||
| @ -1,12 +0,0 @@ | |||||||
| local chad_theme = require("utils").load_config().ui.theme |  | ||||||
| vim.g.nvchad_theme = chad_theme |  | ||||||
| 
 |  | ||||||
| local present, base16 = pcall(require, "base16") |  | ||||||
| 
 |  | ||||||
| if present then |  | ||||||
|    base16(base16.themes(chad_theme), true) |  | ||||||
|    require "highlights" |  | ||||||
|    return true |  | ||||||
| else |  | ||||||
|    return false |  | ||||||
| end |  | ||||||
							
								
								
									
										531
									
								
								lua/utils.lua
									
									
									
									
									
								
							
							
						
						
									
										531
									
								
								lua/utils.lua
									
									
									
									
									
								
							| @ -1,531 +0,0 @@ | |||||||
| local M = {} |  | ||||||
| 
 |  | ||||||
| -- 1st arg as current theme, 2nd as new theme |  | ||||||
| M.change_theme = function(current_theme, new_theme) |  | ||||||
|    if current_theme == nil or new_theme == nil then |  | ||||||
|       print "Error: Provide current and new theme name" |  | ||||||
|       return false |  | ||||||
|    end |  | ||||||
|    if current_theme == new_theme then |  | ||||||
|       return |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    local user_config = vim.g.nvchad_user_config |  | ||||||
|    local file = vim.fn.stdpath "config" .. "/lua/" .. user_config .. ".lua" |  | ||||||
|    -- store in data variable |  | ||||||
|    local data = assert(M.file("r", file)) |  | ||||||
|    -- escape characters which can be parsed as magic chars |  | ||||||
|    current_theme = current_theme:gsub("%p", "%%%0") |  | ||||||
|    new_theme = new_theme:gsub("%p", "%%%0") |  | ||||||
|    local find = "theme = .?" .. current_theme .. ".?" |  | ||||||
|    local replace = 'theme = "' .. new_theme .. '"' |  | ||||||
|    local content = string.gsub(data, find, replace) |  | ||||||
|    -- see if the find string exists in file |  | ||||||
|    if content == data then |  | ||||||
|       print("Error: Cannot change default theme with " .. new_theme .. ", edit " .. file .. " manually") |  | ||||||
|       return false |  | ||||||
|    else |  | ||||||
|       assert(M.file("w", file, content)) |  | ||||||
|    end |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.clear_cmdline = function() |  | ||||||
|    vim.defer_fn(function() |  | ||||||
|       vim.cmd "echo" |  | ||||||
|    end, 0) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| M.close_buffer = function(bufexpr, 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 |  | ||||||
|          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, type = 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)) |  | ||||||
|             -- swtich to another buff |  | ||||||
|             -- TODO switch to next bufffer, 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 |  | ||||||
| 
 |  | ||||||
| -- wrapper to use vim.api.nvim_echo |  | ||||||
| -- table of {string, highlight} |  | ||||||
| -- e.g echo({{"Hello", "Title"}, {"World"}}) |  | ||||||
| M.echo = function(opts) |  | ||||||
|    if opts == nil or type(opts) ~= "table" then |  | ||||||
|       return |  | ||||||
|    end |  | ||||||
|    vim.api.nvim_echo(opts, false, {}) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- 1st arg - r or w |  | ||||||
| -- 2nd arg - file path |  | ||||||
| -- 3rd arg - content if 1st arg is w |  | ||||||
| -- return file data on read, nothing on write |  | ||||||
| M.file = function(mode, filepath, content) |  | ||||||
|    local data |  | ||||||
|    local fd = assert(vim.loop.fs_open(filepath, mode, 438)) |  | ||||||
|    local stat = assert(vim.loop.fs_fstat(fd)) |  | ||||||
|    if stat.type ~= "file" then |  | ||||||
|       data = false |  | ||||||
|    else |  | ||||||
|       if mode == "r" then |  | ||||||
|          data = assert(vim.loop.fs_read(fd, stat.size, 0)) |  | ||||||
|       else |  | ||||||
|          assert(vim.loop.fs_write(fd, content, 0)) |  | ||||||
|          data = true |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
|    assert(vim.loop.fs_close(fd)) |  | ||||||
|    return data |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- hide statusline |  | ||||||
| -- tables fetched from load_config function |  | ||||||
| M.hide_statusline = function(values) |  | ||||||
|    local hidden = require("utils").load_config().ui.statusline.hidden |  | ||||||
|    local shown = require("utils").load_config().ui.statusline.shown |  | ||||||
|    local api = vim.api |  | ||||||
|    local buftype = api.nvim_buf_get_option("%", "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 |  | ||||||
|    else |  | ||||||
|       api.nvim_set_option("laststatus", 2) |  | ||||||
|    end |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- return a table of available themes |  | ||||||
| M.list_themes = function(return_type) |  | ||||||
|    local themes = {} |  | ||||||
|    -- folder where theme files are stored |  | ||||||
|    local themes_folder = vim.fn.stdpath "config" .. "/lua/themes" |  | ||||||
|    -- list all the contents of the folder and filter out files with .lua extension, then append to themes table |  | ||||||
|    local fd = vim.loop.fs_scandir(themes_folder) |  | ||||||
|    if fd then |  | ||||||
|       while true do |  | ||||||
|          local name, typ = vim.loop.fs_scandir_next(fd) |  | ||||||
|          if name == nil then |  | ||||||
|             break |  | ||||||
|          end |  | ||||||
|          if typ ~= "directory" and string.find(name, ".lua") then |  | ||||||
|             -- return the table values as keys if specified |  | ||||||
|             if return_type == "keys_as_value" then |  | ||||||
|                themes[vim.fn.fnamemodify(name, ":r")] = true |  | ||||||
|             else |  | ||||||
|                table.insert(themes, vim.fn.fnamemodify(name, ":r")) |  | ||||||
|             end |  | ||||||
|          end |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
|    return themes |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- Base code: https://gist.github.com/revolucas/184aec7998a6be5d2f61b984fac1d7f7 |  | ||||||
| -- Changes over it: preserving table 1 contents and also update with table b, without duplicating |  | ||||||
| -- 1st arg - base table, 2nd arg - table to merge |  | ||||||
| M.merge_table = function(into, from) |  | ||||||
|    -- make sure both are table |  | ||||||
|    if type(into) ~= "table" or type(from) ~= "table" then |  | ||||||
|       return into |  | ||||||
|    end |  | ||||||
|    local stack, seen = {}, {} |  | ||||||
|    local table1, table2 = into, from |  | ||||||
|    while true do |  | ||||||
|       for k, v in pairs(table2) do |  | ||||||
|          if type(v) == "table" and type(table1[k]) == "table" then |  | ||||||
|             table.insert(stack, { table1[k], table2[k] }) |  | ||||||
|          else |  | ||||||
|             local present = seen[v] or false |  | ||||||
|             if not present then |  | ||||||
|                if type(k) == "number" then |  | ||||||
|                   -- add the value to seen table until value is found |  | ||||||
|                   -- only do when key is number we just want to append to subtables |  | ||||||
|                   -- todo: maybe improve this |  | ||||||
| 
 |  | ||||||
|                   for _, value in pairs(table1) do |  | ||||||
|                      if value == v then |  | ||||||
|                         present = true |  | ||||||
|                         break |  | ||||||
|                      end |  | ||||||
|                   end |  | ||||||
|                   seen[v] = true |  | ||||||
|                   if not present then |  | ||||||
|                      table1[#table1 + 1] = v |  | ||||||
|                   end |  | ||||||
|                else |  | ||||||
|                   table1[k] = v |  | ||||||
|                end |  | ||||||
|             end |  | ||||||
|          end |  | ||||||
|       end |  | ||||||
|       if #stack > 0 then |  | ||||||
|          local t = stack[#stack] |  | ||||||
|          table1, table2 = t[1], t[2] |  | ||||||
|          stack[#stack] = nil |  | ||||||
|       else |  | ||||||
|          break |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
|    return into |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- load config |  | ||||||
| -- 1st arg = boolean - whether to force reload |  | ||||||
| -- Modifies _G._NVCHAD_CONFIG global variable |  | ||||||
| M.load_config = function(reload) |  | ||||||
|    -- only do the stuff below one time, otherwise just return the set config |  | ||||||
|    if _G._NVCHAD_CONFIG_CONTENTS ~= nil and not (reload or false) then |  | ||||||
|       return _G._NVCHAD_CONFIG_CONTENTS |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    local default_config = "default_config" |  | ||||||
|    local config_name = vim.g.nvchad_user_config or "chadrc" |  | ||||||
|    local config_file = vim.fn.stdpath "config" .. "/lua/" .. config_name .. ".lua" |  | ||||||
| 
 |  | ||||||
|    -- unload the modules if force reload |  | ||||||
|    if reload then |  | ||||||
|       package.loaded[default_config or false] = nil |  | ||||||
|       package.loaded[config_name or false] = nil |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    -- don't enclose in pcall, it better break when default config is faulty |  | ||||||
|    _G._NVCHAD_CONFIG_CONTENTS = require(default_config) |  | ||||||
| 
 |  | ||||||
|    -- user config is not required to run nvchad but a optional |  | ||||||
|    -- Make sure the config doesn't break the whole system if user config is not present or in bad state or not a table |  | ||||||
|    -- print warning texts if user config file is  present |  | ||||||
|    -- check if the user config is present |  | ||||||
|    if vim.fn.empty(vim.fn.glob(config_file)) < 1 then |  | ||||||
|       local present, config = pcall(require, config_name) |  | ||||||
|       if present then |  | ||||||
|          -- make sure the returned value is table |  | ||||||
|          if type(config) == "table" then |  | ||||||
|             -- data = require(config_name) |  | ||||||
|             _G._NVCHAD_CONFIG_CONTENTS = require("utils").merge_table(_G._NVCHAD_CONFIG_CONTENTS, config) |  | ||||||
|          else |  | ||||||
|             print("Warning: " .. config_name .. " sourced successfully but did not return a lua table.") |  | ||||||
|          end |  | ||||||
|       else |  | ||||||
|          print("Warning: " .. config_file .. " is present but sourcing failed.") |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
|    return _G._NVCHAD_CONFIG_CONTENTS |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- reload a plugin ( will try to load even if not loaded) |  | ||||||
| -- can take a string or list ( table ) |  | ||||||
| -- return true or false |  | ||||||
| M.reload_plugin = function(plugins) |  | ||||||
|    local status = true |  | ||||||
|    local function _reload_plugin(plugin) |  | ||||||
|       local loaded = package.loaded[plugin] |  | ||||||
|       if loaded then |  | ||||||
|          package.loaded[plugin] = nil |  | ||||||
|       end |  | ||||||
|       if not pcall(require, plugin) then |  | ||||||
|          print("Error: Cannot load " .. plugin .. " plugin!") |  | ||||||
|          status = false |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    if type(plugins) == "string" then |  | ||||||
|       _reload_plugin(plugins) |  | ||||||
|    elseif type(plugins) == "table" then |  | ||||||
|       for _, plugin in ipairs(plugins) do |  | ||||||
|          _reload_plugin(plugin) |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
|    return status |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- reload themes without restarting vim |  | ||||||
| -- if no theme name given then reload the current theme |  | ||||||
| M.reload_theme = function(theme_name) |  | ||||||
|    local reload_plugin = require("utils").reload_plugin |  | ||||||
| 
 |  | ||||||
|    -- if theme name is empty or nil, then reload the current theme |  | ||||||
|    if theme_name == nil or theme_name == "" then |  | ||||||
|       theme_name = vim.g.nvchad_theme |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    if not pcall(require, "themes/" .. theme_name) then |  | ||||||
|       print("No such theme ( " .. theme_name .. " )") |  | ||||||
|       return false |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    vim.g.nvchad_theme = theme_name |  | ||||||
| 
 |  | ||||||
|    -- reload the base16 theme |  | ||||||
|    local ok, base16 = pcall(require, "base16") |  | ||||||
|    if not ok then |  | ||||||
|       print "Error: Cannot load base16 plugin!" |  | ||||||
|       return false |  | ||||||
|    end |  | ||||||
|    base16(base16.themes(theme_name), true) |  | ||||||
| 
 |  | ||||||
|    if |  | ||||||
|       not reload_plugin { |  | ||||||
|          "highlights", |  | ||||||
|          "plugins.bufferline", |  | ||||||
|          "galaxyline", |  | ||||||
|          "plugins.statusline", |  | ||||||
|       } |  | ||||||
|    then |  | ||||||
|       print "Error: Not able to reload all plugins." |  | ||||||
|       return false |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    -- yes, this is very hacky, but due to new_async in |  | ||||||
|    -- https://github.com/glepnir/galaxyline.nvim/blob/main/lua/galaxyline/provider.lua#L5-L36 |  | ||||||
|    -- it doesn't work properly and some statusline stuff dissapears |  | ||||||
|    local vcs = require "galaxyline.provider_vcs" |  | ||||||
|    local fileinfo = require "galaxyline.provider_fileinfo" |  | ||||||
|    local buffer = require "galaxyline.provider_buffer" |  | ||||||
|    local extension = require "galaxyline.provider_extensions" |  | ||||||
|    local whitespace = require "galaxyline.provider_whitespace" |  | ||||||
|    local lspclient = require "galaxyline.provider_lsp" |  | ||||||
|    _G.galaxyline_providers = { |  | ||||||
|       BufferIcon = buffer.get_buffer_type_icon, |  | ||||||
|       BufferNumber = buffer.get_buffer_number, |  | ||||||
|       FileTypeName = buffer.get_buffer_filetype, |  | ||||||
|       GitBranch = vcs.get_git_branch, |  | ||||||
|       DiffAdd = vcs.diff_add, |  | ||||||
|       DiffModified = vcs.diff_modified, |  | ||||||
|       DiffRemove = vcs.diff_remove, |  | ||||||
|       LineColumn = fileinfo.line_column, |  | ||||||
|       FileFormat = fileinfo.get_file_format, |  | ||||||
|       FileEncode = fileinfo.get_file_encode, |  | ||||||
|       FileSize = fileinfo.get_file_size, |  | ||||||
|       FileIcon = fileinfo.get_file_icon, |  | ||||||
|       FileName = fileinfo.get_current_file_name, |  | ||||||
|       SFileName = fileinfo.filename_in_special_buffer, |  | ||||||
|       LinePercent = fileinfo.current_line_percent, |  | ||||||
|       ScrollBar = extension.scrollbar_instance, |  | ||||||
|       VistaPlugin = extension.vista_nearest, |  | ||||||
|       WhiteSpace = whitespace.get_item, |  | ||||||
|       GetLspClient = lspclient.get_lsp_client, |  | ||||||
|    } |  | ||||||
|    local diagnostic = require "galaxyline.provider_diagnostic" |  | ||||||
|    _G.galaxyline_providers.DiagnosticError = diagnostic.get_diagnostic_error |  | ||||||
|    _G.galaxyline_providers.DiagnosticWarn = diagnostic.get_diagnostic_warn |  | ||||||
|    _G.galaxyline_providers.DiagnosticHint = diagnostic.get_diagnostic_hint |  | ||||||
|    _G.galaxyline_providers.DiagnosticInfo = diagnostic.get_diagnostic_info |  | ||||||
| 
 |  | ||||||
|    return true |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- toggle between 2 themes |  | ||||||
| -- argument should be a table with 2 theme names |  | ||||||
| M.toggle_theme = function(themes) |  | ||||||
|    local current_theme = vim.g.current_nvchad_theme or vim.g.nvchad_theme |  | ||||||
|    for _, name in ipairs(themes) do |  | ||||||
|       if name ~= current_theme then |  | ||||||
|          if require("utils").reload_theme(name) then |  | ||||||
|             -- open a buffer and close it to reload the statusline |  | ||||||
|             vim.cmd "new|bwipeout" |  | ||||||
|             vim.g.current_nvchad_theme = name |  | ||||||
|             if M.change_theme(vim.g.nvchad_theme, name) then |  | ||||||
|                vim.g.nvchad_theme = name |  | ||||||
|             end |  | ||||||
|          end |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| -- update nvchad |  | ||||||
| M.update_nvchad = function() |  | ||||||
|    -- in all the comments below, config means user config |  | ||||||
|    local config_path = vim.fn.stdpath "config" |  | ||||||
|    local config_name = vim.g.nvchad_user_config or "chadrc" |  | ||||||
|    local config_file = config_path .. "/lua/" .. config_name .. ".lua" |  | ||||||
|    -- generate a random file name |  | ||||||
|    local config_file_backup = config_path .. "/" .. config_name .. ".lua.bak." .. math.random() |  | ||||||
|    local utils = require "utils" |  | ||||||
|    local echo = utils.echo |  | ||||||
|    local current_config = utils.load_config() |  | ||||||
|    local update_url = current_config.options.update_url or "https://github.com/NvChad/NvChad" |  | ||||||
|    local update_branch = current_config.options.update_branch or "main" |  | ||||||
| 
 |  | ||||||
|    -- ask the user for confirmation to update because we are going to run git reset --hard |  | ||||||
|    echo { { "Url: ", "Title" }, { update_url } } |  | ||||||
|    echo { { "Branch: ", "Title" }, { update_branch } } |  | ||||||
|    echo { |  | ||||||
|       { "\nUpdater will run", "WarningMsg" }, |  | ||||||
|       { " git reset --hard " }, |  | ||||||
|       { |  | ||||||
|          "in config folder, so changes to existing repo files except ", |  | ||||||
|          "WarningMsg", |  | ||||||
|       }, |  | ||||||
| 
 |  | ||||||
|       { config_name }, |  | ||||||
|       { " will be lost!\n\nUpdate NvChad ? [y/N]", "WarningMsg" }, |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    local ans = string.lower(vim.fn.input "-> ") == "y" |  | ||||||
|    utils.clear_cmdline() |  | ||||||
|    if not ans then |  | ||||||
|       echo { { "Update cancelled!", "Title" } } |  | ||||||
|       return |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    -- first try to fetch contents of config, this will make sure it is readable and taking backup of its contents |  | ||||||
|    local config_contents = utils.file("r", config_file) |  | ||||||
|    -- also make a local backup in ~/.config/nvim, will be removed when config is succesfully restored |  | ||||||
|    utils.file("w", config_file_backup, config_contents) |  | ||||||
|    -- write original config file with its contents, will make sure charc is writable, this maybe overkill but a little precaution always helps |  | ||||||
|    utils.file("w", config_file, config_contents) |  | ||||||
| 
 |  | ||||||
|    -- function that will executed when git commands are done |  | ||||||
|    local function update_exit(_, code) |  | ||||||
|       -- restore config file irrespective of whether git commands were succesfull or not |  | ||||||
|       if pcall(function() |  | ||||||
|          utils.file("w", config_file, config_contents) |  | ||||||
|       end) then |  | ||||||
|          -- config restored succesfully, remove backup file that was created |  | ||||||
|          if not pcall(os.remove, config_file_backup) then |  | ||||||
|             echo { { "Warning: Failed to remove backup chadrc, remove manually.", "WarningMsg" } } |  | ||||||
|             echo { { "Path: ", "WarningMsg" }, { config_file_backup } } |  | ||||||
|          end |  | ||||||
|       else |  | ||||||
|          echo { { "Error: Restoring " .. config_name .. " failed.\n", "ErrorMsg" } } |  | ||||||
|          echo { { "Backed up " .. config_name .. " path: " .. config_file_backup .. "\n\n", "None" } } |  | ||||||
|       end |  | ||||||
| 
 |  | ||||||
|       -- close the terminal buffer only if update was success, as in case of error, we need the error message |  | ||||||
|       if code == 0 then |  | ||||||
|          vim.cmd "bd!" |  | ||||||
|          echo { { "NvChad succesfully updated.\n", "String" } } |  | ||||||
|       else |  | ||||||
|          echo { { "Error: NvChad Update failed.\n", "ErrorMsg" } } |  | ||||||
|       end |  | ||||||
|    end |  | ||||||
| 
 |  | ||||||
|    -- git commands that will executed, reset in case config was modfied |  | ||||||
|    -- use --rebase, to not mess up if the local repo is outdated |  | ||||||
|    local update_script = table.concat({ |  | ||||||
|       "git reset --hard && git pull --set-upstream", |  | ||||||
|       update_url, |  | ||||||
|       update_branch, |  | ||||||
|       "--rebase", |  | ||||||
|    }, " ") |  | ||||||
| 
 |  | ||||||
|    -- open a new buffer |  | ||||||
|    vim.cmd "new" |  | ||||||
|    -- finally open the pseudo terminal buffer |  | ||||||
|    vim.fn.termopen(update_script, { |  | ||||||
|       -- change dir to config path so we don't need to move in script |  | ||||||
|       cwd = config_path, |  | ||||||
|       on_exit = update_exit, |  | ||||||
|    }) |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| return M |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user