diff options
| -rw-r--r-- | lua/plugins/colorscheme.lua | 2 | ||||
| -rw-r--r-- | lua/plugins/linecolor.lua | 112 | ||||
| -rw-r--r-- | lua/plugins/lsp-colors.lua | 9 | ||||
| -rw-r--r-- | lua/plugins/lspkind.lua | 47 | ||||
| -rw-r--r-- | lua/plugins/lspsaga-22.10.23-13:08-bak.lua | 145 | ||||
| -rw-r--r-- | lua/plugins/lspsaga.lua | 46 | ||||
| -rw-r--r-- | lua/plugins/lualine.lua | 423 | ||||
| -rw-r--r-- | lua/plugins/luasnip-22.10.23-12:54-bak.lua | 161 | ||||
| -rw-r--r-- | lua/plugins/toggleterm.lua | 90 | ||||
| -rw-r--r-- | lua/user/colorscheme.lua | 5 | ||||
| -rw-r--r-- | lua/user/keys.lua | 69 | ||||
| -rw-r--r-- | lua/user/opts.lua | 68 | ||||
| -rw-r--r-- | lua/user/reload.lua | 8 | ||||
| -rw-r--r-- | lua/user/utils.lua | 9 | ||||
| -rw-r--r-- | snippets/lua.lua | 9 |
15 files changed, 152 insertions, 1051 deletions
diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 3ded54c..dc0145d 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -1,6 +1,6 @@ -- Colorscheme -- ayu gruvbox molokai onedark srcery everblush vscode edge nightfly doom-one -local colorscheme = "doom-one" +local colorscheme = "onedark" local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) if not status_ok then vim.notify("colorscheme " .. colorscheme .. " not found!") diff --git a/lua/plugins/linecolor.lua b/lua/plugins/linecolor.lua deleted file mode 100644 index 37550dd..0000000 --- a/lua/plugins/linecolor.lua +++ /dev/null @@ -1,112 +0,0 @@ ---local M = {} ---M.theme = function() --- -- I know I could just set bg = nil but I'm leaving this here in case I want custom colors in the future --- local colors = { --- nobg = nil, --- blue = "#87b0f9", --- mauve = "#cba6f7", --- red = "#f38ba8", --- green = "#a6e3a1", --- peach = "#fab387", --- white = "#c6d0f5", --- gray = "#a1a8c9", --- black = "#1e1e2e", --- } --- return { --- inactive = { --- a = { fg = colors.blue, bg = colors.nobg, gui = "bold" }, --- b = { fg = colors.white, bg = colors.black }, --- c = { fg = colors.gray, bg = colors.nobg }, --- }, --- visual = { --- a = { fg = colors.black, bg = colors.mauve, gui = "bold" }, --- b = { fg = colors.mauve, bg = colors.nobg }, --- c = { fg = colors.white, bg = colors.nobg }, --- }, --- replace = { --- a = { fg = colors.black, bg = colors.red, gui = "bold" }, --- b = { fg = colors.red, bg = colors.nobg }, --- c = { fg = colors.white, bg = colors.nobg }, --- }, --- normal = { --- a = { fg = colors.black, bg = colors.blue, gui = "bold" }, --- b = { fg = colors.black, bg = colors.green }, --- c = { fg = colors.white, bg = colors.black }, --- }, --- insert = { --- a = { fg = colors.black, bg = colors.green, gui = "bold" }, --- b = { fg = colors.teal, bg = colors.nobg }, --- c = { fg = colors.white, bg = colors.nobg }, --- }, --- command = { --- a = { fg = colors.black, bg = colors.peach, gui = "bold" }, --- b = { fg = colors.peach, bg = colors.nobg }, --- c = { fg = colors.white, bg = colors.nobg }, --- }, --- modified = { --- a = { fg = colors.black, bg = colors.peach, gui = "bold" }, --- b = { fg = colors.peach, bg = colors.peach }, --- c = { fg = colors.white, bg = colors.peach }, --- }, --- } ---end ---return M -local M = {} -M.theme = function() - --local colors = { - -- darkgray = "#16161d", - -- gray = "#727169", - -- innerbg = nil, - -- outerbg = "#16161D", - -- normal = "#7e9cd8", - -- insert = "#98bb6c", - -- visual = "#ffa066", - -- replace = "#e46876", - -- command = "#e6c384", - --} - local colors = { - darkgray = "#16161d", - gray = "#727169", - innerbg = nil, - outerbg = "#16161D", - normal = "#39BAE6", - insert = "#AAD94C", - visual = "#FA8D3F", - replace = "#F07171", - command = "#F2AE49", - } - return { - inactive = { - a = { fg = colors.gray, bg = colors.outerbg, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - visual = { - a = { fg = colors.darkgray, bg = colors.visual, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - replace = { - a = { fg = colors.darkgray, bg = colors.replace, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - normal = { - a = { fg = colors.darkgray, bg = colors.normal, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - y = { fg = colors.gray, bg = colors.outerbg }, - }, - insert = { - a = { fg = colors.darkgray, bg = colors.insert, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - command = { - a = { fg = colors.darkgray, bg = colors.command, gui = "bold" }, - b = { fg = colors.gray, bg = colors.outerbg }, - c = { fg = colors.gray, bg = colors.innerbg }, - }, - } -end -return M diff --git a/lua/plugins/lsp-colors.lua b/lua/plugins/lsp-colors.lua deleted file mode 100644 index 1398123..0000000 --- a/lua/plugins/lsp-colors.lua +++ /dev/null @@ -1,9 +0,0 @@ -local status, colors = pcall(require, "lsp-colors") -if (not status) then return end - -colors.setup { - Error = "#db4b4b", - Warning = "#e0af68", - Information = "#0db9d7", - Hint = "#10B981" -} diff --git a/lua/plugins/lspkind.lua b/lua/plugins/lspkind.lua deleted file mode 100644 index 72ca5c2..0000000 --- a/lua/plugins/lspkind.lua +++ /dev/null @@ -1,47 +0,0 @@ -local status, lspkind = pcall(require, "lspkind") -if (not status) then return end - -lspkind.init({ - -- enables text annotations - -- - -- default: true - mode = 'symbol', - - -- default symbol map - -- can be either 'default' (requires nerd-fonts font) or - -- 'codicons' for codicon preset (requires vscode-codicons font) - -- - -- default: 'default' - preset = 'codicons', - - -- override preset symbols - -- - -- default: {} - symbol_map = { - Text = "", - Method = "", - Function = "", - Constructor = "", - Field = "ﰠ", - Variable = "", - Class = "ﴯ", - Interface = "", - Module = "", - Property = "ﰠ", - Unit = "塞", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "פּ", - Event = "", - Operator = "", - TypeParameter = "" - }, -}) diff --git a/lua/plugins/lspsaga-22.10.23-13:08-bak.lua b/lua/plugins/lspsaga-22.10.23-13:08-bak.lua deleted file mode 100644 index 0bf1ec7..0000000 --- a/lua/plugins/lspsaga-22.10.23-13:08-bak.lua +++ /dev/null @@ -1,145 +0,0 @@ -require "lspsaga".init_lsp_saga { - -- "single" | "double" | "rounded" | "bold" | "plus" - border_style = "rounded", - --border_style = "single", - saga_winblend = 30, - move_in_saga = { next = '<C-n>', prev = '<C-p>' }, - --move_in_saga = { prev = "k", next = "j" }, - scroll_in_preview = { - scroll_down = "<C-d>", - scroll_up = "<C-u>", - }, - diagnostic_header = { " ", " ", " ", " " }, - -- add bracket or something with diagnostic source, just have 2 elements - -- use emoji lightbulb in default - code_action_icon = "", - --code_action_icon = "ﯦ ", - -- if true can press number to execute the codeaction in codeaction window - code_action_num_shortcut = true, - -- same as nvim-lightbulb but async - code_action_lightbulb = { - enable = false, - sign = false, - sign_priority = 20, -- - virtual_text = false, - }, - finder_icons = { - def = " ", - ref = " ", - link = " ", - }, - -- preview lines of lsp_finder and definition preview - max_preview_lines = 5, - definition_action_keys = { - edit = '<CR>', - vsplit = '<C-y>', - split = '<C-x>', - tabe = '<C-t>', - quit = '<ESC>', - }, - -- definition_preview_quit = '<ESC>', - -- finder_preview_hl_ns = 8, - finder_action_keys = { - open = { 'o', '<CR>' }, - vsplit = "v", - split = "s", - tabe = "t", - quit = "<ESC>", - scroll_down = "<C-j>", - scroll_up = "<C-k>", -- quit can be a table - }, - code_action_keys = { - quit = "<ESC>", - exec = "<CR>", - }, - rename_action_quit = "<ESC>", - rename_in_select = true, - symbol_in_winbar = { - enable = true, - --in_custom = false, - in_custom = true, - separator = ' ', - --show_file = false, - show_file = true, - click_support = false, - --click_support = false, - }, - --show_outline = { - -- win_position = 'right', - -- --set special filetype win that outline window split.like NvimTree neotree - -- -- defx, db_ui - -- min_with = '', - -- win_width = 40, - -- auto_enter = false, - -- auto_preview = true, - -- virt_text = 'x', - -- jump_key = 'l', - -- -- auto refresh when change buffer - -- auto_refresh = true, - --}, - custom_kind = { - File = { " " }, - Module = { " " }, - Namespace = { "ﱕ " }, - Package = { " " }, - Class = { "ﴯ " }, - Method = { "" }, - Property = { "ﰠ " }, - Field = { "ﰠ " }, - Constructor = { " " }, - Enum = { " " }, - Interface = { " " }, - Function = { " " }, - Variable = { " " }, - Constant = { " " }, - String = { " " }, - Number = { " " }, - Boolean = { " " }, - Array = { " " }, - Object = { " " }, - Key = { "- " }, - Null = { " " }, - EnumMember = { " " }, - Struct = { " " }, - Event = { " " }, - Operator = { " " }, - TypeParameter = { " " }, - TypeAlias = { " " }, - Parameter = { " " }, - StaticMethod = { " " }, - Macro = { "廓" }, - }, -} - - -- Mappings. -local map = vim.api.nvim_set_keymap -local opts = { noremap = true, silent = true } - -map("n", "gd", "<CMD>Lspsaga peek_definition<CR>", opts) ---map("n", "gp", "<Cmd>Lspsaga peek_definition<CR>", opts) -map("n", "gi", "<CMD>Lspsaga lsp_finder<CR>", opts) -map("n", "gh", "<CMD>Lspsaga hover_doc<CR>", opts) -map("n", "gs", "<CMD>Lspsaga signature_help<CR>", opts) -map("n", "ga", "<CMD>Lspsaga code_action<CR>", opts) -map("v", "ga", "<CMD><C-u>Lspsaga range_code_action<CR>", opts) -map("n", "gl", "<CMD>Lspsaga show_line_diagnostics<CR>", opts) ---map("n", "go", "<CMD>Lspsaga open_floaterm zsh<CR>", opts) -map("n", ";D", "<CMD>Lspsaga show_cursor_diagnostics<CR>", opts) -map("n", "<gr>", "<CMD>Lspsaga rename<CR>", opts) -map("n", "gk", "<CMD>Lspsaga diagnostic_jump_prev<CR>", opts) -map("n", "gj", "<CMD>Lspsaga diagnostic_jump_next<CR>", opts) -map("n", "[d", "<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts) -map("n", "]d", "<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts) -map("t", "<ESC>", "<CMD>Lspsaga close_floaterm<CR>", opts) - ---vim.api.nvim_command("highlight LspFloatWinNormal guibg=none ") ---hi LspFloatWinNormal guibg=none - - --- vim.api.nvim_create_autocmd("BufEnter", { --- callback = function () --- if #vim.api.nvim_list_wins() == 1 and vim.bo.filetype == "lspsagaoutline" then --- vim.cmd "quit" --- end --- end --- }) diff --git a/lua/plugins/lspsaga.lua b/lua/plugins/lspsaga.lua deleted file mode 100644 index 4161ce9..0000000 --- a/lua/plugins/lspsaga.lua +++ /dev/null @@ -1,46 +0,0 @@ -return function() - local saga = require "lspsaga" - - saga.init_lsp_saga { - use_saga_diagnostic_sign = false, - finder_action_keys = { - vsplit = "v", - split = "s", - quit = { "q", "<ESC>" }, - }, - code_action_icon = "💡", - code_action_prompt = { - enable = false, - sign = false, - virtual_text = false, - }, - } - - require("as.highlights").highlight("LspSagaLightbulb", { guifg = "NONE", guibg = "NONE" }) - --- as.vnoremap("<leader>ca", ":<c-u>lua require('lspsaga.codeaction').range_code_action()<CR>") --- as.inoremap("<c-k>", "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>") --- as.nnoremap("K", "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>") --- -- scroll down hover doc --- as.nnoremap("<C-f>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>") --- -- scroll up hover doc --- as.nnoremap("<C-b>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>") - - require("which-key").register { - ["<leader>rn"] = { require("lspsaga.rename").rename, "lsp: rename" }, - ["<leader>ca"] = { require("lspsaga.codeaction").code_action, "lsp: code action" }, - ["gp"] = { require("lspsaga.provider").preview_definition, "lsp: preview definition" }, - ["gh"] = { require("lspsaga.provider").lsp_finder, "lsp: finder" }, - -- jump diagnostic - ["]c"] = { require("lspsaga.diagnostic").lsp_jump_diagnostic_prev, "lsp: previous diagnostic" }, - ["[c"] = { require("lspsaga.diagnostic").lsp_jump_diagnostic_next, "lsp: next diagnostic" }, - } - - -- augroup("LspSagaCursorCommands", { - -- { - -- events = { "CursorHold" }, - -- targets = { "*" }, - -- command = "lua require('lspsaga.diagnostic').show_cursor_diagnostics()", - -- }, - -- }) -end diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua deleted file mode 100644 index 9d86e21..0000000 --- a/lua/plugins/lualine.lua +++ /dev/null @@ -1,423 +0,0 @@ -local lualine_status_ok, lualine = pcall(require, "lualine") -if not lualine_status_ok then - print("lualine.nvim is etiher broken or is not installed.") - return -end - ---local colors = require('tokyonight.colors').setup() ---local colors = { ---bg_dark = "#1f2335", ---bg = "#24283b", ---fg = "#c0caf5", ---fg_gutter = "#3b4261", ---green = "#a6e3a1", ---red = "#f38ba8", ---} - ---local colors = { --- gray = '#23232e', --- lightgray = '#5f6a8e', --- orange = '#ffb86c', --- purple = '#bd93f9', --- red = '#ff5555', --- yellow = '#f1fa8c', --- green = '#50fa7b', --- white = '#f8f8f2', --- black = '#282a36', ---} -local colors = { - nobg = nil, - blue = "#87b0f9", - mauve = "#cba6f7", - red = "#f38ba8", - green = "#a6e3a1", - peach = "#fab387", - white = "#c6d0f5", - gray = "#a1a8c9", - black = "#1e1e2e", - innerbg = nil, - outerbg = "#16161D", -} ---require("lualine").setup({ --- Your lua part of config goes here -require("lualine").setup({ - options = { - icons_enabled = true, - --theme = "auto", - theme = require("plugins.linecolor").theme(), - --theme = { - -- We are going to use lualine_c an lualine_x as left and - -- right section. Both are highlighte by c theme . So we - -- are just setting default looks o statusline - --normal = { c = { fg = colors.fg, bg = colors.bg } }, - --inactive = { c = { fg = colors.fg, bg = colors.bg } }, - --}, - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - --component_separators = { left = '|', right = '|'}, - --section_separators = { left = '', right = ''}, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = true, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - }, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { - "branch", - { - "diff", - colored = true, - diff_color = { - added = "DiffAdd", - modified = "DiffChange", - removed = "DiffDelete", - }, - }, - { - "diagnostics", - - sources = { "nvim_lsp" }, - sections = { "error", "warn", "info" }, - - diagnostics_color = { - error = "DiagnosticError", - warn = "DiagnosticWarn", - info = "DiagnosticInfo", - }, - colored = true, - update_in_insert = false, - always_visible = false, - }, - }, - --lualine_b = { "branch", "diff", "diagnostics" }, - lualine_c = { - --{"filetype", padding={right=0}, icon_only = true, component_separators = {left = "", right = ""}}, - --{"filename", padding={left=0}, color = {gui = "bold,italic"}}, - --{ "filetype", - -- icon_only = true, - --}, - { - "filename", - --color = {gui = "bold,italic", fg = '#ffaa88', bg = 'nil' }, - --component_separators = {left = "", right = ""}, - }, - }, - lualine_x = { "encoding", "fileformat", "filetype" }, - --lualine_x = { - -- {"encoding", color = { bg = colors.black }, component_separators = {left = "", right = ""}}, - -- {"fileformat", color = { bg = colors.black }, component_separators = {left = "", right = ""}}, - -- {"filetype", color = { bg = colors.black }, component_separators = {left = "", right = ""}}, - --}, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { "filename" }, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, - }, - -- tabline = {}, - tabline = { - --lualine_a = { "mode" }, - --lualine_a = {custom_fname}, - lualine_a = { - { - "buffers", - show_filename_only = false, - show_modified_status = true, - mode = 4, - buffers_color = { - active = { bg = colors.nobg, fg = colors.black }, -- color for active buffer - --inactive = { bg = colors.white, fg = colors.fg_gutter }, -- color for inactive buffer - --active = { bg = colors.bg, fg = colors.white }, -- color for active buffer - --inactive = { bg = colors.bg_dark, fg = colors.fg_gutter }, -- color for inactive buffer - ----color = function() - ---- return { bg = vim.bo.modified and '#aa3355' or '#33aa88' } - ----end, - }, - symbols = { - modified = " ●", -- Text to show when the buffer is modified - alternate_file = "", -- Text to show to identify the alternate file - --directory = "", -- Text to show when the buffer is a directory - }, - max_length = vim.o.columns * 5 / 6, - --{{function() - -- local bg = 'hi! lualine_buffers_color' -- not modified - -- if vim.bo.modified then bg = '#c70039' -- unsaved - -- elseif not vim.bo.readonly then bg = 'hi! lualine_buffers_color' end -- readonly - -- vim.cmd('hi! lualine_buffers_color guibg='..bg) - --end, - --color = 'hi! lualine_buffers_color', - --}}, - }, - }, - lualine_b = {}, - lualine_c = {}, - lualine_x = {}, - lualine_y = {}, - lualine_z = {}, - --lualine_z = { "tabs" }, - }, - --tabline = { - -- lualine_a = { "mode" }, - -- lualine_b = { "buffers" }, - -- lualine_c = { "branch" }, - -- --lualine_c = { "branch", "diff", "diagnostics" }, - -- lualine_x = {}, - -- lualine_y = {}, - -- lualine_z = { "tabs" }, - --}, - --winbar = { - -- lualine_a = {}, - -- lualine_b = {}, - -- lualine_c = {'filename'}, - -- lualine_x = {}, - -- lualine_y = {}, - -- lualine_z = {} - --}, - --inactive_winbar = { - -- lualine_a = {}, - -- lualine_b = {}, - -- lualine_c = {}, - -- lualine_x = {}, - -- lualine_y = {}, - -- lualine_z = {} - --}, - winbar = {}, - inactive_winbar = {}, - --extensions = {}, - extensions = { "quickfix" }, -}) ---require("lualine").statusline() ---require("lualine").tabline() ---if not lualine_status_ok then --- print("lualine.nvim is etiher broken or is not installed.") --- return ---end ---local lualine_status_ok, lualine = pcall(require, "lualine") ---if not lualine_status_ok then --- print("lualine.nvim is etiher broken or is not installed.") --- return ---end ---local utils = require("heirline.utils") - ---local M = {} - --- stylua: ignore start ---M.colours = {--{{{ ----- Color table for highlights ----- stylua: ignore ---local colors = { --- bg = '#2E3440', --- fg = '#E5E9F0', --- yellow = '#EBCB8B', --- cyan = '#88C0D0', --- darkblue = '#5E81AC', --- green = '#A3BE8C', --- orange = '#D08770', --- violet = '#B48EAD', --- magenta = '#B48EAD', --- blue = '#81A1C1', --- red = '#BF616A', ---} --- ---local conditions = { --- buffer_not_empty = function() --- return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 --- end, --- hide_in_width = function() --- return vim.fn.winwidth(0) > 80 --- end, --- check_git_workspace = function() --- local filepath = vim.fn.expand("%:p:h") --- local gitdir = vim.fn.finddir(".git", filepath .. ";") --- return gitdir and #gitdir > 0 and #gitdir < #filepath --- end, ---} - --- Config ---local config = { ---require('lualine').setup { --- options = { --- -- Disable sections and component separators --- component_separators = "", --- section_separators = "", --- theme = { --- -- We are going to use lualine_c an lualine_x as left and --- -- right section. Both are highlighte by c theme . So we --- -- are just setting default looks o statusline --- normal = { c = { fg = colors.fg, bg = colors.bg } }, --- inactive = { c = { fg = colors.fg, bg = colors.bg } }, --- }, --- disabled_filetypes = { "NvimTree" }, --- }, --- sections = { --- -- these are to remove the defaults --- lualine_a = {}, --- lualine_b = {}, --- lualine_y = {}, --- lualine_z = {}, --- -- These will be filled later --- lualine_c = {}, --- lualine_x = {}, --- }, --- inactive_sections = { --- -- these are to remove the defaults --- lualine_a = {}, --- lualine_b = {}, --- lualine_y = {}, --- lualine_z = {}, --- lualine_c = {}, --- lualine_x = {}, --- }, ---} --- ----- Inserts a component in lualine_c at left section ---local function ins_left(component) --- table.insert(lualine.sections.lualine_c, component) ---end --- ----- Inserts a component in lualine_x ot right section ---local function ins_right(component) --- table.insert(lualine.sections.lualine_x, component) ---end --- ---ins_left({ --- function() --- return "▊" --- end, --- color = { fg = colors.green }, -- Sets highlighting of component --- padding = { left = 0, right = 1 }, -- We don't need space before this ---}) --- ---ins_left({ --- -- mode component --- function() --- return "" --- end, --- color = function() --- -- auto change color according to neovims mode --- local mode_color = { --- n = colors.blue, --- i = colors.green, --- v = colors.violet, --- ["�"] = colors.blue, --- V = colors.blue, --- c = colors.magenta, --- no = colors.red, --- s = colors.orange, --- S = colors.orange, --- ic = colors.yellow, --- R = colors.violet, --- Rv = colors.violet, --- cv = colors.red, --- ce = colors.red, --- r = colors.cyan, --- rm = colors.cyan, --- ["r?"] = colors.cyan, --- ["!"] = colors.red, --- t = colors.red, --- } --- return { fg = mode_color[vim.fn.mode()] } --- end, --- padding = { right = 1 }, ---}) --- ---ins_left({ --- -- mode component --- "mode", --- color = function() --- -- auto change color according to neovims mode --- local mode_color = { --- n = colors.red, --- i = colors.green, --- v = colors.violet, --- ["�"] = colors.blue, --- V = colors.blue, --- c = colors.magenta, --- no = colors.red, --- s = colors.orange, --- S = colors.orange, --- ic = colors.yellow, --- R = colors.violet, --- Rv = colors.violet, --- cv = colors.red, --- ce = colors.red, --- r = colors.cyan, --- rm = colors.cyan, --- ["r?"] = colors.cyan, --- ["!"] = colors.red, --- t = colors.red, --- } --- return { fg = mode_color[vim.fn.mode()] } --- end, --- padding = { right = 1 }, ---}) --- ---ins_left({ --- "branch", --- icon = "", --- color = { fg = colors.violet, gui = "bold" }, ---}) --- ---ins_left({ --- "filename", --- cond = conditions.buffer_not_empty, --- color = { fg = colors.aqua, gui = "bold" }, ---}) --- ---ins_left({ --- -- filesize component --- "filesize", --- cond = conditions.buffer_not_empty, ---}) --- ----- Add components to right sections ---ins_right({ --- "o:encoding", -- option component same as &encoding in viml --- fmt = string.lower, -- I'm not sure why it's upper case either ;) --- cond = conditions.hide_in_width, --- color = { fg = colors.yellow }, ---}) --- ---ins_right({ --- "fileformat", --- fmt = string.upper, --- icons_enabled = true, -- I think icons are cool but Eviline doesn't have them. sigh --- color = { fg = colors.fg, gui = "bold" }, ---}) --- ---ins_right({ --- "filetype", ---}) --- ---ins_right({ "progress", color = { fg = colors.fg, gui = "bold" } }) --- ---ins_right({ --- "location", ---}) --- ---ins_right({ --- function() --- return "▊" --- end, --- color = { fg = colors.green }, --- padding = { left = 1 }, ---}) ---return M --- Now don't forget to initialize lualine ---require("lualine").setup(config) ---require"lualine".setup(config) ---lualine.setup(config) diff --git a/lua/plugins/luasnip-22.10.23-12:54-bak.lua b/lua/plugins/luasnip-22.10.23-12:54-bak.lua deleted file mode 100644 index 08f49ee..0000000 --- a/lua/plugins/luasnip-22.10.23-12:54-bak.lua +++ /dev/null @@ -1,161 +0,0 @@ -if vim.g.snippets ~= "luasnip" or not pcall(require, "luasnip") then - return -end ---local luasnip = require("luasnip") -local ls = require "luasnip" -- -local types = require "luasnip.util.types" -- ---local options = { -ls.config.set_config { - history = true, - updateevents = "TextChanged,TextChangedI", - -- Autosnippets: - enable_autosnippets = true, -- - ext_opts = { -- - [types.choiceNode] = { -- - active = { -- - virt_text = { { " « ", "NonTest" } }, -- - }, -- - }, -- - }, -- -} - ---local keymap = vim.keymap -local keymap = vim.api.nvim_set_keymap ---local keymap = vim.keymap.set --- <c-j> is my jump backwards key. --- this always moves to the previous item within the snippet - ---keymap({ "i", "s" }, "<C-j>", function() --- if ls.jumpable(-1) then --- ls.jump(-1) --- end ---end, { silent = true }) - --- <c-l> is selecting within a list of options. --- This is useful for choice nodes (introduced in the forthcoming episode 2) ---keymap({"i"}, "<c-l>", function() --- if ls.choice_active() then --- ls.change_choice(1) --- end ---end, { silent = true }) - - ---keymap("i", "<c-z>", require "luasnip.extras.select_choice") - --- shorcut to source my luasnips file again, which will reload my snippets ---keymap("n", "<leader><leader>s", "<cmd>source ~/.config/nvim/lua/user/plugins/luasnip.lua<CR>") - --- ls.parser.parse_snippet(<text>, <VS**** style snippet>) ---ls.snippets = { --- all = { --- -- Available in any filetype --- ls.parser.parse_snippet("expand", "-- this is what was expanded!"), ---s.snippets = { --- all = { --- -- Available in any filetype --- ls.parser.parse_snippet("expand", "-- this is what was expanded!"), --- }, --- lua = { --- -- Lua specific snippets go here. --- ls.parser.parse_snippet("lf", "local $1 = function($2)\n $0\nend") --- }, --- ---}) -local snip = ls.snippet -local node = ls.snippet_node -local text = ls.text_node -local insert = ls.insert_node -local func = ls.function_node -local choice = ls.choice_node -local dynamicn = ls.dynamic_node - -local date = function() return {os.date('%Y-%m-%d')} end - -ls.add_snippets(nil, { - all = { - --snip({ - -- trig = "date", - -- namr = "Date", - -- dscr = "Date in the form of YYYY-MM-DD", - --}, { - -- func(date, {}), - --}), - snip({ - trig = "meta", - namr = "Metadata", - dscr = "Yaml metadata format for markdown" -}, -{ - text({"---", - "title: "}), insert(1, "note_title"), text({"", - "author: "}), insert(2, "author"), text({"", - "date: "}), func(date, {}), text({"", - "categories: ["}), insert(3, ""), text({"]", - "lastmod: "}), func(date, {}), text({"", - "tags: ["}), insert(4), text({"]", - "comments: true", - "---", ""}), - insert(0) - }), - }}) ---keymap("i", "<C-j>", "<cmd>lua require'luasnip'.jump(1)<CR>", opts) ---keymap("s", "<C-j>", "<cmd>lua require'luasnip'.jump(1)<CR>", opts) ---keymap("i", "<C-k>", "<cmd>lua require'luasnip'.jump(-1)<CR>", opts) ---local opts = { noremap = true, silent = true } ---local keymap = vim.api.nvim_set_keymap ---local keymap = vim.keymap ---local term_opts = { noremap = true, silent = false } --- local map = function(mode, l, r, opts) --- opts = opts or {} --- opts.silent = true --- opts.noremap = true --- keymap.set(mode, l, r, opts) --- end - - - ---keymap("i", "<C-j>", "<Plug>luasnip-expand-or-jump * <Cmd>lua require'luasnip'.expand_or_jump()<CR>", opts) ---keymap("i", "<C-k>", "<Plug>luasnip-jump-prev * <Cmd>lua require'luasnip'.jump(-1)<CR>", opts) ---keymap("s", "<C-j>", "<Plug>luasnip-expand-or-jump * <Cmd>lua require'luasnip'.expand_or_jump()<CR>", opts) ---keymap("s", "<C-k>", "<Plug>luasnip-jump-prev * <Cmd>lua require'luasnip'.jump(-1)<CR>", opts) ---keymap("i", "<C-c>", "<Plug>luasnip-next-choice * <Cmd>lua require'luasnip'.change_choice(1)<CR>", opts) ---keymap("s", "<C-k>", "<cmd>lua require'luasnip'.jump(-1)<CR>", opts) ---map("i", "<C-j>", "<Plug>luasnip-expand-or-jump<CR>") - ---! <Plug>luasnip-expand-repeat * <Cmd>lua require'luasnip'.expand_repeat()<CR> ---! <Plug>luasnip-delete-check * <Cmd>lua require'luasnip'.unlink_current_if_deleted()<CR> ---i <Plug>luasnip-jump-prev * <Cmd>lua require'luasnip'.jump(-1)<CR> ---i <Plug>luasnip-jump-next * <Cmd>lua require'luasnip'.jump(1)<CR> ---i <Plug>luasnip-prev-choice * <Cmd>lua require'luasnip'.change_choice(-1)<CR> ---i <Plug>luasnip-next-choice * <Cmd>lua require'luasnip'.change_choice(1)<CR> ---i <Plug>luasnip-expand-snippet * <Cmd>lua require'luasnip'.expand()<CR> ---i <Plug>luasnip-expand-or-jump * <Cmd>lua require'luasnip'.expand_or_jump()<CR> - ---- - - - - - - - - - ---luasnip.config.set_config(options) ---require("luasnip.loaders.from_vscode").lazy_load() ---require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" } --- ---vim.api.nvim_create_autocmd("InsertLeave", { --- callback = function() --- if --- require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] --- and not require("luasnip").session.jump_active --- then --- require("luasnip").unlink_current() --- end --- end, ---}) - - - - diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua deleted file mode 100644 index 912729a..0000000 --- a/lua/plugins/toggleterm.lua +++ /dev/null @@ -1,90 +0,0 @@ -local status_ok, toggleterm = pcall(require, "toggleterm") -if not status_ok then - return -end - -toggleterm.setup({ - size = function(term) - if term.direction == "horizontal" then - return 12 - elseif term.direction == "vertical" then - return vim.o.columns * 0.3 - end - end, - --size = 20, - open_mapping = [[<leader>to]], - hide_numbers = true, - shade_filetypes = {}, - shade_terminals = false, - shading_factor = 1, - start_in_insert = true, - insert_mappings = true, - persist_size = true, - direction = "float", - --direction = "vertical", - --direction = "horizontal", - close_on_exit = true, - shell = vim.o.shell, - highlights = { - -- highlights which map to a highlight group name and a table of it's values - -- NOTE: this is only a subset of values, any group placed here will be set for the terminal window split - Normal = { - background = "#000000", - }, - }, - float_opts = { - width = 70, - height = 15, - winblend = 3, - border = "curved", - --winblend = 0, - highlights = { - border = "Normal", - background = "Normal", - }, - }, -}) - -function _G.set_terminal_keymaps() - local opts = { noremap = true } - --local opts = {buffer = 0} - vim.api.nvim_buf_set_keymap(0, "t", "<esc>", [[<C-\><C-n>]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "jj", [[<C-\><C-n>]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "<C-h>", [[<C-\><C-n><C-W>h]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "<C-j>", [[<C-\><C-n><C-W>j]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "<C-k>", [[<C-\><C-n><C-W>k]], opts) - vim.api.nvim_buf_set_keymap(0, "t", "<C-l>", [[<C-\><C-n><C-W>l]], opts) -end - -vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") - -local Terminal = require("toggleterm.terminal").Terminal -local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) - -function _LAZYGIT_TOGGLE() - lazygit:toggle() -end - -local node = Terminal:new({ cmd = "node", hidden = true }) - -function _NODE_TOGGLE() - node:toggle() -end - -local ncdu = Terminal:new({ cmd = "ncdu", hidden = true }) - -function _NCDU_TOGGLE() - ncdu:toggle() -end - -local htop = Terminal:new({ cmd = "htop", hidden = true }) - -function _HTOP_TOGGLE() - htop:toggle() -end - -local python = Terminal:new({ cmd = "python", hidden = true }) - -function _PYTHON_TOGGLE() - python:toggle() -end diff --git a/lua/user/colorscheme.lua b/lua/user/colorscheme.lua index dc0145d..e74d48c 100644 --- a/lua/user/colorscheme.lua +++ b/lua/user/colorscheme.lua @@ -10,14 +10,17 @@ end vim.api.nvim_command("syntax on") vim.api.nvim_command("highlight Normal guibg=none") vim.api.nvim_command("highlight SignColumn guibg=none") + vim.api.nvim_command("highlight TabLine guibg=#333842 gui=bold") +vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold") + --vim.api.nvim_command("highlight TabLine guibg=none gui=bold") --vim.api.nvim_command("highlight StatusLine guibg=#333842 gui=bold") --vim.api.nvim_command("highlight StatusLine guibg=#333842 guifg=#d6d3ea gui=bold") --vim.api.nvim_command("highlight StatusLine guibg=none gui=bold") --vim.api.nvim_command("highlight TabLineNC guibg=none gui=bold") --vim.api.nvim_command("highlight TabLineSel guibg=#bd93f9 gui=bold") -vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold") +vim.api.nvim_command("highlight Title guibg=none gui=bold") vim.api.nvim_command("highlight TabLineFill guibg=none gui=bold") vim.api.nvim_command("highlight WinBar guibg=none gui=bold") vim.api.nvim_command("highlight NormalFloat guibg=none") diff --git a/lua/user/keys.lua b/lua/user/keys.lua index bc1f874..8beb6d3 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -26,7 +26,14 @@ vim.g.mapleader = ";" --vim.g.maplocalleader = ";" -- "jj" to exit insert-mode -map("i", "kk", "<esc>") +map("i", "jk", "<esc>") + +map("n", "<leader>m", ":messages<CR>") + +-- Print last error message or use these commands | v:errmsgv | :statusmsg | :h execute() | +--nnoremap <silent><leader>x :put =trim(execute(input(':', '', 'command')))<CR> +-- Press <leader>x, then enter your command, such as 5mess and press <Enter>. The last five message lines will be added to the current buffer. +-- useful to copy error message when vim start -- save quickly --map("n", ";w", ":w<CR>", d("Save buffer")) @@ -38,8 +45,33 @@ map("i", "kk", "<esc>") --nnoremap <leader>so :source $my_vimrc<cr> --]]) +-- Toggle between folds +--utils.map("n", "<F2>", "&foldlevel ? 'zM' : 'zR'", { expr = true }) + +-- Move to the next and previous item in the quickfixlist +--utils.map("n", "]c", "<Cmd>cnext<CR>") +--utils.map("n", "[c", "<Cmd>cprevious<CR>") + +-- Use space to toggle fold +--utils.map("n", "<Space>", "za") + +-- Hitting ESC when inside a terminal to get into normal mode +--utils.map("t", "<Esc>", [[<C-\><C-N>]]) + +-- select last change +--nnoremap gV `[v`] + + +--map("n", "<leader><CR>", ":runtime! /lua/plugins/*.lua<CR> | :runtime! /lua/user/*.lua<CR> | :luafile ~/.config/nvim/init.lua<CR>", print ("Nvim reloaded")) +--map("n", "<leader><CR>", ":lua require('init').unload_lua_namespace()<CR>", print ("Nvim reloaded")) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO)) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :lua require("notify")("completion off")") +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", vim.api.nvim_echo({{'first chunk and ', 'None'}, {'second chunk to echo', 'None'}}, false, {})) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", print ("Nvim config loading...")) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echo ('hello') | <C-l><CR>") +map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>") +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>") --vim.api.nvim_set_keymap("n", "<leader><CR>", "<cmd>lua ReloadConfig()<CR>", { noremap = true, silent = false }) -map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", print ("Nvim configuration reloaded")) map("n", "<Leader>tc", ":lua require('user.utils').toggle_completion()<CR>") -- vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) @@ -169,6 +201,39 @@ map("v", "p", '"_dP') -- visual mode to select text to swap with map("v", "<C-X>", "<Esc>`.``gvP``P") +-- Keep Visual mode selection when indenting text +--utils.map("x", ">", ">gv") +--utils.map("x", "<", "<gv") + +-- Make visual pasting a word to not update the unnamed register +-- Thus, allowing us to repeatedly paste the word. {"_ : black-hole register} +--utils.map("v", "p", [["_dP]]) + +-- Whole-word search +--utils.map("n", "<leader>/", ":/\\<\\><Left><Left>", { silent = false }) + +-- EasyAlign keybindings +-- 'vipga' starts interactive EasyAlign in visual mode +-- 'gaip' starts interactive EasyAlign for text/motion object +--utils.map({ "n", "x" }, "ga", "<Plug>(EasyAlign)") +--utils.map({ "n", "x" }, "<leader>ga", "<Plug>(LiveEasyAlign)") + +-- Set a mark when moving more than 5 lines upwards/downards +-- this will populate the jumplist enabling us to jump back with Ctrl-O +--utils.map("n", "k", [[(v:count > 5 ? "m'" . v:count : "") . 'k']], { expr = true }) +--utils.map("n", "j", [[(v:count > 5 ? "m'" . v:count : "") . 'j']], { expr = true }) + +-- Zoom toggle a buffer in a new tab +--utils.map("n", "<leader>z", function() +-- require("tt.helper").zoomToggleNewTab() +--end, { desc = "Zoom toggle a buffer in a new tab" }) + +-- Hitting ESC when inside a terminal to get into normal mode +--utils.map("t", "<Esc>", [[<C-\><C-N>]]) + + + + -- Search and replace map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c') --vnoremap ; :call Get_visual_selection()<cr> diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 3200cd5..39cd2a4 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -19,9 +19,11 @@ vim.g.loaded_python3_provider = 1 -- vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file --vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals" -- +-- Colors vim.opt.termguicolors = true + -- Behaviour -vim.opt.clipboard:append({ "unnamedplus" }) -- +vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup vim.opt.backspace = { "start", "eol", "indent" } -- Make backspace work as you would expect. vim.opt.hidden = true -- Switch between buffers without having to save first. vim.opt.splitbelow = true -- make split put the new buffer below the current buffer @@ -32,7 +34,7 @@ vim.opt.autoread = true -- reload files if changed externally vim.opt.display = "lastline" -- Show as much as possible of the last line. vim.opt.inccommand = "split" -- vim.opt.ttyfast = true -- Faster redrawing. -vim.opt.lazyredraw = true -- Only redraw when necessary +--vim.opt.lazyredraw = true -- Only redraw when necessary vim.opt.keywordprg = ":help" -- :help options vim.opt.ruler = true -- vim.opt.errorbells = false -- @@ -67,8 +69,9 @@ vim.opt.smartindent = true -- smart indent vim.opt.number = true -- --vim.opt.title = true -- --vim.opt.colorcolumn = "+1" -- ---vim.opt.signcolumn = "yes:1" -- always show the sign column -vim.opt.signcolumn = "number" +vim.opt.signcolumn = "yes:1" -- always show the sign column +--vim.opt.signcolumn = "yes:" .. vim.o.numberwidth +--vim.opt.signcolumn = "number" --vim.opt.signcolumn = "no" -- vim.opt.laststatus = 3 -- " Always show statusline. vim.opt.showmode = true -- Show current mode in command-line, example: -- INSERT -- mode @@ -87,6 +90,11 @@ vim.opt.report = 0 -- Always report changed lines. -- end -- end, --}) +---- With vertical splits, the statusline would still show up at the +---- bottom of the split. A quick fix is to just set the statusline +---- to empty whitespace (it can't be an empty string because then +---- it'll get replaced by the default stline). +vim.opt.stl = " " -- Backup/undo vim.opt.backup = false -- @@ -101,16 +109,53 @@ vim.cmd([[let &t_Ce = "\e[4:0m"]]) -- vim.opt.path:append({ "**" }) -- Finding files - Search down into subfolder vim.cmd("set whichwrap+=<,>,[,],h,l") -- vim.cmd([[set iskeyword+=-]]) -- -vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work +--vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work +vim.opt.formatoptions = vim.opt.formatoptions + - "t" -- wrap with text width + + "c" -- wrap comments + + "r" -- insert comment after enter + - "o" -- insert comment after o/O + - "q" -- allow formatting of comments with gq + - "a" -- format paragraphs + + "n" -- recognized numbered lists + - "2" -- use indent of second line for paragraph + + "l" -- long lines are not broken + + "j" -- remove comment when joining lines vim.opt.wrapscan = true -- " Searches wrap around end-of-file. --vim.wo.number = true -- --vim.opt.wrap = false -- No Wrap lines --vim.opt.foldmethod = 'manual' -- --vim.opt.foldmethod = "expr" -- +vim.opt.foldmethod = "manual" +vim.opt.foldlevel = 3 +vim.opt.confirm = true +vim.opt.shortmess:append("sI") +--vim.opt.shortmess = "a" +--vim.opt.shortmess = "sI" +--vim.o.shortmess = vim.o.shortmess:gsub('s', '') +vim.opt.fillchars = { + horiz = "━", + horizup = "┻", + horizdown = "┳", + vert = "┃", + vertleft = "┨", + vertright = "┣", + verthoriz = "╋", + fold = "⠀", + eob = " ", + diff = "┃", + msgsep = "‾", + foldopen = "▾", + foldsep = "│", + foldclose = "▸", +} +vim.opt.listchars = { tab = "▸ ", trail = "·" } -- +--vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer vim.opt.modeline = true -- vim.opt.modelines = 3 -- modelines (comments that set vim options on a per-file basis) +vim.opt.modelineexpr = true --vim.opt.nofoldenable = true -- turn folding off -vim.opt.foldenable = false -- turn folding off +--vim.opt.foldenable = false -- turn folding off -- Highlights vim.opt.incsearch = true -- Highlight while searching with / or ?. @@ -121,7 +166,8 @@ vim.opt.synmaxcol = 200 -- Only highlight the first 200 columns. vim.opt.winblend = 30 --vim.opt.winblend = 5 vim.opt.wildoptions = "pum" -- -vim.opt.pumblend = 5 -- +--vim.opt.pumblend = 5 -- +vim.opt.pumblend = 12 -- --vim.opt.pumblend=15 vim.opt.pumheight = 10 -- pop up menu height @@ -148,6 +194,12 @@ vim.opt.wildignore:append({ "*.pyc" }) -- Python byte code vim.opt.wildignore:append({ "*.orig" }) -- Merge resolution files vim.opt.wildignore:append({ "*/node_modules/*" }) -- +-- Shada +vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" + +-- Sessions +vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" + -- Cursorline vim.cmd([[ " Only show cursorline in the current window and in normal mode augroup cline @@ -167,8 +219,6 @@ vim.cmd([[ " Only show in insert mode au InsertLeave * :set listchars+=trail:⌴ augroup END ]]) -vim.opt.listchars = { tab = "▸ ", trail = "·" } -- -vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer -- Line Return vim.cmd([[ " Return to the same line when we reopen a file diff --git a/lua/user/reload.lua b/lua/user/reload.lua index ecf5dd0..c02ff7b 100644 --- a/lua/user/reload.lua +++ b/lua/user/reload.lua @@ -8,18 +8,18 @@ -- dofile(vim.env.MYVIMRC) -- vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) --end -function _G.ReloadConfig() +--function _G.ReloadConfig() --dofile(vim.env.MYVIMRC) -- dofile(vim.fn.stdpath('config') .. '/init.lua') --dofile(vim.fn.stdpath('user') .. '/init.lua') - require("plenary.reload").reload_module("user", true) + -- require("plenary.reload").reload_module("user", true) --dofile("/home/sxrdusr/.config/nvim/lua/user/keys.lua") --dofile("/home/sxrdusr/.config/nvim/lua/user/mods.lua") --dofile("/home/sxrdusr/.config/nvim/lua/user/opts.lua") --dofile("/home/sxrdusr/.config/nvim/lua/user/pack.lua") --dofile("/home/sxrdusr/.config/nvim/lua/user/utils.lua") - vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) -end + --vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) +--end --P = function(v) -- print(vim.inspect(v)) -- return v diff --git a/lua/user/utils.lua b/lua/user/utils.lua index 3c6f89e..bfb5faa 100644 --- a/lua/user/utils.lua +++ b/lua/user/utils.lua @@ -31,6 +31,15 @@ function M.may_create_dir(dir) end end +M['unload_lua_namespace'] = function(prefix) + local prefix_with_dot = prefix .. '.' + for key, value in pairs(package.loaded) do + if key == prefix or key:sub(1, #prefix_with_dot) == prefix_with_dot then + package.loaded[key] = nil + end + end +end + -- toggle cmp completion vim.g.cmp_toggle_flag = false -- initialize local normal_buftype = function() diff --git a/snippets/lua.lua b/snippets/lua.lua index 00ccd31..eb46b67 100644 --- a/snippets/lua.lua +++ b/snippets/lua.lua @@ -228,7 +228,14 @@ table.insert(snippets, mySecondSnippet) local myFirstAutoSnippet = s("automatic", { t("This was auto triggered") }) table.insert(autosnippets, myFirstAutoSnippet) -local mySecondAutoSnippet = s({ trig = "normal", regTrig = true }, { t("This was auto triggered") }) +local mySecondAutoSnippet = s({ trig = "digit(%d)(%d)", regTrig = true }, { + f(function(_, snip) + return snip.captures[1] .. " + " + end), + f(function(_, snip) + return snip.captures[2] + end), +}) table.insert(autosnippets, mySecondAutoSnippet) |
