diff --git a/README.md b/README.md index 503729aa6..9ce3fc4cf 100644 --- a/README.md +++ b/README.md @@ -68,16 +68,16 @@ Just run the following interactive bootstrap command, and you're good to go 👍 - **Windows** _(Note: This script REQUIRES `pwsh` > `v7.1`)_ ```pwsh -Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/install/install.ps1')) +Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.ps1')) ``` - **\*nix** ```sh if command -v curl >/dev/null 2>&1; then - bash -c "$(curl -fsSL https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/install/install.sh)" + bash -c "$(curl -fsSL https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)" else - bash -c "$(wget -O- https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/install/install.sh)" + bash -c "$(wget -O- https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)" fi ``` diff --git a/init.lua b/init.lua index 9fb46cd6a..5473331a1 100644 --- a/init.lua +++ b/init.lua @@ -5,8 +5,8 @@ if not vim.g.vscode then vim.schedule(function() vim.notify_once( [[ -We've released version v1.0.0! -It has brought about some major changes that would require a manual cleanup. +We've released version v2.0.0! +This is a backward-incompatible release. See the release notes for instructions on how to migrate your configs. Visit https://github.com/ayamir/nvimdots/releases to see the release notes. diff --git a/lua/core/event.lua b/lua/core/event.lua index b66275b7c..e75d64e33 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -24,7 +24,7 @@ vim.api.nvim_create_autocmd("BufEnter", { and vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(layout[2]), "filetype") == "NvimTree" and layout[3] == nil then - vim.cmd("confirm quit") + vim.api.nvim_command([[confirm quit]]) end end, }) diff --git a/lua/core/init.lua b/lua/core/init.lua index b268acb01..e564c5123 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -125,7 +125,7 @@ local load_core = function() require("core.mapping") require("keymap") require("core.event") - require("core.lazy") + require("core.pack") local colorscheme = require("core.settings").colorscheme local background = require("core.settings").background diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index 8a5335314..ffc51d827 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -45,8 +45,8 @@ local def_map = { ["c|"] = map_cmd(""):with_noremap(), ["c|"] = map_cmd([[=expand("%:p:h") . "/" ]]):with_noremap(), -- Visual - ["v|J"] = map_cmd(":m '>+1gv=gv"), - ["v|K"] = map_cmd(":m '<-2gv=gv"), + ["v|J"] = map_cmd(":m '>+1gv=gv"), + ["v|K"] = map_cmd(":m '<-2gv=gv"), ["v|<"] = map_cmd(""] = map_cmd(">gv"), } diff --git a/lua/core/options.lua b/lua/core/options.lua index a8259dc21..84acaa5b8 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -121,6 +121,12 @@ local function load_options() for name, value in pairs(global_local) do vim.o[name] = value end + + -- Fix sqlite3 missing-lib issue on Windows + if global.is_windows then + -- Download the DLLs form https://www.sqlite.org/download.html + vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400100/sqlite3.dll" + end end load_options() diff --git a/lua/core/lazy.lua b/lua/core/pack.lua similarity index 71% rename from lua/core/lazy.lua rename to lua/core/pack.lua index 762e0ae42..2cdea4953 100644 --- a/lua/core/lazy.lua +++ b/lua/core/pack.lua @@ -10,48 +10,46 @@ local settings = require("core.settings") local use_ssh = settings.use_ssh local icons = { - kind = require("modules.ui.icons").get("kind"), - documents = require("modules.ui.icons").get("documents"), - ui = require("modules.ui.icons").get("ui"), - ui_sep = require("modules.ui.icons").get("ui", true), - misc = require("modules.ui.icons").get("misc"), + kind = require("modules.utils.icons").get("kind"), + documents = require("modules.utils.icons").get("documents"), + ui = require("modules.utils.icons").get("ui"), + ui_sep = require("modules.utils.icons").get("ui", true), + misc = require("modules.utils.icons").get("misc"), } local Lazy = {} -Lazy.__index = Lazy function Lazy:load_plugins() - self.repos = {} + self.modules = {} + + local append_nativertp = function() + package.path = package.path + .. string.format(";%s;%s", modules_dir .. "/configs/?.lua", modules_dir .. "/configs/?/init.lua") + end local get_plugins_list = function() local list = {} - local tmp = vim.split(fn.globpath(modules_dir, "*/plugins.lua"), "\n") - local subtmp = vim.split(fn.globpath(modules_dir, "*/user/plugins.lua"), "\n") - if type(subtmp) == "table" then - for _, v in ipairs(subtmp) do - if v ~= "" then - table.insert(tmp, v) - end - end - end - if type(tmp) == "table" then - for _, f in ipairs(tmp) do - -- fill list with `plugins.lua`'s path used for later `require` like this: - -- list[#list + 1] = "modules/completion/plugins.lua" + local plugins_list = vim.split(fn.glob(modules_dir .. "/plugins/*.lua"), "\n") + if type(plugins_list) == "table" then + for _, f in ipairs(plugins_list) do + -- fill list with `plugins/*.lua`'s path used for later `require` like this: + -- list[#list + 1] = "plugins/completion.lua" list[#list + 1] = f:sub(#modules_dir - 6, -1) end end return list end + append_nativertp() + local plugins_file = get_plugins_list() for _, m in ipairs(plugins_file) do - -- require repos which returned in `plugins.lua` like this: - -- local repos = require("modules/completion/plugins") - local repos = require(m:sub(0, #m - 4)) - if type(repos) == "table" then - for repo, conf in pairs(repos) do - self.repos[#self.repos + 1] = vim.tbl_extend("force", { repo }, conf) + -- require modules which returned in previous operation like this: + -- local modules = require("modules/plugins/completion.lua") + local modules = require(m:sub(0, #m - 4)) + if type(modules) == "table" then + for name, conf in pairs(modules) do + self.modules[#self.modules + 1] = vim.tbl_extend("force", { name }, conf) end end end @@ -101,7 +99,7 @@ function Lazy:load_lazy() icons.ui_sep.BigCircle, icons.ui_sep.BigUnfilledCircle, icons.ui_sep.Square, - icons.ui_sep.ArrowClosed, + icons.ui_sep.ChevronRight, }, }, }, @@ -118,7 +116,7 @@ function Lazy:load_lazy() rtp = { reset = true, -- reset the runtime path to $VIMRUNTIME and the config directory ---@type string[] - paths = {}, -- add any custom paths here that you want to indluce in the rtp + paths = {}, -- add any custom paths here that you want to include in the rtp }, }, } @@ -127,7 +125,7 @@ function Lazy:load_lazy() end vim.opt.rtp:prepend(lazy_path) - require("lazy").setup(self.repos, lazy_settings) + require("lazy").setup(self.modules, lazy_settings) end Lazy:load_lazy() diff --git a/lua/modules/completion/config.lua b/lua/modules/completion/config.lua deleted file mode 100644 index 7bf90e9e7..000000000 --- a/lua/modules/completion/config.lua +++ /dev/null @@ -1,416 +0,0 @@ -local config = {} - -function config.nvim_lsp() - require("modules.completion.lsp") -end - -function config.lspsaga() - local icons = { - diagnostics = require("modules.ui.icons").get("diagnostics", true), - kind = require("modules.ui.icons").get("kind", true), - type = require("modules.ui.icons").get("type", true), - ui = require("modules.ui.icons").get("ui", true), - } - - local function set_sidebar_icons() - -- Set icons for sidebar. - local diagnostic_icons = { - Error = icons.diagnostics.Error_alt, - Warn = icons.diagnostics.Warning_alt, - Info = icons.diagnostics.Information_alt, - Hint = icons.diagnostics.Hint_alt, - } - for type, icon in pairs(diagnostic_icons) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl }) - end - end - - set_sidebar_icons() - - local colors = require("modules.utils").get_palette() - - require("lspsaga").setup({ - preview = { - lines_above = 1, - lines_below = 17, - }, - scroll_preview = { - scroll_down = "", - scroll_up = "", - }, - request_timeout = 3000, - finder = { - keys = { - jump_to = "e", - edit = { "o", "" }, - vsplit = "s", - split = "i", - tabe = "t", - quit = { "q", "" }, - close_in_preview = "", - }, - }, - definition = { - edit = "o", - vsplit = "v", - split = "s", - tabe = "t", - quit = "q", - close = "", - }, - code_action = { - num_shortcut = true, - keys = { - quit = "q", - exec = "", - }, - }, - lightbulb = { - enable = false, - sign = true, - enable_in_insert = true, - sign_priority = 20, - virtual_text = false, - }, - diagnostic = { - show_code_action = true, - border_follow = true, - show_source = true, - jump_num_shortcut = true, - keys = { - exec_action = "", - quit = "q", - go_action = "g", - }, - }, - rename = { - quit = "", - mark = "x", - confirm = "", - exec = "", - in_select = true, - }, - outline = { - win_position = "right", - win_with = "_sagaoutline", - win_width = 30, - show_detail = true, - auto_preview = false, - auto_refresh = true, - auto_close = true, - keys = { - jump = "", - expand_collapse = "u", - quit = "q", - }, - }, - symbol_in_winbar = { - enable = false, - separator = " " .. icons.ui.Separator, - hide_keyword = true, - show_file = false, - color_mode = true, - }, - beacon = { - enable = true, - frequency = 12, - }, - ui = { - theme = "round", - border = "single", -- Can be single, double, rounded, solid, shadow. - winblend = 0, - expand = icons.ui.ArrowClosed, - collapse = icons.ui.ArrowOpen, - preview = icons.ui.Newspaper, - code_action = icons.ui.CodeAction, - diagnostic = icons.ui.Bug, - incoming = icons.ui.Incoming, - outgoing = icons.ui.Outgoing, - kind = { - -- Kind - Class = { icons.kind.Class, colors.yellow }, - Constant = { icons.kind.Constant, colors.peach }, - Constructor = { icons.kind.Constructor, colors.sapphire }, - Enum = { icons.kind.Enum, colors.yellow }, - EnumMember = { icons.kind.EnumMember, colors.teal }, - Event = { icons.kind.Event, colors.yellow }, - Field = { icons.kind.Field, colors.teal }, - File = { icons.kind.File, colors.rosewater }, - Function = { icons.kind.Function, colors.blue }, - Interface = { icons.kind.Interface, colors.yellow }, - Key = { icons.kind.Keyword, colors.red }, - Method = { icons.kind.Method, colors.blue }, - Module = { icons.kind.Module, colors.blue }, - Namespace = { icons.kind.Namespace, colors.blue }, - Number = { icons.kind.Number, colors.peach }, - Operator = { icons.kind.Operator, colors.sky }, - Package = { icons.kind.Package, colors.blue }, - Property = { icons.kind.Property, colors.teal }, - Struct = { icons.kind.Struct, colors.yellow }, - TypeParameter = { icons.kind.TypeParameter, colors.maroon }, - Variable = { icons.kind.Variable, colors.peach }, - -- Type - Array = { icons.type.Array, colors.peach }, - Boolean = { icons.type.Boolean, colors.peach }, - Null = { icons.type.Null, colors.yellow }, - Object = { icons.type.Object, colors.yellow }, - String = { icons.type.String, colors.green }, - -- ccls-specific icons. - TypeAlias = { icons.kind.TypeAlias, colors.green }, - Parameter = { icons.kind.Parameter, colors.blue }, - StaticMethod = { icons.kind.StaticMethod, colors.peach }, - -- Microsoft-specific icons. - Text = { icons.kind.Text, colors.green }, - Snippet = { icons.kind.Snippet, colors.mauve }, - Folder = { icons.kind.Folder, colors.blue }, - Unit = { icons.kind.Unit, colors.green }, - Value = { icons.kind.Value, colors.peach }, - }, - }, - }) -end - -function config.cmp() - local icons = { - kind = require("modules.ui.icons").get("kind", false), - type = require("modules.ui.icons").get("type", false), - cmp = require("modules.ui.icons").get("cmp", false), - } - local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) - end - - local border = function(hl) - return { - { "╭", hl }, - { "─", hl }, - { "╮", hl }, - { "│", hl }, - { "╯", hl }, - { "─", hl }, - { "╰", hl }, - { "│", hl }, - } - end - - local cmp_window = require("cmp.utils.window") - - cmp_window.info_ = cmp_window.info - cmp_window.info = function(self) - local info = self:info_() - info.scrollable = false - return info - end - - local compare = require("cmp.config.compare") - compare.lsp_scores = function(entry1, entry2) - local diff - if entry1.completion_item.score and entry2.completion_item.score then - diff = (entry2.completion_item.score * entry2.score) - (entry1.completion_item.score * entry1.score) - else - diff = entry2.score - entry1.score - end - return (diff < 0) - end - - local lspkind = require("lspkind") - local cmp = require("cmp") - - cmp.setup({ - window = { - completion = { - border = border("Normal"), - max_width = 80, - max_height = 20, - }, - documentation = { - border = border("CmpDocBorder"), - }, - }, - sorting = { - priority_weight = 2, - comparators = { - require("copilot_cmp.comparators").prioritize, - require("copilot_cmp.comparators").score, - -- require("cmp_tabnine.compare"), - compare.offset, - compare.exact, - compare.lsp_scores, - require("cmp-under-comparator").under, - compare.kind, - compare.sort_text, - compare.length, - compare.order, - }, - }, - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - local kind = lspkind.cmp_format({ - mode = "symbol_text", - maxwidth = 50, - symbol_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp), - })(entry, vim_item) - local strings = vim.split(kind.kind, "%s", { trimempty = true }) - kind.kind = " " .. strings[1] .. " " - kind.menu = " (" .. strings[2] .. ")" - return kind - end, - }, - -- You can set mappings if you want - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.close(), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif require("luasnip").expand_or_jumpable() then - vim.fn.feedkeys(t("luasnip-expand-or-jump"), "") - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif require("luasnip").jumpable(-1) then - vim.fn.feedkeys(t("luasnip-jump-prev"), "") - else - fallback() - end - end, { "i", "s" }), - }), - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - -- You should specify your *installed* sources. - sources = { - { name = "nvim_lsp" }, - { name = "nvim_lua" }, - { name = "luasnip" }, - { name = "path" }, - { name = "spell" }, - { name = "tmux" }, - { name = "orgmode" }, - { name = "buffer" }, - { name = "latex_symbols" }, - { name = "copilot" }, - -- { name = "cmp_tabnine" }, - }, - }) -end - -function config.luasnip() - local snippet_path = vim.fn.stdpath("config") .. "/my-snippets/" - if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then - vim.opt.rtp:append(snippet_path) - end - - require("luasnip").config.set_config({ - history = true, - updateevents = "TextChanged,TextChangedI", - delete_check_events = "TextChanged,InsertLeave", - }) - require("luasnip.loaders.from_lua").lazy_load() - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_snipmate").lazy_load() -end - --- function config.tabnine() --- local tabnine = require("cmp_tabnine.config") --- tabnine:setup({ max_line = 1000, max_num_results = 20, sort = true }) --- end - -function config.autopairs() - require("nvim-autopairs").setup({}) - - -- If you want insert `(` after select function or method item - local cmp_autopairs = require("nvim-autopairs.completion.cmp") - local cmp = require("cmp") - local handlers = require("nvim-autopairs.completion.handlers") - cmp.event:on( - "confirm_done", - cmp_autopairs.on_confirm_done({ - filetypes = { - -- "*" is an alias to all filetypes - ["*"] = { - ["("] = { - kind = { - cmp.lsp.CompletionItemKind.Function, - cmp.lsp.CompletionItemKind.Method, - }, - handler = handlers["*"], - }, - }, - -- Disable for tex - tex = false, - }, - }) - ) -end - -function config.mason_install() - require("mason-tool-installer").setup({ - - -- a list of all tools you want to ensure are installed upon - -- start; they should be the names Mason uses for each tool - ensure_installed = { - -- you can turn off/on auto_update per tool - -- "editorconfig-checker", - - "stylua", - - "black", - - "prettier", - - "shellcheck", - "shfmt", - - -- "vint", - }, - - -- if set to true this will check each tool for updates. If updates - -- are available the tool will be updated. - -- Default: false - auto_update = false, - - -- automatically install / update on startup. If set to false nothing - -- will happen on startup. You can use `:MasonToolsUpdate` to install - -- tools and check for updates. - -- Default: true - run_on_start = true, - }) -end - -function config.copilot() - vim.defer_fn(function() - require("copilot").setup({ - cmp = { - enabled = true, - method = "getCompletionsCycling", - }, - panel = { - -- if true, it can interfere with completions in copilot-cmp - enabled = false, - }, - suggestion = { - -- if true, it can interfere with completions in copilot-cmp - enabled = false, - }, - filetypes = { - ["dap-repl"] = false, - ["big_file_disabled_ft"] = false, - }, - }) - end, 100) -end - -return config diff --git a/lua/modules/completion/lsp.lua b/lua/modules/completion/lsp.lua deleted file mode 100644 index 9f8d695f9..000000000 --- a/lua/modules/completion/lsp.lua +++ /dev/null @@ -1,305 +0,0 @@ -local formatting = require("modules.completion.formatting") - -local nvim_lsp = require("lspconfig") -local mason = require("mason") -local mason_lsp = require("mason-lspconfig") - -require("lspconfig.ui.windows").default_options.border = "single" - -local icons = { - ui = require("modules.ui.icons").get("ui", true), - misc = require("modules.ui.icons").get("misc", true), -} - -mason.setup({ - ui = { - border = "rounded", - icons = { - package_pending = icons.ui.Modified_alt, - package_installed = icons.ui.Check, - package_uninstalled = icons.misc.Ghost, - }, - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - cancel_installation = "", - }, - }, -}) -mason_lsp.setup({ - ensure_installed = { - "bashls", - "efm", - "sumneko_lua", - "clangd", - "gopls", - "pyright", - }, -}) - -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) - -local function custom_attach(client, bufnr) - require("lsp_signature").on_attach({ - bind = true, - use_lspsaga = false, - floating_window = true, - fix_pos = true, - hint_enable = true, - hi_parameter = "Search", - handler_opts = { - border = "rounded", - }, - }) -end - -local function switch_source_header_splitcmd(bufnr, splitcmd) - bufnr = nvim_lsp.util.validate_bufnr(bufnr) - local clangd_client = nvim_lsp.util.get_active_client_by_name(bufnr, "clangd") - local params = { uri = vim.uri_from_bufnr(bufnr) } - if clangd_client then - clangd_client.request("textDocument/switchSourceHeader", params, function(err, result) - if err then - error(tostring(err)) - end - if not result then - vim.notify("Corresponding file can’t be determined", vim.log.levels.ERROR, { title = "LSP Error!" }) - return - end - vim.api.nvim_command(splitcmd .. " " .. vim.uri_to_fname(result)) - end) - else - vim.notify( - "Method textDocument/switchSourceHeader is not supported by any active server on this buffer", - vim.log.levels.ERROR, - { title = "LSP Error!" } - ) - end -end - --- Override server settings here - -for _, server in ipairs(mason_lsp.get_installed_servers()) do - if server == "gopls" then - nvim_lsp.gopls.setup({ - on_attach = custom_attach, - flags = { debounce_text_changes = 500 }, - capabilities = capabilities, - cmd = { "gopls", "-remote=auto" }, - settings = { - gopls = { - usePlaceholders = true, - analyses = { - nilness = true, - shadow = true, - unusedparams = true, - unusewrites = true, - }, - }, - }, - }) - elseif server == "sumneko_lua" then - nvim_lsp.sumneko_lua.setup({ - capabilities = capabilities, - on_attach = custom_attach, - settings = { - Lua = { - diagnostics = { globals = { "vim" } }, - workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, - }, - maxPreload = 100000, - preloadFileSize = 10000, - }, - telemetry = { enable = false }, - -- Do not override treesitter lua highlighting with sumneko lua highlighting - semantic = { enable = false }, - }, - }, - }) - elseif server == "clangd" then - nvim_lsp.clangd.setup({ - capabilities = vim.tbl_deep_extend("keep", { offsetEncoding = { "utf-16", "utf-8" } }, capabilities), - single_file_support = true, - on_attach = custom_attach, - cmd = { - "clangd", - "--background-index", - "--pch-storage=memory", - -- You MUST set this arg ↓ to your c/cpp compiler location (if not included)! - "--query-driver=/usr/bin/clang++,/usr/bin/**/clang-*,/bin/clang,/bin/clang++,/usr/bin/gcc,/usr/bin/g++", - "--clang-tidy", - "--all-scopes-completion", - "--completion-style=detailed", - "--header-insertion-decorators", - "--header-insertion=iwyu", - }, - commands = { - ClangdSwitchSourceHeader = { - function() - switch_source_header_splitcmd(0, "edit") - end, - description = "Open source/header in current buffer", - }, - ClangdSwitchSourceHeaderVSplit = { - function() - switch_source_header_splitcmd(0, "vsplit") - end, - description = "Open source/header in a new vsplit", - }, - ClangdSwitchSourceHeaderSplit = { - function() - switch_source_header_splitcmd(0, "split") - end, - description = "Open source/header in a new split", - }, - }, - }) - elseif server == "jsonls" then - nvim_lsp.jsonls.setup({ - flags = { debounce_text_changes = 500 }, - capabilities = capabilities, - on_attach = custom_attach, - settings = { - json = { - -- Schemas https://www.schemastore.org - schemas = { - { - fileMatch = { "package.json" }, - url = "https://json.schemastore.org/package.json", - }, - { - fileMatch = { "tsconfig*.json" }, - url = "https://json.schemastore.org/tsconfig.json", - }, - { - fileMatch = { - ".prettierrc", - ".prettierrc.json", - "prettier.config.json", - }, - url = "https://json.schemastore.org/prettierrc.json", - }, - { - fileMatch = { ".eslintrc", ".eslintrc.json" }, - url = "https://json.schemastore.org/eslintrc.json", - }, - { - fileMatch = { - ".babelrc", - ".babelrc.json", - "babel.config.json", - }, - url = "https://json.schemastore.org/babelrc.json", - }, - { - fileMatch = { "lerna.json" }, - url = "https://json.schemastore.org/lerna.json", - }, - { - fileMatch = { - ".stylelintrc", - ".stylelintrc.json", - "stylelint.config.json", - }, - url = "http://json.schemastore.org/stylelintrc.json", - }, - { - fileMatch = { "/.github/workflows/*" }, - url = "https://json.schemastore.org/github-workflow.json", - }, - }, - }, - }, - }) - elseif server ~= "efm" then - nvim_lsp[server].setup({ - capabilities = capabilities, - on_attach = custom_attach, - }) - end -end - --- https://github.com/vscode-langservers/vscode-html-languageserver-bin - -nvim_lsp.html.setup({ - cmd = { "html-languageserver", "--stdio" }, - filetypes = { "html" }, - init_options = { - configurationSection = { "html", "css", "javascript" }, - embeddedLanguages = { css = true, javascript = true }, - }, - settings = {}, - single_file_support = true, - flags = { debounce_text_changes = 500 }, - capabilities = capabilities, - on_attach = custom_attach, -}) - -local efmls = require("efmls-configs") - --- Init `efm-langserver` here. - -efmls.init({ - on_attach = custom_attach, - capabilities = capabilities, - init_options = { documentFormatting = true, codeAction = true }, -}) - --- Require `efmls-configs-nvim`'s config here - -local vint = require("efmls-configs.linters.vint") -local eslint = require("efmls-configs.linters.eslint") -local flake8 = require("efmls-configs.linters.flake8") - -local black = require("efmls-configs.formatters.black") -local stylua = require("efmls-configs.formatters.stylua") -local prettier = require("efmls-configs.formatters.prettier") -local shfmt = require("efmls-configs.formatters.shfmt") - --- Add your own config for formatter and linter here - --- local rustfmt = require("modules.completion.efm.formatters.rustfmt") -local clangfmt = require("modules.completion.efm.formatters.clangfmt") - --- Override default config here - -flake8 = vim.tbl_extend("force", flake8, { - prefix = "flake8: max-line-length=160, ignore F403 and F405", - lintStdin = true, - lintIgnoreExitCode = true, - lintFormats = { "%f:%l:%c: %t%n%n%n %m" }, - lintCommand = "flake8 --max-line-length 160 --extend-ignore F403,F405 --format '%(path)s:%(row)d:%(col)d: %(code)s %(code)s %(text)s' --stdin-display-name ${INPUT} -", -}) - --- Setup formatter and linter for efmls here - -efmls.setup({ - vim = { formatter = vint }, - lua = { formatter = stylua }, - c = { formatter = clangfmt }, - cpp = { formatter = clangfmt }, - python = { formatter = black }, - vue = { formatter = prettier }, - typescript = { formatter = prettier, linter = eslint }, - javascript = { formatter = prettier, linter = eslint }, - typescriptreact = { formatter = prettier, linter = eslint }, - javascriptreact = { formatter = prettier, linter = eslint }, - yaml = { formatter = prettier }, - html = { formatter = prettier }, - css = { formatter = prettier }, - scss = { formatter = prettier }, - sh = { formatter = shfmt }, - markdown = { formatter = prettier }, - -- rust = {formatter = rustfmt}, -}) - -formatting.configure_format_on_save() diff --git a/lua/modules/configs/completion/autopairs.lua b/lua/modules/configs/completion/autopairs.lua new file mode 100644 index 000000000..85255a693 --- /dev/null +++ b/lua/modules/configs/completion/autopairs.lua @@ -0,0 +1,27 @@ +return function() + require("nvim-autopairs").setup({}) + + -- If you want insert `(` after select function or method item + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + local handlers = require("nvim-autopairs.completion.handlers") + cmp.event:on( + "confirm_done", + cmp_autopairs.on_confirm_done({ + filetypes = { + -- "*" is an alias to all filetypes + ["*"] = { + ["("] = { + kind = { + cmp.lsp.CompletionItemKind.Function, + cmp.lsp.CompletionItemKind.Method, + }, + handler = handlers["*"], + }, + }, + -- Disable for tex + tex = false, + }, + }) + ) +end diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua new file mode 100644 index 000000000..b5ebe3b39 --- /dev/null +++ b/lua/modules/configs/completion/cmp.lua @@ -0,0 +1,135 @@ +return function() + local icons = { + kind = require("modules.utils.icons").get("kind"), + type = require("modules.utils.icons").get("type"), + cmp = require("modules.utils.icons").get("cmp"), + } + local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) + end + + local border = function(hl) + return { + { "╭", hl }, + { "─", hl }, + { "╮", hl }, + { "│", hl }, + { "╯", hl }, + { "─", hl }, + { "╰", hl }, + { "│", hl }, + } + end + + local cmp_window = require("cmp.utils.window") + + cmp_window.info_ = cmp_window.info + cmp_window.info = function(self) + local info = self:info_() + info.scrollable = false + return info + end + + local compare = require("cmp.config.compare") + compare.lsp_scores = function(entry1, entry2) + local diff + if entry1.completion_item.score and entry2.completion_item.score then + diff = (entry2.completion_item.score * entry2.score) - (entry1.completion_item.score * entry1.score) + else + diff = entry2.score - entry1.score + end + return (diff < 0) + end + + local lspkind = require("lspkind") + local cmp = require("cmp") + + cmp.setup({ + window = { + completion = { + border = border("Normal"), + max_width = 80, + max_height = 20, + }, + documentation = { + border = border("CmpDocBorder"), + }, + }, + sorting = { + priority_weight = 2, + comparators = { + require("copilot_cmp.comparators").prioritize, + require("copilot_cmp.comparators").score, + -- require("cmp_tabnine.compare"), + compare.offset, + compare.exact, + compare.lsp_scores, + require("cmp-under-comparator").under, + compare.kind, + compare.sort_text, + compare.length, + compare.order, + }, + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + local kind = lspkind.cmp_format({ + mode = "symbol_text", + maxwidth = 50, + symbol_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp), + })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = " " .. strings[1] .. " " + kind.menu = " (" .. strings[2] .. ")" + return kind + end, + }, + -- You can set mappings if you want + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.close(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(t("luasnip-expand-or-jump"), "") + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(t("luasnip-jump-prev"), "") + else + fallback() + end + end, { "i", "s" }), + }), + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + -- You should specify your *installed* sources. + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "luasnip" }, + { name = "path" }, + { name = "spell" }, + { name = "tmux" }, + { name = "orgmode" }, + { name = "buffer" }, + { name = "latex_symbols" }, + { name = "copilot" }, + -- { name = "cmp_tabnine" }, + }, + }) +end diff --git a/lua/modules/configs/completion/copilot-cmp.lua b/lua/modules/configs/completion/copilot-cmp.lua new file mode 100644 index 000000000..d8689880c --- /dev/null +++ b/lua/modules/configs/completion/copilot-cmp.lua @@ -0,0 +1,3 @@ +return function() + require("copilot_cmp").setup({}) +end diff --git a/lua/modules/configs/completion/copilot.lua b/lua/modules/configs/completion/copilot.lua new file mode 100644 index 000000000..f1fd63b1f --- /dev/null +++ b/lua/modules/configs/completion/copilot.lua @@ -0,0 +1,22 @@ +return function() + vim.defer_fn(function() + require("copilot").setup({ + cmp = { + enabled = true, + method = "getCompletionsCycling", + }, + panel = { + -- if true, it can interfere with completions in copilot-cmp + enabled = false, + }, + suggestion = { + -- if true, it can interfere with completions in copilot-cmp + enabled = false, + }, + filetypes = { + ["dap-repl"] = false, + ["big_file_disabled_ft"] = false, + }, + }) + end, 100) +end diff --git a/lua/modules/completion/efm/formatters/clangfmt.lua b/lua/modules/configs/completion/efm/formatters/clangfmt.lua similarity index 100% rename from lua/modules/completion/efm/formatters/clangfmt.lua rename to lua/modules/configs/completion/efm/formatters/clangfmt.lua diff --git a/lua/modules/completion/efm/formatters/rustfmt.lua b/lua/modules/configs/completion/efm/formatters/rustfmt.lua similarity index 100% rename from lua/modules/completion/efm/formatters/rustfmt.lua rename to lua/modules/configs/completion/efm/formatters/rustfmt.lua diff --git a/lua/modules/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua similarity index 97% rename from lua/modules/completion/formatting.lua rename to lua/modules/configs/completion/formatting.lua index 8a86cbdbf..ca73f4eec 100644 --- a/lua/modules/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -59,7 +59,7 @@ function M.enable_format_on_save(is_configured) group = "format_on_save", pattern = opts.pattern, callback = function() - require("modules.completion.formatting").format({ timeout_ms = opts.timeout, filter = M.format_filter }) + require("completion.formatting").format({ timeout_ms = opts.timeout, filter = M.format_filter }) end, }) if not is_configured then diff --git a/lua/modules/configs/completion/lsp.lua b/lua/modules/configs/completion/lsp.lua new file mode 100644 index 000000000..b7a3de119 --- /dev/null +++ b/lua/modules/configs/completion/lsp.lua @@ -0,0 +1,176 @@ +return function() + local formatting = require("completion.formatting") + + local nvim_lsp = require("lspconfig") + local mason = require("mason") + local mason_lspconfig = require("mason-lspconfig") + + require("lspconfig.ui.windows").default_options.border = "single" + + local icons = { + ui = require("modules.utils.icons").get("ui", true), + misc = require("modules.utils.icons").get("misc", true), + } + + mason.setup({ + ui = { + border = "rounded", + icons = { + package_pending = icons.ui.Modified_alt, + package_installed = icons.ui.Check, + package_uninstalled = icons.misc.Ghost, + }, + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + cancel_installation = "", + }, + }, + }) + mason_lspconfig.setup({ + ensure_installed = { + "bashls", + "clangd", + "efm", + "gopls", + "pyright", + "sumneko_lua", + }, + }) + + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) + + local opts = { + on_attach = function() + require("lsp_signature").on_attach({ + bind = true, + use_lspsaga = false, + floating_window = true, + fix_pos = true, + hint_enable = true, + hi_parameter = "Search", + handler_opts = { + border = "rounded", + }, + }) + end, + capabilities = capabilities, + } + + mason_lspconfig.setup_handlers({ + function(server) + require("lspconfig")[server].setup({ + capabilities = opts.capabilities, + on_attach = opts.on_attach, + }) + end, + + bashls = function() + local _opts = require("completion.servers.bashls") + local final_opts = vim.tbl_deep_extend("keep", _opts, opts) + nvim_lsp.bashls.setup(final_opts) + end, + + clangd = function() + local _capabilities = vim.tbl_deep_extend("keep", { offsetEncoding = { "utf-16", "utf-8" } }, capabilities) + local _opts = require("completion.servers.clangd") + local final_opts = + vim.tbl_deep_extend("keep", _opts, { on_attach = opts.on_attach, capabilities = _capabilities }) + nvim_lsp.clangd.setup(final_opts) + end, + + efm = function() + -- Do not setup efm + end, + + gopls = function() + local _opts = require("completion.servers.gopls") + local final_opts = vim.tbl_deep_extend("keep", _opts, opts) + nvim_lsp.gopls.setup(final_opts) + end, + + jsonls = function() + local _opts = require("completion.servers.jsonls") + local final_opts = vim.tbl_deep_extend("keep", _opts, opts) + nvim_lsp.jsonls.setup(final_opts) + end, + + sumneko_lua = function() + local _opts = require("completion.servers.sumneko_lua") + local final_opts = vim.tbl_deep_extend("keep", _opts, opts) + nvim_lsp.sumneko_lua.setup(final_opts) + end, + }) + + if vim.fn.executable("html-languageserver") then + local _opts = require("completion.servers.html") + local final_opts = vim.tbl_deep_extend("keep", _opts, opts) + nvim_lsp.html.setup(final_opts) + end + + local efmls = require("efmls-configs") + + -- Init `efm-langserver` here. + + efmls.init({ + on_attach = opts.on_attach, + capabilities = capabilities, + init_options = { documentFormatting = true, codeAction = true }, + }) + + -- Require `efmls-configs-nvim`'s config here + + local vint = require("efmls-configs.linters.vint") + local eslint = require("efmls-configs.linters.eslint") + local flake8 = require("efmls-configs.linters.flake8") + + local black = require("efmls-configs.formatters.black") + local stylua = require("efmls-configs.formatters.stylua") + local prettier = require("efmls-configs.formatters.prettier") + local shfmt = require("efmls-configs.formatters.shfmt") + + -- Add your own config for formatter and linter here + + -- local rustfmt = require("completion.efm.formatters.rustfmt") + local clangfmt = require("completion.efm.formatters.clangfmt") + + -- Override default config here + + flake8 = vim.tbl_extend("force", flake8, { + prefix = "flake8: max-line-length=160, ignore F403 and F405", + lintStdin = true, + lintIgnoreExitCode = true, + lintFormats = { "%f:%l:%c: %t%n%n%n %m" }, + lintCommand = "flake8 --max-line-length 160 --extend-ignore F403,F405 --format '%(path)s:%(row)d:%(col)d: %(code)s %(code)s %(text)s' --stdin-display-name ${INPUT} -", + }) + + -- Setup formatter and linter for efmls here + + efmls.setup({ + vim = { formatter = vint }, + lua = { formatter = stylua }, + c = { formatter = clangfmt }, + cpp = { formatter = clangfmt }, + python = { formatter = black }, + vue = { formatter = prettier }, + typescript = { formatter = prettier, linter = eslint }, + javascript = { formatter = prettier, linter = eslint }, + typescriptreact = { formatter = prettier, linter = eslint }, + javascriptreact = { formatter = prettier, linter = eslint }, + yaml = { formatter = prettier }, + html = { formatter = prettier }, + css = { formatter = prettier }, + scss = { formatter = prettier }, + sh = { formatter = shfmt }, + markdown = { formatter = prettier }, + -- rust = {formatter = rustfmt}, + }) + + formatting.configure_format_on_save() +end diff --git a/lua/modules/configs/completion/lspsaga.lua b/lua/modules/configs/completion/lspsaga.lua new file mode 100644 index 000000000..dc1c81b77 --- /dev/null +++ b/lua/modules/configs/completion/lspsaga.lua @@ -0,0 +1,166 @@ +return function() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics", true), + kind = require("modules.utils.icons").get("kind", true), + type = require("modules.utils.icons").get("type", true), + ui = require("modules.utils.icons").get("ui", true), + } + + local function set_sidebar_icons() + -- Set icons for sidebar. + local diagnostic_icons = { + Error = icons.diagnostics.Error_alt, + Warn = icons.diagnostics.Warning_alt, + Info = icons.diagnostics.Information_alt, + Hint = icons.diagnostics.Hint_alt, + } + for type, icon in pairs(diagnostic_icons) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl }) + end + end + + set_sidebar_icons() + + local colors = require("modules.utils").get_palette() + + require("lspsaga").setup({ + preview = { + lines_above = 1, + lines_below = 17, + }, + scroll_preview = { + scroll_down = "", + scroll_up = "", + }, + request_timeout = 3000, + finder = { + keys = { + jump_to = "e", + edit = { "o", "" }, + vsplit = "s", + split = "i", + tabe = "t", + quit = { "q", "" }, + close_in_preview = "", + }, + }, + definition = { + edit = "o", + vsplit = "v", + split = "s", + tabe = "t", + quit = "q", + close = "", + }, + code_action = { + num_shortcut = true, + keys = { + quit = "q", + exec = "", + }, + }, + lightbulb = { + enable = false, + sign = true, + enable_in_insert = true, + sign_priority = 20, + virtual_text = false, + }, + diagnostic = { + show_code_action = true, + border_follow = true, + show_source = true, + jump_num_shortcut = true, + keys = { + exec_action = "", + quit = "q", + go_action = "g", + }, + }, + rename = { + quit = "", + mark = "x", + confirm = "", + exec = "", + in_select = true, + }, + outline = { + win_position = "right", + win_with = "_sagaoutline", + win_width = 30, + show_detail = true, + auto_preview = false, + auto_refresh = true, + auto_close = true, + keys = { + jump = "", + expand_collapse = "u", + quit = "q", + }, + }, + symbol_in_winbar = { + enable = false, + separator = " " .. icons.ui.Separator, + hide_keyword = true, + show_file = false, + color_mode = true, + }, + beacon = { + enable = true, + frequency = 12, + }, + ui = { + theme = "round", + border = "single", -- Can be single, double, rounded, solid, shadow. + winblend = 0, + expand = icons.ui.ArrowClosed, + collapse = icons.ui.ArrowOpen, + preview = icons.ui.Newspaper, + code_action = icons.ui.CodeAction, + diagnostic = icons.ui.Bug, + incoming = icons.ui.Incoming, + outgoing = icons.ui.Outgoing, + kind = { + -- Kind + Class = { icons.kind.Class, colors.yellow }, + Constant = { icons.kind.Constant, colors.peach }, + Constructor = { icons.kind.Constructor, colors.sapphire }, + Enum = { icons.kind.Enum, colors.yellow }, + EnumMember = { icons.kind.EnumMember, colors.teal }, + Event = { icons.kind.Event, colors.yellow }, + Field = { icons.kind.Field, colors.teal }, + File = { icons.kind.File, colors.rosewater }, + Function = { icons.kind.Function, colors.blue }, + Interface = { icons.kind.Interface, colors.yellow }, + Key = { icons.kind.Keyword, colors.red }, + Method = { icons.kind.Method, colors.blue }, + Module = { icons.kind.Module, colors.blue }, + Namespace = { icons.kind.Namespace, colors.blue }, + Number = { icons.kind.Number, colors.peach }, + Operator = { icons.kind.Operator, colors.sky }, + Package = { icons.kind.Package, colors.blue }, + Property = { icons.kind.Property, colors.teal }, + Struct = { icons.kind.Struct, colors.yellow }, + TypeParameter = { icons.kind.TypeParameter, colors.maroon }, + Variable = { icons.kind.Variable, colors.peach }, + -- Type + Array = { icons.type.Array, colors.peach }, + Boolean = { icons.type.Boolean, colors.peach }, + Null = { icons.type.Null, colors.yellow }, + Object = { icons.type.Object, colors.yellow }, + String = { icons.type.String, colors.green }, + -- ccls-specific icons. + TypeAlias = { icons.kind.TypeAlias, colors.green }, + Parameter = { icons.kind.Parameter, colors.blue }, + StaticMethod = { icons.kind.StaticMethod, colors.peach }, + -- Microsoft-specific icons. + Text = { icons.kind.Text, colors.green }, + Snippet = { icons.kind.Snippet, colors.mauve }, + Folder = { icons.kind.Folder, colors.blue }, + Unit = { icons.kind.Unit, colors.green }, + Value = { icons.kind.Value, colors.peach }, + }, + }, + }) +end diff --git a/lua/modules/configs/completion/luasnip.lua b/lua/modules/configs/completion/luasnip.lua new file mode 100644 index 000000000..a7185ebfe --- /dev/null +++ b/lua/modules/configs/completion/luasnip.lua @@ -0,0 +1,15 @@ +return function() + local snippet_path = vim.fn.stdpath("config") .. "/snips/" + if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then + vim.opt.rtp:append(snippet_path) + end + + require("luasnip").config.set_config({ + history = true, + updateevents = "TextChanged,TextChangedI", + delete_check_events = "TextChanged,InsertLeave", + }) + require("luasnip.loaders.from_lua").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_snipmate").lazy_load() +end diff --git a/lua/modules/configs/completion/mason-tool-installer.lua b/lua/modules/configs/completion/mason-tool-installer.lua new file mode 100644 index 000000000..37cbe657d --- /dev/null +++ b/lua/modules/configs/completion/mason-tool-installer.lua @@ -0,0 +1,32 @@ +return function() + require("mason-tool-installer").setup({ + -- a list of all tools you want to ensure are installed upon + -- start; they should be the names Mason uses for each tool + ensure_installed = { + -- you can turn off/on auto_update per tool + -- "editorconfig-checker", + + "stylua", + + "black", + + "prettier", + + "shellcheck", + "shfmt", + + -- "vint", + }, + + -- if set to true this will check each tool for updates. If updates + -- are available the tool will be updated. + -- Default: false + auto_update = false, + + -- automatically install / update on startup. If set to false nothing + -- will happen on startup. You can use `:MasonToolsUpdate` to install + -- tools and check for updates. + -- Default: true + run_on_start = true, + }) +end diff --git a/lua/modules/configs/completion/servers/bashls.lua b/lua/modules/configs/completion/servers/bashls.lua new file mode 100644 index 000000000..d5e470f93 --- /dev/null +++ b/lua/modules/configs/completion/servers/bashls.lua @@ -0,0 +1,5 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/bashls.lua +return { + cmd = { "bash-language-server", "start" }, + filetypes = { "bash", "sh" }, +} diff --git a/lua/modules/configs/completion/servers/clangd.lua b/lua/modules/configs/completion/servers/clangd.lua new file mode 100644 index 000000000..a0be22b1c --- /dev/null +++ b/lua/modules/configs/completion/servers/clangd.lua @@ -0,0 +1,60 @@ +local function switch_source_header_splitcmd(bufnr, splitcmd) + bufnr = require("lspconfig").util.validate_bufnr(bufnr) + local clangd_client = require("lspconfig").util.get_active_client_by_name(bufnr, "clangd") + local params = { uri = vim.uri_from_bufnr(bufnr) } + if clangd_client then + clangd_client.request("textDocument/switchSourceHeader", params, function(err, result) + if err then + error(tostring(err)) + end + if not result then + vim.notify("Corresponding file can’t be determined", vim.log.levels.ERROR, { title = "LSP Error!" }) + return + end + vim.api.nvim_command(splitcmd .. " " .. vim.uri_to_fname(result)) + end) + else + vim.notify( + "Method textDocument/switchSourceHeader is not supported by any active server on this buffer", + vim.log.levels.ERROR, + { title = "LSP Error!" } + ) + end +end + +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/clangd.lua +return { + single_file_support = true, + cmd = { + "clangd", + "--background-index", + "--pch-storage=memory", + -- You MUST set this arg ↓ to your c/cpp compiler location (if not included)! + "--query-driver=/usr/bin/clang++,/usr/bin/**/clang-*,/bin/clang,/bin/clang++,/usr/bin/gcc,/usr/bin/g++", + "--clang-tidy", + "--all-scopes-completion", + "--completion-style=detailed", + "--header-insertion-decorators", + "--header-insertion=iwyu", + }, + commands = { + ClangdSwitchSourceHeader = { + function() + switch_source_header_splitcmd(0, "edit") + end, + description = "Open source/header in current buffer", + }, + ClangdSwitchSourceHeaderVSplit = { + function() + switch_source_header_splitcmd(0, "vsplit") + end, + description = "Open source/header in a new vsplit", + }, + ClangdSwitchSourceHeaderSplit = { + function() + switch_source_header_splitcmd(0, "split") + end, + description = "Open source/header in a new split", + }, + }, +} diff --git a/lua/modules/configs/completion/servers/gopls.lua b/lua/modules/configs/completion/servers/gopls.lua new file mode 100644 index 000000000..c5de67868 --- /dev/null +++ b/lua/modules/configs/completion/servers/gopls.lua @@ -0,0 +1,16 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/gopls.lua +return { + flags = { debounce_text_changes = 500 }, + cmd = { "gopls", "-remote=auto" }, + settings = { + gopls = { + usePlaceholders = true, + analyses = { + nilness = true, + shadow = true, + unusedparams = true, + unusewrites = true, + }, + }, + }, +} diff --git a/lua/modules/configs/completion/servers/html.lua b/lua/modules/configs/completion/servers/html.lua new file mode 100644 index 000000000..fa8f9bd83 --- /dev/null +++ b/lua/modules/configs/completion/servers/html.lua @@ -0,0 +1,12 @@ +-- https://github.com/vscode-langservers/vscode-html-languageserver-bin +return { + cmd = { "html-languageserver", "--stdio" }, + filetypes = { "html" }, + init_options = { + configurationSection = { "html", "css", "javascript" }, + embeddedLanguages = { css = true, javascript = true }, + }, + settings = {}, + single_file_support = true, + flags = { debounce_text_changes = 500 }, +} diff --git a/lua/modules/configs/completion/servers/jsonls.lua b/lua/modules/configs/completion/servers/jsonls.lua new file mode 100644 index 000000000..d83198d3f --- /dev/null +++ b/lua/modules/configs/completion/servers/jsonls.lua @@ -0,0 +1,55 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/jsonls.lua +return { + flags = { debounce_text_changes = 500 }, + settings = { + json = { + -- Schemas https://www.schemastore.org + schemas = { + { + fileMatch = { "package.json" }, + url = "https://json.schemastore.org/package.json", + }, + { + fileMatch = { "tsconfig*.json" }, + url = "https://json.schemastore.org/tsconfig.json", + }, + { + fileMatch = { + ".prettierrc", + ".prettierrc.json", + "prettier.config.json", + }, + url = "https://json.schemastore.org/prettierrc.json", + }, + { + fileMatch = { ".eslintrc", ".eslintrc.json" }, + url = "https://json.schemastore.org/eslintrc.json", + }, + { + fileMatch = { + ".babelrc", + ".babelrc.json", + "babel.config.json", + }, + url = "https://json.schemastore.org/babelrc.json", + }, + { + fileMatch = { "lerna.json" }, + url = "https://json.schemastore.org/lerna.json", + }, + { + fileMatch = { + ".stylelintrc", + ".stylelintrc.json", + "stylelint.config.json", + }, + url = "http://json.schemastore.org/stylelintrc.json", + }, + { + fileMatch = { "/.github/workflows/*" }, + url = "https://json.schemastore.org/github-workflow.json", + }, + }, + }, + }, +} diff --git a/lua/modules/configs/completion/servers/sumneko_lua.lua b/lua/modules/configs/completion/servers/sumneko_lua.lua new file mode 100644 index 000000000..2becee53c --- /dev/null +++ b/lua/modules/configs/completion/servers/sumneko_lua.lua @@ -0,0 +1,22 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/sumneko_lua.lua +return { + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + disable = { "different-requires" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, + }, + telemetry = { enable = false }, + -- Do not override treesitter lua highlighting with sumneko lua highlighting + semantic = { enable = false }, + }, + }, +} diff --git a/lua/modules/configs/completion/tabnine.lua b/lua/modules/configs/completion/tabnine.lua new file mode 100644 index 000000000..05096160a --- /dev/null +++ b/lua/modules/configs/completion/tabnine.lua @@ -0,0 +1,3 @@ +return function() + require("cmp_tabnine.config"):setup({ max_line = 1000, max_num_results = 20, sort = true }) +end diff --git a/lua/modules/configs/editor/accelerated-jk.lua b/lua/modules/configs/editor/accelerated-jk.lua new file mode 100644 index 000000000..92e28a4e5 --- /dev/null +++ b/lua/modules/configs/editor/accelerated-jk.lua @@ -0,0 +1,11 @@ +return function() + require("accelerated-jk").setup({ + mode = "time_driven", + enable_deceleration = false, + acceleration_motions = {}, + acceleration_limit = 150, + acceleration_table = { 7, 12, 17, 21, 24, 26, 28, 30 }, + -- when 'enable_deceleration = true', 'deceleration_table = { {200, 3}, {300, 7}, {450, 11}, {600, 15}, {750, 21}, {900, 9999} }' + deceleration_table = { { 150, 9999 } }, + }) +end diff --git a/lua/modules/configs/editor/auto-session.lua b/lua/modules/configs/editor/auto-session.lua new file mode 100644 index 000000000..c056c5173 --- /dev/null +++ b/lua/modules/configs/editor/auto-session.lua @@ -0,0 +1,11 @@ +return function() + require("auto-session").setup({ + log_level = "info", + auto_session_enable_last_session = true, + auto_session_root_dir = vim.fn.stdpath("data") .. "/sessions/", + auto_session_enabled = true, + auto_save_enabled = true, + auto_restore_enabled = true, + auto_session_suppress_dirs = nil, + }) +end diff --git a/lua/modules/configs/editor/autotag.lua b/lua/modules/configs/editor/autotag.lua new file mode 100644 index 000000000..1f78a09a1 --- /dev/null +++ b/lua/modules/configs/editor/autotag.lua @@ -0,0 +1,12 @@ +return function() + require("nvim-ts-autotag").setup({ + filetypes = { + "html", + "xml", + "javascript", + "typescriptreact", + "javascriptreact", + "vue", + }, + }) +end diff --git a/lua/modules/configs/editor/better-escape.lua b/lua/modules/configs/editor/better-escape.lua new file mode 100644 index 000000000..4a0ee9474 --- /dev/null +++ b/lua/modules/configs/editor/better-escape.lua @@ -0,0 +1,12 @@ +return function() + require("better_escape").setup({ + mapping = { "jk", "jj" }, -- a table with mappings to use + timeout = 500, -- the time in which the keys must be hit in ms. Use option timeoutlen by default + clear_empty_lines = false, -- clear line after escaping if there is only whitespace + keys = "", -- keys used for escaping, if it is a function will use the result everytime + -- example(recommended) + -- keys = function() + -- return vim.api.nvim_win_get_cursor(0)[2] > 1 and 'l' or '' + -- end, + }) +end diff --git a/lua/modules/configs/editor/bigfile.lua b/lua/modules/configs/editor/bigfile.lua new file mode 100644 index 000000000..4a7473125 --- /dev/null +++ b/lua/modules/configs/editor/bigfile.lua @@ -0,0 +1,32 @@ +return function() + local ftdetect = { + name = "ftdetect", + opts = { defer = true }, + disable = function() + vim.api.nvim_set_option_value("filetype", "big_file_disabled_ft", { scope = "local" }) + end, + } + + local cmp = { + name = "nvim-cmp", + opts = { defer = true }, + disable = function() + require("cmp").setup.buffer({ enabled = false }) + end, + } + + require("bigfile").config({ + filesize = 1, -- size of the file in MiB + pattern = { "*" }, -- autocmd pattern + features = { -- features to disable + "indent_blankline", + "lsp", + "illuminate", + "treesitter", + "syntax", + "vimopts", + ftdetect, + cmp, + }, + }) +end diff --git a/lua/modules/configs/editor/cleverf.lua b/lua/modules/configs/editor/cleverf.lua new file mode 100644 index 000000000..731a7adec --- /dev/null +++ b/lua/modules/configs/editor/cleverf.lua @@ -0,0 +1,11 @@ +return function() + vim.api.nvim_set_hl( + 0, + "CleverChar", + { underline = true, bold = true, fg = "Orange", bg = "NONE", ctermfg = "Red", ctermbg = "NONE" } + ) + vim.g.clever_f_mark_char_color = "CleverChar" + vim.g.clever_f_mark_direct_color = "CleverChar" + vim.g.clever_f_mark_direct = true + vim.g.clever_f_timeout_ms = 1500 +end diff --git a/lua/modules/configs/editor/colorizer.lua b/lua/modules/configs/editor/colorizer.lua new file mode 100644 index 000000000..d0e7569ab --- /dev/null +++ b/lua/modules/configs/editor/colorizer.lua @@ -0,0 +1,3 @@ +return function() + require("colorizer").setup({}) +end diff --git a/lua/modules/configs/editor/hop.lua b/lua/modules/configs/editor/hop.lua new file mode 100644 index 000000000..be2a5ebf7 --- /dev/null +++ b/lua/modules/configs/editor/hop.lua @@ -0,0 +1,3 @@ +return function() + require("hop").setup({ keys = "etovxqpdygfblzhckisuran" }) +end diff --git a/lua/modules/configs/editor/nvim-comment.lua b/lua/modules/configs/editor/nvim-comment.lua new file mode 100644 index 000000000..2b3d05546 --- /dev/null +++ b/lua/modules/configs/editor/nvim-comment.lua @@ -0,0 +1,7 @@ +return function() + require("nvim_comment").setup({ + hook = function() + require("ts_context_commentstring.internal").update_commentstring() + end, + }) +end diff --git a/lua/modules/configs/editor/tabout.lua b/lua/modules/configs/editor/tabout.lua new file mode 100644 index 000000000..dd6915f27 --- /dev/null +++ b/lua/modules/configs/editor/tabout.lua @@ -0,0 +1,20 @@ +return function() + require("tabout").setup({ + tabkey = "", -- key to trigger tabout, set to an empty string to disable + backwards_tabkey = "", -- key to trigger backwards tabout, set to an empty string to disable + act_as_tab = true, -- shift content if tab out is not possible + act_as_shift_tab = false, -- reverse shift content if tab out is not possible (if your keyboard/terminal supports ) + enable_backwards = true, + completion = true, -- if the tabkey is used in a completion pum + tabouts = { + { open = "'", close = "'" }, + { open = '"', close = '"' }, + { open = "`", close = "`" }, + { open = "(", close = ")" }, + { open = "[", close = "]" }, + { open = "{", close = "}" }, + }, + ignore_beginning = true, -- if the cursor is at the beginning of a filled element it will rather tab out than shift the content + exclude = {}, -- tabout will ignore these filetypes + }) +end diff --git a/lua/modules/configs/editor/treesitter.lua b/lua/modules/configs/editor/treesitter.lua new file mode 100644 index 000000000..95eb7c55d --- /dev/null +++ b/lua/modules/configs/editor/treesitter.lua @@ -0,0 +1,87 @@ +return function() + local use_ssh = require("core.settings").use_ssh + + vim.api.nvim_set_option_value("foldmethod", "expr", {}) + vim.api.nvim_set_option_value("foldexpr", "nvim_treesitter#foldexpr()", {}) + + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "bash", + "c", + "cpp", + "lua", + "go", + "gomod", + "json", + "yaml", + "latex", + "make", + "markdown", + "markdown_inline", + "python", + "rust", + "html", + "javascript", + "typescript", + "vue", + "css", + }, + highlight = { + enable = true, + disable = function(ft, bufnr) + if vim.tbl_contains({ "vim" }, ft) then + return true + end + + local ok, is_large_file = pcall(vim.api.nvim_buf_get_var, bufnr, "bigfile_disable_treesitter") + return ok and is_large_file + end, + additional_vim_regex_highlighting = { "c", "cpp" }, + }, + textobjects = { + select = { + enable = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]["] = "@function.outer", + ["]m"] = "@class.outer", + }, + goto_next_end = { + ["]]"] = "@function.outer", + ["]M"] = "@class.outer", + }, + goto_previous_start = { + ["[["] = "@function.outer", + ["[m"] = "@class.outer", + }, + goto_previous_end = { + ["[]"] = "@function.outer", + ["[M"] = "@class.outer", + }, + }, + }, + rainbow = { + enable = true, + extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean + max_file_lines = 2000, -- Do not enable for files with more than 2000 lines, int + }, + context_commentstring = { enable = true, enable_autocmd = false }, + matchup = { enable = true }, + }) + require("nvim-treesitter.install").prefer_git = true + if use_ssh then + local parsers = require("nvim-treesitter.parsers").get_parser_configs() + for _, p in pairs(parsers) do + p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:") + end + end +end diff --git a/lua/modules/configs/editor/vim-illuminate.lua b/lua/modules/configs/editor/vim-illuminate.lua new file mode 100644 index 000000000..c48dc4559 --- /dev/null +++ b/lua/modules/configs/editor/vim-illuminate.lua @@ -0,0 +1,22 @@ +return function() + require("illuminate").configure({ + providers = { + "lsp", + "treesitter", + "regex", + }, + delay = 100, + filetypes_denylist = { + "alpha", + "dashboard", + "DoomInfo", + "fugitive", + "help", + "norg", + "NvimTree", + "Outline", + "toggleterm", + }, + under_cursor = false, + }) +end diff --git a/lua/modules/lang/config.lua b/lua/modules/configs/lang/rust-tools.lua similarity index 91% rename from lua/modules/lang/config.lua rename to lua/modules/configs/lang/rust-tools.lua index ce7f61847..f3e5b98c5 100644 --- a/lua/modules/lang/config.lua +++ b/lua/modules/configs/lang/rust-tools.lua @@ -1,6 +1,4 @@ -local config = {} - -function config.rust_tools() +return function() local opts = { tools = { -- rust-tools options @@ -184,18 +182,3 @@ function config.rust_tools() require("rust-tools").setup(opts) end - -function config.lang_go() - vim.g.go_doc_keywordprg_enabled = 0 - vim.g.go_def_mapping_enabled = 0 - vim.g.go_code_completion_enabled = 0 -end - --- function config.lang_org() --- require("orgmode").setup({ --- org_agenda_files = {"~/Sync/org/*"}, --- org_default_notes_file = "~/Sync/org/refile.org" --- }) --- end - -return config diff --git a/lua/modules/configs/lang/vim-go.lua b/lua/modules/configs/lang/vim-go.lua new file mode 100644 index 000000000..d5452ea94 --- /dev/null +++ b/lua/modules/configs/lang/vim-go.lua @@ -0,0 +1,5 @@ +return function() + vim.g.go_doc_keywordprg_enabled = 0 + vim.g.go_def_mapping_enabled = 0 + vim.g.go_code_completion_enabled = 0 +end diff --git a/lua/modules/configs/tool/dap/dap-debugpy.lua b/lua/modules/configs/tool/dap/dap-debugpy.lua new file mode 100644 index 000000000..cbd7980b6 --- /dev/null +++ b/lua/modules/configs/tool/dap/dap-debugpy.lua @@ -0,0 +1,46 @@ +local dap = require("dap") + +local function isempty(s) + return s == nil or s == "" +end + +dap.adapters.python = { + type = "executable", + command = "/usr/bin/python", + args = { "-m", "debugpy.adapter" }, +} +dap.configurations.python = { + { + -- The first three options are required by nvim-dap + type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python` + request = "launch", + name = "Launch file", + -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options + + program = "${file}", -- This configuration will launch the current file if used. + pythonPath = function() + if not isempty(vim.env.CONDA_PREFIX) then + return vim.env.CONDA_PREFIX .. "/bin/python" + else + return "/usr/bin/python3" + end + end, + }, +} + +-- NOTE: for people using venv +-- pythonPath = function() +-- -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. +-- -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. +-- -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. +-- local cwd, venv = vim.fn.getcwd(), os.getenv("VIRTUAL_ENV") +-- if venv and vim.fn.executable(venv .. "/bin/python") == 1 then +-- return venv .. "/bin/python" +-- elseif vim.fn.executable(cwd .. "/venv/bin/python") == 1 then +-- return cwd .. "/venv/bin/python" +-- elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then +-- return cwd .. "/.venv/bin/python" +-- else +-- return "/usr/bin/python" +-- end +-- end, diff --git a/lua/modules/configs/tool/dap/dap-dlv.lua b/lua/modules/configs/tool/dap/dap-dlv.lua new file mode 100644 index 000000000..68fc55051 --- /dev/null +++ b/lua/modules/configs/tool/dap/dap-dlv.lua @@ -0,0 +1,55 @@ +local dap = require("dap") + +dap.adapters.go = function(callback) + local stdout = vim.loop.new_pipe(false) + local handle + local pid_or_err + local port = 38697 + local opts = { + stdio = { nil, stdout }, + args = { "dap", "-l", "127.0.0.1:" .. port }, + detached = true, + } + handle, pid_or_err = vim.loop.spawn("dlv", opts, function(code) + stdout:close() + handle:close() + if code ~= 0 then + vim.notify( + string.format('"dlv" exited with code: %d, please check your configs for correctness.', code), + vim.log.levels.WARN, + { title = "[go] DAP Warning!" } + ) + end + end) + assert(handle, "Error running dlv: " .. tostring(pid_or_err)) + stdout:read_start(function(err, chunk) + assert(not err, err) + if chunk then + vim.schedule(function() + require("dap.repl").append(chunk) + end) + end + end) + -- Wait for delve to start + vim.defer_fn(function() + callback({ type = "server", host = "127.0.0.1", port = port }) + end, 100) +end +-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md +dap.configurations.go = { + { type = "go", name = "Debug", request = "launch", program = "${file}" }, + { + type = "go", + name = "Debug test", -- configuration for debugging test files + request = "launch", + mode = "test", + program = "${file}", + }, -- works with go.mod packages and sub packages + { + type = "go", + name = "Debug test (go.mod)", + request = "launch", + mode = "test", + program = "./${relativeFileDirname}", + }, +} diff --git a/lua/modules/configs/tool/dap/dap-lldb.lua b/lua/modules/configs/tool/dap/dap-lldb.lua new file mode 100644 index 000000000..53aa9adfd --- /dev/null +++ b/lua/modules/configs/tool/dap/dap-lldb.lua @@ -0,0 +1,38 @@ +local dap = require("dap") + +dap.adapters.lldb = { + type = "executable", + command = "/usr/bin/lldb-vscode", + name = "lldb", +} +dap.configurations.cpp = { + { + name = "Launch", + type = "lldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = function() + local input = vim.fn.input("Input args: ") + return vim.fn.split(input, " ", true) + end, + + -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: + -- + -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope + -- + -- Otherwise you might get the following error: + -- + -- Error on launch: Failed to attach to the target process + -- + -- But you should be aware of the implications: + -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html + runInTerminal = false, + }, +} + +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp diff --git a/lua/modules/configs/tool/dap/dapui.lua b/lua/modules/configs/tool/dap/dapui.lua new file mode 100644 index 000000000..13896e2d8 --- /dev/null +++ b/lua/modules/configs/tool/dap/dapui.lua @@ -0,0 +1,57 @@ +return function() + local icons = { + ui = require("modules.utils.icons").get("ui"), + dap = require("modules.utils.icons").get("dap"), + } + + require("dapui").setup({ + icons = { expanded = icons.ui.ArrowOpen, collapsed = icons.ui.ArrowClosed, current_frame = icons.ui.Indicator }, + mappings = { + -- Use a table to apply multiple mappings + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + }, + layouts = { + { + elements = { + -- Provide as ID strings or tables with "id" and "size" keys + { + id = "scopes", + size = 0.25, -- Can be float or integer > 1 + }, + { id = "breakpoints", size = 0.25 }, + { id = "stacks", size = 0.25 }, + { id = "watches", size = 0.25 }, + }, + size = 40, + position = "left", + }, + { elements = { "repl" }, size = 10, position = "bottom" }, + }, + -- Requires Nvim version >= 0.8 + controls = { + enabled = true, + -- Display controls in this session + element = "repl", + icons = { + pause = icons.dap.Pause, + play = icons.dap.Play, + step_into = icons.dap.StepInto, + step_over = icons.dap.StepOver, + step_out = icons.dap.StepOut, + step_back = icons.dap.StepBack, + run_last = icons.dap.RunLast, + terminate = icons.dap.Terminate, + }, + }, + floating = { + max_height = nil, + max_width = nil, + mappings = { close = { "q", "" } }, + }, + windows = { indent = 1 }, + }) +end diff --git a/lua/modules/configs/tool/dap/init.lua b/lua/modules/configs/tool/dap/init.lua new file mode 100644 index 000000000..f0623fbfe --- /dev/null +++ b/lua/modules/configs/tool/dap/init.lua @@ -0,0 +1,40 @@ +return function() + local icons = { dap = require("modules.utils.icons").get("dap") } + local colors = require("modules.utils").get_palette() + + local dap = require("dap") + local dapui = require("dapui") + + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() + end + dap.listeners.after.event_terminated["dapui_config"] = function() + dapui.close() + end + dap.listeners.after.event_exited["dapui_config"] = function() + dapui.close() + end + + -- We need to override nvim-dap's default highlight groups, AFTER requiring nvim-dap for catppuccin. + vim.api.nvim_set_hl(0, "DapStopped", { fg = colors.green }) + + vim.fn.sign_define( + "DapBreakpoint", + { text = icons.dap.Breakpoint, texthl = "DapBreakpoint", linehl = "", numhl = "" } + ) + vim.fn.sign_define( + "DapBreakpointCondition", + { text = icons.dap.BreakpointCondition, texthl = "DapBreakpoint", linehl = "", numhl = "" } + ) + vim.fn.sign_define("DapStopped", { text = icons.dap.Stopped, texthl = "DapStopped", linehl = "", numhl = "" }) + vim.fn.sign_define( + "DapBreakpointRejected", + { text = icons.dap.BreakpointRejected, texthl = "DapBreakpoint", linehl = "", numhl = "" } + ) + vim.fn.sign_define("DapLogPoint", { text = icons.dap.LogPoint, texthl = "DapLogPoint", linehl = "", numhl = "" }) + + -- Config lang adaptors + require("tool.dap.dap-lldb") + require("tool.dap.dap-debugpy") + require("tool.dap.dap-dlv") +end diff --git a/lua/modules/configs/tool/dressing.lua b/lua/modules/configs/tool/dressing.lua new file mode 100644 index 000000000..b7e86de5a --- /dev/null +++ b/lua/modules/configs/tool/dressing.lua @@ -0,0 +1,12 @@ +return function() + require("dressing").setup({ + input = { + enabled = true, + }, + select = { + enabled = true, + backend = "telescope", + trim_prompt = true, + }, + }) +end diff --git a/lua/modules/configs/tool/imselect.lua b/lua/modules/configs/tool/imselect.lua new file mode 100644 index 000000000..a61028389 --- /dev/null +++ b/lua/modules/configs/tool/imselect.lua @@ -0,0 +1,17 @@ +-- fcitx5 need a manual config +return function() + if vim.fn.executable("fcitx5-remote") == 1 then + vim.api.nvim_cmd({ + [[ let g:im_select_get_im_cmd = ["fcitx5-remote"] ]], + [[ let g:im_select_default = '1' ]], + [[ let g:ImSelectSetImCmd = { + \ key -> + \ key == 1 ? ['fcitx5-remote', '-c'] : + \ key == 2 ? ['fcitx5-remote', '-o'] : + \ key == 0 ? ['fcitx5-remote', '-c'] : + \ execute("throw 'invalid im key'") + \ } + ]], + }, { true, true, true }) + end +end diff --git a/lua/modules/configs/tool/legendary.lua b/lua/modules/configs/tool/legendary.lua new file mode 100644 index 000000000..412d3219f --- /dev/null +++ b/lua/modules/configs/tool/legendary.lua @@ -0,0 +1,149 @@ +return function() + require("legendary").setup({ + which_key = { + auto_register = true, + do_binding = false, + }, + scratchpad = { + view = "float", + results_view = "float", + keep_contents = true, + }, + sort = { + -- sort most recently used item to the top + most_recent_first = true, + -- sort user-defined items before built-in items + user_items_first = true, + frecency = { + -- the directory to store the database in + db_root = string.format("%s/legendary/", vim.fn.stdpath("data")), + -- the maximum number of timestamps for a single item + -- to store in the database + max_timestamps = 10, + }, + }, + -- Directory used for caches + cache_path = string.format("%s/legendary/", vim.fn.stdpath("cache")), + -- Log level, one of 'trace', 'debug', 'info', 'warn', 'error', 'fatal' + log_level = "info", + }) + + require("which-key").register({ + [""] = { + b = { + name = "Bufferline commands", + d = "buffer: Sort by directory", + e = "buffer: Sort by extension", + }, + d = { + name = "Dap commands", + b = "debug: Set breakpoint with condition", + c = "debug: Run to cursor", + l = "debug: Run last", + o = "debug: Open repl", + }, + f = { + name = "Telescope commands", + p = "find: Project", + w = "find: Word", + r = "find: File by frecency", + e = "find: File by history", + c = "ui: Change color scheme", + z = "edit: Change current directory by zoxide", + f = "find: File under current work directory", + g = "find: File under current git directory", + n = "edit: New file", + b = "find: Buffer opened", + }, + h = { + name = "Gitsigns commands", + b = "git: Blame line", + p = "git: Preview hunk", + s = "git: Stage hunk", + u = "git: Undo stage hunk", + r = "git: Reset hunk", + R = "git: Reset buffer", + }, + l = { + name = "LSP commands", + i = "lsp: LSP Info", + r = "lsp: LSP Restart", + }, + n = { + name = "NvimTree commands", + f = "filetree: NvimTree find file", + r = "filetree: NvimTree refresh", + }, + p = { + name = "Package commands", + h = "package: Show", + s = "package: Sync", + i = "package: Install", + c = "package: Check", + d = "package: Debug", + l = "package: Log", + p = "package: Profile", + r = "package: Restore", + x = "package: Clean", + u = "package: Update", + }, + s = { + c = "lsp: Show cursor disgnostics", + l = "lsp: Show line disgnostics", + s = "sesson: Save session", + r = "sesson: Restore session", + d = "sesson: Delete session", + }, + t = { + name = "Trouble commands", + d = "lsp: Show document diagnostics", + w = "lsp: Show workspace diagnostics", + q = "lsp: Show quickfix list", + l = "lsp: Show loclist", + r = "lsp: Show lsp references", + }, + }, + ["g"] = { + a = "lsp: Code action", + d = "lsp: Preview definition", + D = "lsp: Goto definition", + h = "lsp: Show reference", + o = "lsp: Toggle outline", + r = "lsp: Rename in file range", + R = "lsp: Rename in project range", + s = "lsp: Signature help", + t = "lsp: Toggle trouble list", + b = "buffer: Buffer pick", + p = { + name = "git commands", + s = "git: Push", + l = "git: Pull", + }, + }, + [""] = "debug: Run/Continue", + [""] = "debug: Terminate debug session", + [""] = "debug: Toggle breakpoint", + [""] = "debug: Step into", + [""] = "debug: Step out", + [""] = "debug: Step over", + ["G"] = "git: Show fugitive", + ["g"] = "git: Show lazygit", + ["D"] = "git: Show diff", + ["D"] = "git: Close diff", + ["]g"] = "git: Goto next hunk", + ["[g"] = "git: Goto prev hunk", + ["g["] = "lsp: Goto prev diagnostic", + ["g]"] = "lsp: Goto next diagnostic", + ["ci"] = "lsp: Incoming calls", + ["co"] = "lsp: Outgoing calls", + ["w"] = "jump: Goto word", + ["j"] = "jump: Goto line", + ["k"] = "jump: Goto line", + ["c"] = "jump: Goto one char", + ["cc"] = "jump: Goto two chars", + ["o"] = "edit: Check spell", + ["u"] = "edit: Show undo history", + ["r"] = "tool: Code snip run", + [""] = "tool: Markdown preview", + }) +end diff --git a/lua/modules/configs/tool/nvim-tree.lua b/lua/modules/configs/tool/nvim-tree.lua new file mode 100644 index 000000000..3a41e1dfa --- /dev/null +++ b/lua/modules/configs/tool/nvim-tree.lua @@ -0,0 +1,183 @@ +return function() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics"), + documents = require("modules.utils.icons").get("documents"), + git = require("modules.utils.icons").get("git"), + ui = require("modules.utils.icons").get("ui"), + } + + require("nvim-tree").setup({ + create_in_closed_folder = false, + respect_buf_cwd = false, + auto_reload_on_write = true, + disable_netrw = false, + hijack_cursor = true, + hijack_netrw = true, + hijack_unnamed_buffer_when_opening = true, + ignore_buffer_on_setup = false, + open_on_setup = false, + open_on_setup_file = false, + open_on_tab = false, + sort_by = "name", + sync_root_with_cwd = true, + view = { + adaptive_size = false, + centralize_selection = false, + width = 30, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + hide_root_folder = false, + float = { + enable = false, + open_win_config = { + relative = "editor", + border = "rounded", + width = 30, + height = 30, + row = 1, + col = 1, + }, + }, + }, + renderer = { + add_trailing = false, + group_empty = true, + highlight_git = false, + full_name = false, + highlight_opened_files = "none", + special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md", "CMakeLists.txt" }, + symlink_destination = true, + indent_markers = { + enable = true, + icons = { + corner = "└ ", + edge = "│ ", + item = "│ ", + none = " ", + }, + }, + root_folder_label = ":.:s?.*?/..?", + icons = { + webdev_colors = true, + git_placement = "before", + show = { + file = true, + folder = true, + folder_arrow = false, + git = true, + }, + padding = " ", + symlink_arrow = "  ", + glyphs = { + default = icons.documents.Default, -- + symlink = icons.documents.Symlink, -- + bookmark = icons.ui.Bookmark, + git = { + unstaged = icons.git.Mod_alt, + staged = icons.git.Add, -- + unmerged = icons.git.Unmerged, + renamed = icons.git.Rename, -- + untracked = icons.git.Untracked, -- "ﲉ" + deleted = icons.git.Remove, -- + ignored = icons.git.Ignore, --◌ + }, + folder = { + -- arrow_open = "", + -- arrow_closed = "", + arrow_open = "", + arrow_closed = "", + default = icons.ui.Folder, + open = icons.ui.FolderOpen, + empty = icons.ui.EmptyFolder, + empty_open = icons.ui.EmptyFolderOpen, + symlink = icons.ui.SymlinkFolder, + symlink_open = icons.ui.FolderOpen, + }, + }, + }, + }, + hijack_directories = { + enable = true, + auto_open = true, + }, + update_focused_file = { + enable = true, + update_root = true, + ignore_list = {}, + }, + ignore_ft_on_setup = {}, + filters = { + dotfiles = false, + custom = { ".DS_Store" }, + exclude = {}, + }, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + }, + open_file = { + quit_on_open = false, + resize_window = false, + window_picker = { + enable = true, + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + filetype = { "notify", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "terminal", "help" }, + }, + }, + }, + remove_file = { + close_window = true, + }, + }, + diagnostics = { + enable = false, + show_on_dirs = false, + debounce_delay = 50, + icons = { + hint = icons.diagnostics.Hint_alt, + info = icons.diagnostics.Information_alt, + warning = icons.diagnostics.Warning_alt, + error = icons.diagnostics.Error_alt, + }, + }, + filesystem_watchers = { + enable = true, + debounce_delay = 50, + }, + git = { + enable = true, + ignore = true, + show_on_dirs = true, + timeout = 400, + }, + trash = { + cmd = "gio trash", + require_confirm = true, + }, + live_filter = { + prefix = "[FILTER]: ", + always_show_folders = true, + }, + log = { + enable = false, + truncate = false, + types = { + all = false, + config = false, + copy_paste = false, + dev = false, + diagnostics = false, + git = false, + profile = false, + watcher = false, + }, + }, + }) +end diff --git a/lua/modules/configs/tool/project.lua b/lua/modules/configs/tool/project.lua new file mode 100644 index 000000000..281f1a25e --- /dev/null +++ b/lua/modules/configs/tool/project.lua @@ -0,0 +1,13 @@ +return function() + require("project_nvim").setup({ + manual_mode = false, + detection_methods = { "lsp", "pattern" }, + patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, + ignore_lsp = { "efm", "copilot" }, + exclude_dirs = {}, + show_hidden = false, + silent_chdir = true, + scope_chdir = "global", + datapath = vim.fn.stdpath("data"), + }) +end diff --git a/lua/modules/configs/tool/smartyank.lua b/lua/modules/configs/tool/smartyank.lua new file mode 100644 index 000000000..d354de52a --- /dev/null +++ b/lua/modules/configs/tool/smartyank.lua @@ -0,0 +1,24 @@ +return function() + require("smartyank").setup({ + highlight = { + enabled = false, -- highlight yanked text + higroup = "IncSearch", -- highlight group of yanked text + timeout = 2000, -- timeout for clearing the highlight + }, + clipboard = { + enabled = true, + }, + tmux = { + enabled = true, + -- remove `-w` to disable copy to host client's clipboard + cmd = { "tmux", "set-buffer", "-w" }, + }, + osc52 = { + enabled = true, + escseq = "tmux", -- use tmux escape sequence, only enable if you're using remote tmux and have issues (see #4) + ssh_only = true, -- false to OSC52 yank also in local sessions + silent = false, -- true to disable the "n chars copied" echo + echo_hl = "Directory", -- highlight group of the OSC52 echo message + }, + }) +end diff --git a/lua/modules/configs/tool/sniprun.lua b/lua/modules/configs/tool/sniprun.lua new file mode 100644 index 000000000..06f018542 --- /dev/null +++ b/lua/modules/configs/tool/sniprun.lua @@ -0,0 +1,27 @@ +return function() + require("sniprun").setup({ + selected_interpreters = {}, -- " use those instead of the default for the current filetype + repl_enable = {}, -- " enable REPL-like behavior for the given interpreters + repl_disable = {}, -- " disable REPL-like behavior for the given interpreters + interpreter_options = {}, -- " intepreter-specific options, consult docs / :SnipInfo + -- " you can combo different display modes as desired + display = { + "TempFloatingWindowOk", -- display ok results in the floating window + "NvimNotifyErr", -- display err results with the nvim-notify plugin + -- "Classic", -- display results in the command line" + -- "VirtualText", -- display results in virtual text" + -- "LongTempFloatingWindow", -- display results in the long floating window + -- "Terminal" -- display results in a vertical split + -- "TerminalWithCode" -- display results and code history in a vertical split + }, + display_options = { + terminal_width = 45, + notification_timeout = 5000, + }, + -- " miscellaneous compatibility/adjustement settings + inline_messages = 0, -- " inline_message (0/1) is a one-line way to display messages + -- " to workaround sniprun not being able to display anything + borders = "single", -- " display borders around floating windows + -- " possible values are 'none', 'single', 'double', or 'shadow' + }) +end diff --git a/lua/modules/configs/tool/telescope.lua b/lua/modules/configs/tool/telescope.lua new file mode 100644 index 000000000..6454f0534 --- /dev/null +++ b/lua/modules/configs/tool/telescope.lua @@ -0,0 +1,75 @@ +return function() + local icons = { ui = require("modules.utils.icons").get("ui", true) } + local lga_actions = require("telescope-live-grep-args.actions") + + require("telescope").setup({ + defaults = { + initial_mode = "insert", + prompt_prefix = " " .. icons.ui.Telescope .. " ", + selection_caret = icons.ui.ChevronRight, + scroll_strategy = "limit", + results_title = false, + layout_strategy = "horizontal", + path_display = { "absolute" }, + file_ignore_patterns = { ".git/", ".cache", "%.class", "%.pdf", "%.mkv", "%.mp4", "%.zip" }, + layout_config = { + horizontal = { + preview_width = 0.5, + }, + }, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + file_sorter = require("telescope.sorters").get_fuzzy_file, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + }, + extensions = { + fzf = { + fuzzy = false, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + frecency = { + show_scores = true, + show_unindexed = true, + ignore_patterns = { "*.git/*", "*/tmp/*" }, + }, + live_grep_args = { + auto_quoting = true, -- enable/disable auto-quoting + -- define mappings, e.g. + mappings = { -- extend mappings + i = { + [""] = lga_actions.quote_prompt(), + [""] = lga_actions.quote_prompt({ postfix = " --iglob " }), + }, + }, + }, + undo = { + side_by_side = true, + layout_config = { + preview_height = 0.8, + }, + mappings = { -- this whole table is the default + i = { + -- IMPORTANT: Note that telescope-undo must be available when telescope is configured if + -- you want to use the following actions. This means installing as a dependency of + -- telescope in it's `requirements` and loading this extension from there instead of + -- having the separate plugin definition as outlined above. See issue #6. + [""] = require("telescope-undo.actions").yank_additions, + [""] = require("telescope-undo.actions").yank_deletions, + [""] = require("telescope-undo.actions").restore, + }, + }, + }, + }, + }) + + require("telescope").load_extension("notify") + require("telescope").load_extension("fzf") + require("telescope").load_extension("projects") + require("telescope").load_extension("zoxide") + require("telescope").load_extension("frecency") + require("telescope").load_extension("live_grep_args") + require("telescope").load_extension("undo") +end diff --git a/lua/modules/configs/tool/toggleterm.lua b/lua/modules/configs/tool/toggleterm.lua new file mode 100644 index 000000000..19dd6a2dc --- /dev/null +++ b/lua/modules/configs/tool/toggleterm.lua @@ -0,0 +1,37 @@ +return function() + local colors = require("modules.utils").get_palette() + local floatborder_hl = require("modules.utils").hl_to_rgb("FloatBorder", false, colors.blue) + + require("toggleterm").setup({ + -- size can be a number or function which is passed the current terminal + size = function(term) + if term.direction == "horizontal" then + return 15 + elseif term.direction == "vertical" then + return vim.o.columns * 0.40 + end + end, + on_open = function() + -- Prevent infinite calls from freezing neovim. + -- Only set these options specific to this terminal buffer. + vim.api.nvim_set_option_value("foldmethod", "manual", { scope = "local" }) + vim.api.nvim_set_option_value("foldexpr", "0", { scope = "local" }) + end, + highlights = { + FloatBorder = { + guifg = floatborder_hl, + }, + }, + open_mapping = false, -- [[]], + hide_numbers = true, -- hide the number column in toggleterm buffers + shade_filetypes = {}, + shade_terminals = false, + shading_factor = "1", -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light + start_in_insert = true, + insert_mappings = true, -- whether or not the open mapping applies in insert mode + persist_size = true, + direction = "horizontal", + close_on_exit = true, -- close the terminal window when the process exits + shell = vim.o.shell, -- change the default shell + }) +end diff --git a/lua/modules/configs/tool/trouble.lua b/lua/modules/configs/tool/trouble.lua new file mode 100644 index 000000000..7c4d59785 --- /dev/null +++ b/lua/modules/configs/tool/trouble.lua @@ -0,0 +1,55 @@ +return function() + local icons = { + ui = require("modules.utils.icons").get("ui"), + diagnostics = require("modules.utils.icons").get("diagnostics"), + } + + require("trouble").setup({ + position = "bottom", -- position of the list can be: bottom, top, left, right + height = 10, -- height of the trouble list when position is top or bottom + width = 50, -- width of the list when position is left or right + icons = true, -- use devicons for filenames + mode = "document_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" + fold_open = icons.ui.ArrowOpen, -- icon used for open folds + fold_closed = icons.ui.ArrowClosed, -- icon used for closed folds + group = true, -- group results by file + padding = true, -- add an extra new line on top of the list + action_keys = { + -- key mappings for actions in the trouble list + -- map to {} to remove a mapping, for example: + -- close = {}, + close = "q", -- close the list + cancel = "", -- cancel the preview and get back to your last window / buffer / cursor + refresh = "r", -- manually refresh + jump = { "", "" }, -- jump to the diagnostic or open / close folds + open_split = { "" }, -- open buffer in new split + open_vsplit = { "" }, -- open buffer in new vsplit + open_tab = { "" }, -- open buffer in new tab + jump_close = { "o" }, -- jump to the diagnostic and close the list + toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode + toggle_preview = "P", -- toggle auto_preview + hover = "K", -- opens a small popup with the full multiline message + preview = "p", -- preview the diagnostic location + close_folds = { "zM", "zm" }, -- close all folds + open_folds = { "zR", "zr" }, -- open all folds + toggle_fold = { "zA", "za" }, -- toggle fold of current file + previous = "k", -- preview item + next = "j", -- next item + }, + indent_lines = true, -- add an indent guide below the fold icons + auto_open = false, -- automatically open the list when you have diagnostics + auto_close = false, -- automatically close the list when you have no diagnostics + auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window + auto_fold = false, -- automatically fold a file trouble list at creation + auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result + signs = { + -- icons / text used for a diagnostic + error = icons.diagnostics.Error_alt, + warning = icons.diagnostics.Warning_alt, + hint = icons.diagnostics.Hint_alt, + information = icons.diagnostics.Information_alt, + other = icons.diagnostics.Question_alt, + }, + use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client + }) +end diff --git a/lua/modules/configs/tool/which-key.lua b/lua/modules/configs/tool/which-key.lua new file mode 100644 index 000000000..319264fde --- /dev/null +++ b/lua/modules/configs/tool/which-key.lua @@ -0,0 +1,34 @@ +return function() + local icons = { + ui = require("modules.utils.icons").get("ui"), + misc = require("modules.utils.icons").get("misc"), + } + + require("which-key").setup({ + plugins = { + presets = { + operators = false, + motions = false, + text_objects = false, + windows = false, + nav = false, + z = true, + g = true, + }, + }, + + icons = { + breadcrumb = icons.ui.Separator, + separator = icons.misc.Vbar, + group = icons.misc.Add, + }, + + window = { + border = "none", + position = "bottom", + margin = { 1, 0, 1, 0 }, + padding = { 1, 1, 1, 1 }, + winblend = 0, + }, + }) +end diff --git a/lua/modules/configs/tool/wilder.lua b/lua/modules/configs/tool/wilder.lua new file mode 100644 index 000000000..74a0cc9a0 --- /dev/null +++ b/lua/modules/configs/tool/wilder.lua @@ -0,0 +1,63 @@ +return function() + local wilder = require("wilder") + local colors = require("modules.utils").get_palette() + local icons = { ui = require("modules.utils.icons").get("ui") } + + wilder.setup({ modes = { ":", "/", "?" } }) + wilder.set_option("use_python_remote_plugin", 0) + wilder.set_option("pipeline", { + wilder.branch( + wilder.cmdline_pipeline({ use_python = 0, fuzzy = 1, fuzzy_filter = wilder.lua_fzy_filter() }), + wilder.vim_search_pipeline(), + { + wilder.check(function(_, x) + return x == "" + end), + wilder.history(), + wilder.result({ + draw = { + function(_, x) + return icons.ui.Calendar .. " " .. x + end, + }, + }), + } + ), + }) + + local match_hl = require("modules.utils").hl_to_rgb("String", false, colors.green) + + local popupmenu_renderer = wilder.popupmenu_renderer(wilder.popupmenu_border_theme({ + border = "rounded", + highlights = { + border = "Title", -- highlight to use for the border + accent = wilder.make_hl("WilderAccent", "Pmenu", { { a = 0 }, { a = 0 }, { foreground = match_hl } }), + }, + empty_message = wilder.popupmenu_empty_message_with_spinner(), + highlighter = wilder.lua_fzy_highlighter(), + left = { + " ", + wilder.popupmenu_devicons(), + wilder.popupmenu_buffer_flags({ + flags = " a + ", + icons = { ["+"] = icons.ui.Pencil, a = icons.ui.Indicator, h = icons.ui.File }, + }), + }, + right = { + " ", + wilder.popupmenu_scrollbar(), + }, + })) + local wildmenu_renderer = wilder.wildmenu_renderer({ + highlighter = wilder.lua_fzy_highlighter(), + apply_incsearch_fix = true, + }) + wilder.set_option( + "renderer", + wilder.renderer_mux({ + [":"] = popupmenu_renderer, + ["/"] = wildmenu_renderer, + substitute = wildmenu_renderer, + }) + ) +end diff --git a/lua/modules/configs/ui/alpha.lua b/lua/modules/configs/ui/alpha.lua new file mode 100644 index 000000000..b17571d57 --- /dev/null +++ b/lua/modules/configs/ui/alpha.lua @@ -0,0 +1,115 @@ +return function() + local alpha = require("alpha") + local dashboard = require("alpha.themes.dashboard") + + dashboard.section.header.val = { + [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⣾⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⣿⣟⠻⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⡿⢫⣷⣿⣿⣿⣿⣿⣿⣿⣾⣯⣿⡿⢧⡚⢷⣌⣽⣿⣿⣿⣿⣿⣶⡌⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣇⣘⠿⢹⣿⣿⣿⣿⣿⣻⢿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⠀⢸⣿⣿⡇⣿⣿⣿⣿⣿⣿⣿⣿⡟⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣻⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⡇⠀⣬⠏⣿⡇⢻⣿⣿⣿⣿⣿⣿⣿⣷⣼⣿⣿⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⠀⠈⠁⠀⣿⡇⠘⡟⣿⣿⣿⣿⣿⣿⣿⣿⡏⠿⣿⣟⣿⣿⣿⣿⣿⣿⣿⣿⣇⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⡏⠀⠀⠐⠀⢻⣇⠀⠀⠹⣿⣿⣿⣿⣿⣿⣩⡶⠼⠟⠻⠞⣿⡈⠻⣟⢻⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⢿⠀⡆⠀⠘⢿⢻⡿⣿⣧⣷⢣⣶⡃⢀⣾⡆⡋⣧⠙⢿⣿⣿⣟⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⡥⠂⡐⠀⠁⠑⣾⣿⣿⣾⣿⣿⣿⡿⣷⣷⣿⣧⣾⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⡿⣿⣍⡴⠆⠀⠀⠀⠀⠀⠀⠀⠀⣼⣄⣀⣷⡄⣙⢿⣿⣿⣿⣿⣯⣶⣿⣿⢟⣾⣿⣿⢡⣿⣿⣿⣿⣿]], + [[⣿⡏⣾⣿⣿⣿⣷⣦⠀⠀⠀⢀⡀⠀⠀⠠⣭⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⣡⣾⣿⣿⢏⣾⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⡴⠀⠀⠀⠀⠀⠠⠀⠰⣿⣿⣿⣷⣿⠿⠿⣿⣿⣭⡶⣫⠔⢻⢿⢇⣾⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⡿⢫⣽⠟⣋⠀⠀⠀⠀⣶⣦⠀⠀⠀⠈⠻⣿⣿⣿⣾⣿⣿⣿⣿⡿⣣⣿⣿⢸⣾⣿⣿⣿⣿⣿⣿⣿]], + [[⡿⠛⣹⣶⣶⣶⣾⣿⣷⣦⣤⣤⣀⣀⠀⠀⠀⠀⠀⠀⠉⠛⠻⢿⣿⡿⠫⠾⠿⠋⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣀⡆⣠⢀⣴⣏⡀⠀⠀⠀⠉⠀⠀⢀⣠⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⠿⠛⠛⠛⠛⠛⠛⠻⢿⣿⣿⣿⣿⣯⣟⠷⢷⣿⡿⠋⠀⠀⠀⠀⣵⡀⢠⡿⠋⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⢿⣿⣿⠂⠀⠀⠀⠀⠀⢀⣽⣿⣿⣿⣿⣿⣿⣿⣍⠛⠿⣿⣿⣿⣿⣿⣿]], + } + dashboard.section.header.opts.hl = "Type" + + local function button(sc, txt, leader_txt, keybind, keybind_opts) + local sc_after = sc:gsub("%s", ""):gsub(leader_txt, "") + + local opts = { + position = "center", + shortcut = sc, + cursor = 5, + width = 50, + align_shortcut = "right", + hl_shortcut = "Keyword", + } + + if nil == keybind then + keybind = sc_after + end + keybind_opts = vim.F.if_nil(keybind_opts, { noremap = true, silent = true, nowait = true }) + opts.keymap = { "n", sc_after, keybind, keybind_opts } + + local function on_press() + -- local key = vim.api.nvim_replace_termcodes(keybind .. '', true, false, true) + local key = vim.api.nvim_replace_termcodes(sc_after .. "", true, false, true) + vim.api.nvim_feedkeys(key, "t", false) + end + + return { + type = "button", + val = txt, + on_press = on_press, + opts = opts, + } + end + + local leader = " " + dashboard.section.buttons.val = { + button("space f c", " Scheme change", leader, "Telescope colorscheme"), + button("space f r", " File frecency", leader, "Telescope frecency"), + button("space f e", " File history", leader, "Telescope oldfiles"), + button("space f p", " Project find", leader, "Telescope projects"), + button("space f f", " File find", leader, "Telescope find_files"), + button("space f n", " File new", leader, "enew"), + button("space f w", " Word find", leader, "Telescope live_grep"), + } + dashboard.section.buttons.opts.hl = "String" + + local function footer() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return "  Have Fun with neovim" + .. "  v" + .. vim.version().major + .. "." + .. vim.version().minor + .. "." + .. vim.version().patch + .. "  " + .. stats.count + .. " plugins in " + .. ms + .. "ms" + end + + dashboard.section.footer.val = footer() + dashboard.section.footer.opts.hl = "Function" + + local head_butt_padding = 2 + local occu_height = #dashboard.section.header.val + 2 * #dashboard.section.buttons.val + head_butt_padding + local header_padding = math.max(0, math.ceil((vim.fn.winheight("$") - occu_height) * 0.25)) + local foot_butt_padding = 1 + + dashboard.config.layout = { + { type = "padding", val = header_padding }, + dashboard.section.header, + { type = "padding", val = head_butt_padding }, + dashboard.section.buttons, + { type = "padding", val = foot_butt_padding }, + dashboard.section.footer, + } + + alpha.setup(dashboard.opts) + + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimStarted", + callback = function() + dashboard.section.footer.val = footer() + pcall(vim.cmd.AlphaRedraw) + end, + }) +end diff --git a/lua/modules/configs/ui/bufferline.lua b/lua/modules/configs/ui/bufferline.lua new file mode 100644 index 000000000..0d538d13b --- /dev/null +++ b/lua/modules/configs/ui/bufferline.lua @@ -0,0 +1,67 @@ +return function() + local icons = { ui = require("modules.utils.icons").get("ui") } + + local opts = { + options = { + number = nil, + modified_icon = icons.ui.Modified, + buffer_close_icon = icons.ui.Close, + left_trunc_marker = icons.ui.Left, + right_trunc_marker = icons.ui.Right, + max_name_length = 14, + max_prefix_length = 13, + tab_size = 20, + show_buffer_close_icons = true, + show_buffer_icons = true, + show_tab_indicators = true, + diagnostics = "nvim_lsp", + always_show_bufferline = true, + separator_style = "thin", + offsets = { + { + filetype = "NvimTree", + text = "File Explorer", + text_align = "center", + padding = 1, + }, + { + filetype = "lspsagaoutline", + text = "Lspsaga Outline", + text_align = "center", + padding = 1, + }, + }, + diagnostics_indicator = function(count) + return "(" .. count .. ")" + end, + }, + -- Change bufferline's highlights here! See `:h bufferline-highlights` for detailed explanation. + -- Note: If you use catppuccin then modify the colors below! + highlights = {}, + } + + if vim.g.colors_name == "catppuccin" then + local cp = require("modules.utils").get_palette() -- Get the palette. + + local catppuccin_hl_overwrite = { + highlights = require("catppuccin.groups.integrations.bufferline").get({ + styles = { "italic", "bold" }, + custom = { + mocha = { + -- Hint + hint = { fg = cp.rosewater }, + hint_visible = { fg = cp.rosewater }, + hint_selected = { fg = cp.rosewater }, + hint_diagnostic = { fg = cp.rosewater }, + hint_diagnostic_visible = { fg = cp.rosewater }, + hint_diagnostic_selected = { fg = cp.rosewater }, + }, + }, + }), + } + + opts = vim.tbl_deep_extend("force", opts, catppuccin_hl_overwrite) + end + + require("bufferline").setup(opts) +end diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua new file mode 100644 index 000000000..7ce7b2948 --- /dev/null +++ b/lua/modules/configs/ui/catppuccin.lua @@ -0,0 +1,245 @@ +return function() + local transparent_background = false -- Set background transparency here! + + require("catppuccin").setup({ + flavour = "mocha", -- Can be one of: latte, frappe, macchiato, mocha + background = { light = "latte", dark = "mocha" }, + dim_inactive = { + enabled = false, + -- Dim inactive splits/windows/buffers. + -- NOT recommended if you use old palette (a.k.a., mocha). + shade = "dark", + percentage = 0.15, + }, + transparent_background = transparent_background, + show_end_of_buffer = false, -- show the '~' characters after the end of buffers + term_colors = true, + compile_path = vim.fn.stdpath("cache") .. "/catppuccin", + styles = { + comments = { "italic" }, + properties = { "italic" }, + functions = { "italic", "bold" }, + keywords = { "italic" }, + operators = { "bold" }, + conditionals = { "bold" }, + loops = { "bold" }, + booleans = { "bold", "italic" }, + numbers = {}, + types = {}, + strings = {}, + variables = {}, + }, + integrations = { + treesitter = true, + native_lsp = { + enabled = true, + virtual_text = { + errors = { "italic" }, + hints = { "italic" }, + warnings = { "italic" }, + information = { "italic" }, + }, + underlines = { + errors = { "underline" }, + hints = { "underline" }, + warnings = { "underline" }, + information = { "underline" }, + }, + }, + aerial = false, + barbar = false, + beacon = false, + cmp = true, + coc_nvim = false, + dap = { enabled = true, enable_ui = true }, + dashboard = false, + fern = false, + fidget = true, + gitgutter = false, + gitsigns = true, + harpoon = false, + hop = true, + illuminate = true, + indent_blankline = { enabled = true, colored_indent_levels = false }, + leap = false, + lightspeed = false, + lsp_saga = true, + lsp_trouble = true, + markdown = true, + mason = true, + mini = false, + navic = { enabled = false }, + neogit = false, + neotest = false, + neotree = { enabled = false, show_root = true, transparent_panel = false }, + noice = false, + notify = true, + nvimtree = true, + overseer = false, + pounce = false, + semantic_tokens = false, + symbols_outline = false, + telekasten = false, + telescope = true, + treesitter_context = false, + ts_rainbow = true, + vim_sneak = false, + vimwiki = false, + which_key = true, + }, + color_overrides = { + mocha = { + rosewater = "#F5E0DC", + flamingo = "#F2CDCD", + mauve = "#DDB6F2", + pink = "#F5C2E7", + red = "#F28FAD", + maroon = "#E8A2AF", + peach = "#F8BD96", + yellow = "#FAE3B0", + green = "#ABE9B3", + blue = "#96CDFB", + sky = "#89DCEB", + teal = "#B5E8E0", + lavender = "#C9CBFF", + + text = "#D9E0EE", + subtext1 = "#BAC2DE", + subtext0 = "#A6ADC8", + overlay2 = "#C3BAC6", + overlay1 = "#988BA2", + overlay0 = "#6E6C7E", + surface2 = "#6E6C7E", + surface1 = "#575268", + surface0 = "#302D41", + + base = "#1E1E2E", + mantle = "#1A1826", + crust = "#161320", + }, + }, + highlight_overrides = { + mocha = function(cp) + return { + -- For base configs. + NormalFloat = { fg = cp.text, bg = transparent_background and cp.none or cp.base }, + CursorLineNr = { fg = cp.green }, + Search = { bg = cp.surface1, fg = cp.pink, style = { "bold" } }, + IncSearch = { bg = cp.pink, fg = cp.surface1 }, + Keyword = { fg = cp.pink }, + Type = { fg = cp.blue }, + Typedef = { fg = cp.yellow }, + StorageClass = { fg = cp.red, style = { "italic" } }, + + -- For native lsp configs. + DiagnosticVirtualTextError = { bg = cp.none }, + DiagnosticVirtualTextWarn = { bg = cp.none }, + DiagnosticVirtualTextInfo = { bg = cp.none }, + DiagnosticVirtualTextHint = { fg = cp.rosewater, bg = cp.none }, + + DiagnosticHint = { fg = cp.rosewater }, + LspDiagnosticsDefaultHint = { fg = cp.rosewater }, + LspDiagnosticsHint = { fg = cp.rosewater }, + LspDiagnosticsVirtualTextHint = { fg = cp.rosewater }, + LspDiagnosticsUnderlineHint = { sp = cp.rosewater }, + + -- For fidget. + FidgetTask = { bg = cp.none, fg = cp.surface2 }, + FidgetTitle = { fg = cp.blue, style = { "bold" } }, + + -- For trouble.nvim + TroubleNormal = { bg = cp.base }, + + -- For treesitter. + ["@field"] = { fg = cp.rosewater }, + ["@property"] = { fg = cp.yellow }, + + ["@include"] = { fg = cp.teal }, + -- ["@operator"] = { fg = cp.sky }, + ["@keyword.operator"] = { fg = cp.sky }, + ["@punctuation.special"] = { fg = cp.maroon }, + + -- ["@float"] = { fg = cp.peach }, + -- ["@number"] = { fg = cp.peach }, + -- ["@boolean"] = { fg = cp.peach }, + + ["@constructor"] = { fg = cp.lavender }, + -- ["@constant"] = { fg = cp.peach }, + -- ["@conditional"] = { fg = cp.mauve }, + -- ["@repeat"] = { fg = cp.mauve }, + ["@exception"] = { fg = cp.peach }, + + ["@constant.builtin"] = { fg = cp.lavender }, + -- ["@function.builtin"] = { fg = cp.peach, style = { "italic" } }, + -- ["@type.builtin"] = { fg = cp.yellow, style = { "italic" } }, + ["@type.qualifier"] = { link = "@keyword" }, + ["@variable.builtin"] = { fg = cp.red, style = { "italic" } }, + + -- ["@function"] = { fg = cp.blue }, + ["@function.macro"] = { fg = cp.red, style = {} }, + ["@parameter"] = { fg = cp.rosewater }, + ["@keyword"] = { fg = cp.red, style = { "italic" } }, + ["@keyword.function"] = { fg = cp.maroon }, + ["@keyword.return"] = { fg = cp.pink, style = {} }, + + -- ["@text.note"] = { fg = cp.base, bg = cp.blue }, + -- ["@text.warning"] = { fg = cp.base, bg = cp.yellow }, + -- ["@text.danger"] = { fg = cp.base, bg = cp.red }, + -- ["@constant.macro"] = { fg = cp.mauve }, + + -- ["@label"] = { fg = cp.blue }, + ["@method"] = { fg = cp.blue, style = { "italic" } }, + ["@namespace"] = { fg = cp.rosewater, style = {} }, + + ["@punctuation.delimiter"] = { fg = cp.teal }, + ["@punctuation.bracket"] = { fg = cp.overlay2 }, + -- ["@string"] = { fg = cp.green }, + -- ["@string.regex"] = { fg = cp.peach }, + ["@type"] = { fg = cp.yellow }, + ["@variable"] = { fg = cp.text }, + ["@tag.attribute"] = { fg = cp.mauve, style = { "italic" } }, + ["@tag"] = { fg = cp.peach }, + ["@tag.delimiter"] = { fg = cp.maroon }, + ["@text"] = { fg = cp.text }, + + -- ["@text.uri"] = { fg = cp.rosewater, style = { "italic", "underline" } }, + -- ["@text.literal"] = { fg = cp.teal, style = { "italic" } }, + -- ["@text.reference"] = { fg = cp.lavender, style = { "bold" } }, + -- ["@text.title"] = { fg = cp.blue, style = { "bold" } }, + -- ["@text.emphasis"] = { fg = cp.maroon, style = { "italic" } }, + -- ["@text.strong"] = { fg = cp.maroon, style = { "bold" } }, + -- ["@string.escape"] = { fg = cp.pink }, + + -- ["@property.toml"] = { fg = cp.blue }, + -- ["@field.yaml"] = { fg = cp.blue }, + + -- ["@label.json"] = { fg = cp.blue }, + + ["@function.builtin.bash"] = { fg = cp.red, style = { "italic" } }, + ["@parameter.bash"] = { fg = cp.yellow, style = { "italic" } }, + + ["@field.lua"] = { fg = cp.lavender }, + ["@constructor.lua"] = { fg = cp.flamingo }, + + ["@constant.java"] = { fg = cp.teal }, + + ["@property.typescript"] = { fg = cp.lavender, style = { "italic" } }, + -- ["@constructor.typescript"] = { fg = cp.lavender }, + + -- ["@constructor.tsx"] = { fg = cp.lavender }, + -- ["@tag.attribute.tsx"] = { fg = cp.mauve }, + + ["@type.css"] = { fg = cp.lavender }, + ["@property.css"] = { fg = cp.yellow, style = { "italic" } }, + + ["@type.builtin.c"] = { fg = cp.yellow, style = {} }, + + ["@property.cpp"] = { fg = cp.text }, + ["@type.builtin.cpp"] = { fg = cp.yellow, style = {} }, + + -- ["@symbol"] = { fg = cp.flamingo }, + } + end, + }, + }) +end diff --git a/lua/modules/configs/ui/edge.lua b/lua/modules/configs/ui/edge.lua new file mode 100644 index 000000000..216899a8e --- /dev/null +++ b/lua/modules/configs/ui/edge.lua @@ -0,0 +1,8 @@ +return function() + vim.g.edge_style = "aura" + vim.g.edge_enable_italic = 1 + vim.g.edge_disable_italic_comment = 1 + vim.g.edge_show_eob = 1 + vim.g.edge_better_performance = 1 + vim.g.edge_transparent_background = 1 +end diff --git a/lua/modules/configs/ui/fidget.lua b/lua/modules/configs/ui/fidget.lua new file mode 100644 index 000000000..2a26b3f91 --- /dev/null +++ b/lua/modules/configs/ui/fidget.lua @@ -0,0 +1,5 @@ +return function() + require("fidget").setup({ + window = { blend = 0 }, + }) +end diff --git a/lua/modules/configs/ui/gitsigns.lua b/lua/modules/configs/ui/gitsigns.lua new file mode 100644 index 000000000..0bee92347 --- /dev/null +++ b/lua/modules/configs/ui/gitsigns.lua @@ -0,0 +1,68 @@ +return function() + require("gitsigns").setup({ + signs = { + add = { + hl = "GitSignsAdd", + text = "│", + numhl = "GitSignsAddNr", + linehl = "GitSignsAddLn", + }, + change = { + hl = "GitSignsChange", + text = "│", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + delete = { + hl = "GitSignsDelete", + text = "_", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + topdelete = { + hl = "GitSignsDelete", + text = "‾", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + changedelete = { + hl = "GitSignsChange", + text = "~", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + }, + keymaps = { + -- Default keymap options + noremap = true, + buffer = true, + ["n ]g"] = { + expr = true, + "&diff ? ']g' : 'lua require\"gitsigns\".next_hunk()'", + }, + ["n [g"] = { + expr = true, + "&diff ? '[g' : 'lua require\"gitsigns\".prev_hunk()'", + }, + ["n hs"] = 'lua require"gitsigns".stage_hunk()', + ["v hs"] = 'lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})', + ["n hu"] = 'lua require"gitsigns".undo_stage_hunk()', + ["n hr"] = 'lua require"gitsigns".reset_hunk()', + ["v hr"] = 'lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})', + ["n hR"] = 'lua require"gitsigns".reset_buffer()', + ["n hp"] = 'lua require"gitsigns".preview_hunk()', + ["n hb"] = 'lua require"gitsigns".blame_line({full=true})', + -- Text objects + ["o ih"] = ':lua require"gitsigns".text_object()', + ["x ih"] = ':lua require"gitsigns".text_object()', + }, + watch_gitdir = { interval = 1000, follow_files = true }, + current_line_blame = true, + current_line_blame_opts = { delay = 1000, virtual_text_pos = "eol" }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + word_diff = false, + diff_opts = { internal = true }, + }) +end diff --git a/lua/modules/configs/ui/indent-blankline.lua b/lua/modules/configs/ui/indent-blankline.lua new file mode 100644 index 000000000..aa49f7019 --- /dev/null +++ b/lua/modules/configs/ui/indent-blankline.lua @@ -0,0 +1,47 @@ +return function() + require("indent_blankline").setup({ + char = "│", + show_first_indent_level = true, + filetype_exclude = { + "startify", + "dashboard", + "dotooagenda", + "log", + "fugitive", + "gitcommit", + "vimwiki", + "markdown", + "json", + "txt", + "vista", + "help", + "todoist", + "NvimTree", + "peekaboo", + "git", + "TelescopePrompt", + "flutterToolsOutline", + "", -- for all buffers without a file type + }, + buftype_exclude = { "terminal", "nofile" }, + show_trailing_blankline_indent = false, + show_current_context = true, + context_patterns = { + "class", + "function", + "method", + "block", + "list_literal", + "selector", + "^if", + "^table", + "if_statement", + "while", + "for", + "type", + "var", + "import", + }, + space_char_blankline = " ", + }) +end diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua new file mode 100644 index 000000000..70afbe773 --- /dev/null +++ b/lua/modules/configs/ui/lualine.lua @@ -0,0 +1,171 @@ +return function() + local colors = require("modules.utils").get_palette() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics", true), + misc = require("modules.utils.icons").get("misc", true), + ui = require("modules.utils.icons").get("ui", true), + } + + local function escape_status() + local ok, m = pcall(require, "better_escape") + return ok and m.waiting and icons.misc.EscapeST or "" + end + + local _cache = { context = "", bufnr = -1 } + local function lspsaga_symbols() + local exclude = { + ["terminal"] = true, + ["toggleterm"] = true, + ["prompt"] = true, + ["NvimTree"] = true, + ["help"] = true, + } + if vim.api.nvim_win_get_config(0).zindex or exclude[vim.bo.filetype] then + return "" -- Excluded filetypes + else + local currbuf = vim.api.nvim_get_current_buf() + local ok, lspsaga = pcall(require, "lspsaga.symbolwinbar") + if ok and lspsaga:get_winbar() ~= nil then + _cache.context = lspsaga:get_winbar() + _cache.bufnr = currbuf + elseif _cache.bufnr ~= currbuf then + _cache.context = "" -- Reset [invalid] cache (usually from another buffer) + end + + return _cache.context + end + end + + local function diff_source() + local gitsigns = vim.b.gitsigns_status_dict + if gitsigns then + return { + added = gitsigns.added, + modified = gitsigns.changed, + removed = gitsigns.removed, + } + end + end + + local function get_cwd() + local cwd = vim.fn.getcwd() + local is_windows = require("core.global").is_windows + if not is_windows then + local home = require("core.global").home + if cwd:find(home, 1, true) == 1 then + cwd = "~" .. cwd:sub(#home + 1) + end + end + return icons.ui.RootFolderOpened .. cwd + end + + local mini_sections = { + lualine_a = { "filetype" }, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {}, + } + local outline = { + sections = mini_sections, + filetypes = { "lspsagaoutline" }, + } + local diffview = { + sections = mini_sections, + filetypes = { "DiffviewFiles" }, + } + + local function python_venv() + local function env_cleanup(venv) + if string.find(venv, "/") then + local final_venv = venv + for w in venv:gmatch("([^/]+)") do + final_venv = w + end + venv = final_venv + end + return venv + end + + if vim.bo.filetype == "python" then + local venv = os.getenv("CONDA_DEFAULT_ENV") + if venv then + return string.format("%s", env_cleanup(venv)) + end + venv = os.getenv("VIRTUAL_ENV") + if venv then + return string.format("%s", env_cleanup(venv)) + end + end + return "" + end + + require("lualine").setup({ + options = { + icons_enabled = true, + theme = "catppuccin", + disabled_filetypes = {}, + component_separators = "|", + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { { "mode" } }, + lualine_b = { { "branch" }, { "diff", source = diff_source } }, + lualine_c = { lspsaga_symbols }, + lualine_x = { + { escape_status }, + { + "diagnostics", + sources = { "nvim_diagnostic" }, + symbols = { + error = icons.diagnostics.Error, + warn = icons.diagnostics.Warning, + info = icons.diagnostics.Information, + }, + }, + { get_cwd }, + }, + lualine_y = { + { "filetype", colored = true, icon_only = true }, + { python_venv }, + { "encoding" }, + { + "fileformat", + icons_enabled = true, + symbols = { + unix = "LF", + dos = "CRLF", + mac = "CR", + }, + }, + }, + lualine_z = { "progress", "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = { + "quickfix", + "nvim-tree", + "nvim-dap-ui", + "toggleterm", + "fugitive", + outline, + diffview, + }, + }) + + -- Properly set background color for lspsaga + local winbar_bg = require("modules.utils").hl_to_rgb("StatusLine", true, colors.mantle) + for _, hlGroup in pairs(require("lspsaga.lspkind").get_kind()) do + require("modules.utils").extend_hl("LspSagaWinbar" .. hlGroup[1], { bg = winbar_bg }) + end + require("modules.utils").extend_hl("LspSagaWinbarSep", { bg = winbar_bg }) +end diff --git a/lua/modules/configs/ui/neodim.lua b/lua/modules/configs/ui/neodim.lua new file mode 100644 index 000000000..200496b25 --- /dev/null +++ b/lua/modules/configs/ui/neodim.lua @@ -0,0 +1,17 @@ +return function() + local blend_color = require("modules.utils").hl_to_rgb("Normal", true) + + require("neodim").setup({ + alpha = 0.45, + blend_color = blend_color, + update_in_insert = { + enable = true, + delay = 100, + }, + hide = { + virtual_text = true, + signs = false, + underline = false, + }, + }) +end diff --git a/lua/modules/configs/ui/neoscroll.lua b/lua/modules/configs/ui/neoscroll.lua new file mode 100644 index 000000000..10235a846 --- /dev/null +++ b/lua/modules/configs/ui/neoscroll.lua @@ -0,0 +1,24 @@ +return function() + require("neoscroll").setup({ + -- All these keys will be mapped to their corresponding default scrolling animation + mappings = { + "", + "", + "", + "", + "", + "", + "zt", + "zz", + "zb", + }, + hide_cursor = true, -- Hide cursor while scrolling + stop_eof = true, -- Stop at when scrolling downwards + use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope + respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file + cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further + easing_function = nil, -- Default easing function + pre_hook = nil, -- Function to run before the scrolling animation starts + post_hook = nil, -- Function to run after the scrolling animation ends + }) +end diff --git a/lua/modules/configs/ui/nord.lua b/lua/modules/configs/ui/nord.lua new file mode 100644 index 000000000..522d3f7c0 --- /dev/null +++ b/lua/modules/configs/ui/nord.lua @@ -0,0 +1,8 @@ +return function() + vim.g.nord_contrast = true + vim.g.nord_borders = false + vim.g.nord_cursorline_transparent = true + vim.g.nord_disable_background = false + vim.g.nord_enable_sidebar_background = true + vim.g.nord_italic = true +end diff --git a/lua/modules/configs/ui/notify.lua b/lua/modules/configs/ui/notify.lua new file mode 100644 index 000000000..7257fee75 --- /dev/null +++ b/lua/modules/configs/ui/notify.lua @@ -0,0 +1,38 @@ +return function() + local notify = require("notify") + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics"), + ui = require("modules.utils.icons").get("ui"), + } + + notify.setup({ + ---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" } + stages = "slide", + ---@usage Function called when a new window is opened, use for changing win settings/config + on_open = nil, + ---@usage Function called when a window is closed + on_close = nil, + ---@usage timeout for notifications in ms, default 5000 + timeout = 2000, + -- @usage User render fps value + fps = 30, + -- Render function for notifications. See notify-render() + render = "default", + ---@usage highlight behind the window for stages that change opacity + background_colour = "Normal", + ---@usage minimum width for notification windows + minimum_width = 50, + ---@usage notifications with level lower than this would be ignored. [ERROR > WARN > INFO > DEBUG > TRACE] + level = "TRACE", + ---@usage Icons for the different levels + icons = { + ERROR = icons.diagnostics.Error, + WARN = icons.diagnostics.Warning, + INFO = icons.diagnostics.Information, + DEBUG = icons.ui.Bug, + TRACE = icons.ui.Pencil, + }, + }) + + vim.notify = notify +end diff --git a/lua/modules/configs/ui/scrollview.lua b/lua/modules/configs/ui/scrollview.lua new file mode 100644 index 000000000..a4350ffd3 --- /dev/null +++ b/lua/modules/configs/ui/scrollview.lua @@ -0,0 +1,3 @@ +return function() + require("scrollview").setup({}) +end diff --git a/lua/modules/configs/ui/specs.lua b/lua/modules/configs/ui/specs.lua new file mode 100644 index 000000000..5626c2213 --- /dev/null +++ b/lua/modules/configs/ui/specs.lua @@ -0,0 +1,17 @@ +return function() + require("specs").setup({ + show_jumps = true, + min_jump = 10, + popup = { + delay_ms = 0, -- delay before popup displays + inc_ms = 10, -- time increments used for fade/resize effects + blend = 10, -- starting blend, between 0-100 (fully transparent), see :h winblend + width = 10, + winhl = "PMenu", + fader = require("specs").pulse_fader, + resizer = require("specs").shrink_resizer, + }, + ignore_filetypes = {}, + ignore_buftypes = { nofile = true }, + }) +end diff --git a/lua/modules/editor/config.lua b/lua/modules/editor/config.lua deleted file mode 100644 index 54b4f6dfd..000000000 --- a/lua/modules/editor/config.lua +++ /dev/null @@ -1,587 +0,0 @@ -local config = {} -local sessions_dir = vim.fn.stdpath("data") .. "/sessions/" -local use_ssh = require("core.settings").use_ssh - -function config.nvim_treesitter() - vim.api.nvim_set_option_value("foldmethod", "expr", {}) - vim.api.nvim_set_option_value("foldexpr", "nvim_treesitter#foldexpr()", {}) - - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "bash", - "c", - "cpp", - "lua", - "go", - "gomod", - "json", - "yaml", - "latex", - "make", - "markdown", - "markdown_inline", - "python", - "rust", - "html", - "javascript", - "typescript", - "vue", - "css", - }, - highlight = { - enable = true, - disable = function(ft, bufnr) - if vim.tbl_contains({ "vim" }, ft) then - return true - end - - local ok, is_large_file = pcall(vim.api.nvim_buf_get_var, bufnr, "bigfile_disable_treesitter") - return ok and is_large_file - end, - additional_vim_regex_highlighting = { "c", "cpp" }, - }, - textobjects = { - select = { - enable = true, - keymaps = { - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]["] = "@function.outer", - ["]m"] = "@class.outer", - }, - goto_next_end = { - ["]]"] = "@function.outer", - ["]M"] = "@class.outer", - }, - goto_previous_start = { - ["[["] = "@function.outer", - ["[m"] = "@class.outer", - }, - goto_previous_end = { - ["[]"] = "@function.outer", - ["[M"] = "@class.outer", - }, - }, - }, - rainbow = { - enable = true, - extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean - max_file_lines = 2000, -- Do not enable for files with more than 2000 lines, int - }, - context_commentstring = { enable = true, enable_autocmd = false }, - matchup = { enable = true }, - }) - require("nvim-treesitter.install").prefer_git = true - if use_ssh then - local parsers = require("nvim-treesitter.parsers").get_parser_configs() - for _, p in pairs(parsers) do - p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:") - end - end -end - -function config.illuminate() - require("illuminate").configure({ - providers = { - "lsp", - "treesitter", - "regex", - }, - delay = 100, - filetypes_denylist = { - "alpha", - "dashboard", - "DoomInfo", - "fugitive", - "help", - "norg", - "NvimTree", - "Outline", - "toggleterm", - }, - under_cursor = false, - }) -end - -function config.nvim_comment() - require("nvim_comment").setup({ - hook = function() - require("ts_context_commentstring.internal").update_commentstring() - end, - }) -end - -function config.hop() - require("hop").setup({ keys = "etovxqpdygfblzhckisuran" }) -end - -function config.autotag() - require("nvim-ts-autotag").setup({ - filetypes = { - "html", - "xml", - "javascript", - "typescriptreact", - "javascriptreact", - "vue", - }, - }) -end - -function config.nvim_colorizer() - require("colorizer").setup() -end - -function config.neoscroll() - require("neoscroll").setup({ - -- All these keys will be mapped to their corresponding default scrolling animation - mappings = { - "", - "", - "", - "", - "", - "", - "zt", - "zz", - "zb", - }, - hide_cursor = true, -- Hide cursor while scrolling - stop_eof = true, -- Stop at when scrolling downwards - use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope - respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file - cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further - easing_function = nil, -- Default easing function - pre_hook = nil, -- Function to run before the scrolling animation starts - post_hook = nil, -- Function to run after the scrolling animation ends - }) -end - -function config.auto_session() - local opts = { - log_level = "info", - auto_session_enable_last_session = true, - auto_session_root_dir = sessions_dir, - auto_session_enabled = true, - auto_save_enabled = true, - auto_restore_enabled = true, - auto_session_suppress_dirs = nil, - } - - require("auto-session").setup(opts) -end - -function config.toggleterm() - local colors = require("modules.utils").get_palette() - local floatborder_hl = require("modules.utils").hl_to_rgb("FloatBorder", false, colors.blue) - - require("toggleterm").setup({ - -- size can be a number or function which is passed the current terminal - size = function(term) - if term.direction == "horizontal" then - return 15 - elseif term.direction == "vertical" then - return vim.o.columns * 0.40 - end - end, - highlights = { - FloatBorder = { - guifg = floatborder_hl, - }, - }, - on_open = function() - -- Prevent infinite calls from freezing neovim. - -- Only set these options specific to this terminal buffer. - vim.api.nvim_set_option_value("foldmethod", "manual", { scope = "local" }) - vim.api.nvim_set_option_value("foldexpr", "0", { scope = "local" }) - end, - open_mapping = false, -- [[]], - hide_numbers = true, -- hide the number column in toggleterm buffers - shade_filetypes = {}, - shade_terminals = false, - shading_factor = "1", -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light - start_in_insert = true, - insert_mappings = true, -- whether or not the open mapping applies in insert mode - persist_size = true, - direction = "horizontal", - close_on_exit = true, -- close the terminal window when the process exits - shell = vim.o.shell, -- change the default shell - }) -end - -function config.dapui() - local icons = { - ui = require("modules.ui.icons").get("ui"), - dap = require("modules.ui.icons").get("dap"), - } - - require("dapui").setup({ - icons = { expanded = icons.ui.ArrowOpen, collapsed = icons.ui.ArrowClosed, current_frame = icons.ui.Indicator }, - mappings = { - -- Use a table to apply multiple mappings - expand = { "", "<2-LeftMouse>" }, - open = "o", - remove = "d", - edit = "e", - repl = "r", - }, - layouts = { - { - elements = { - -- Provide as ID strings or tables with "id" and "size" keys - { - id = "scopes", - size = 0.25, -- Can be float or integer > 1 - }, - { id = "breakpoints", size = 0.25 }, - { id = "stacks", size = 0.25 }, - { id = "watches", size = 0.25 }, - }, - size = 40, - position = "left", - }, - { elements = { "repl" }, size = 10, position = "bottom" }, - }, - -- Requires Nvim version >= 0.8 - controls = { - enabled = true, - -- Display controls in this session - element = "repl", - icons = { - pause = icons.dap.Pause, - play = icons.dap.Play, - step_into = icons.dap.StepInto, - step_over = icons.dap.StepOver, - step_out = icons.dap.StepOut, - step_back = icons.dap.StepBack, - run_last = icons.dap.RunLast, - terminate = icons.dap.Terminate, - }, - }, - floating = { - max_height = nil, - max_width = nil, - mappings = { close = { "q", "" } }, - }, - windows = { indent = 1 }, - }) -end - -function config.dap() - local icons = { dap = require("modules.ui.icons").get("dap") } - local colors = require("modules.utils").get_palette() - - local dap = require("dap") - local dapui = require("dapui") - - dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() - end - dap.listeners.after.event_terminated["dapui_config"] = function() - dapui.close() - end - dap.listeners.after.event_exited["dapui_config"] = function() - dapui.close() - end - - -- We need to override nvim-dap's default highlight groups, AFTER requiring nvim-dap for catppuccin. - vim.api.nvim_set_hl(0, "DapStopped", { fg = colors.green }) - - vim.fn.sign_define( - "DapBreakpoint", - { text = icons.dap.Breakpoint, texthl = "DapBreakpoint", linehl = "", numhl = "" } - ) - vim.fn.sign_define( - "DapBreakpointCondition", - { text = icons.dap.BreakpointCondition, texthl = "DapBreakpoint", linehl = "", numhl = "" } - ) - vim.fn.sign_define("DapStopped", { text = icons.dap.Stopped, texthl = "DapStopped", linehl = "", numhl = "" }) - vim.fn.sign_define( - "DapBreakpointRejected", - { text = icons.dap.BreakpointRejected, texthl = "DapBreakpoint", linehl = "", numhl = "" } - ) - vim.fn.sign_define("DapLogPoint", { text = icons.dap.LogPoint, texthl = "DapLogPoint", linehl = "", numhl = "" }) - - dap.adapters.lldb = { - type = "executable", - command = "/usr/bin/lldb-vscode", - name = "lldb", - } - dap.configurations.cpp = { - { - name = "Launch", - type = "lldb", - request = "launch", - args = function() - local input = vim.fn.input("Input args: ") - return vim.fn.split(input, " ", true) - end, - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - - -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: - -- - -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope - -- - -- Otherwise you might get the following error: - -- - -- Error on launch: Failed to attach to the target process - -- - -- But you should be aware of the implications: - -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html - runInTerminal = false, - }, - } - - dap.configurations.c = dap.configurations.cpp - dap.configurations.rust = dap.configurations.cpp - - dap.adapters.go = function(callback) - local stdout = vim.loop.new_pipe(false) - local handle - local pid_or_err - local port = 38697 - local opts = { - stdio = { nil, stdout }, - args = { "dap", "-l", "127.0.0.1:" .. port }, - detached = true, - } - handle, pid_or_err = vim.loop.spawn("dlv", opts, function(code) - stdout:close() - handle:close() - if code ~= 0 then - vim.notify( - string.format('"dlv" exited with code: %d, please check your configs for correctness.', code), - vim.log.levels.WARN, - { title = "[go] DAP Warning!" } - ) - end - end) - assert(handle, "Error running dlv: " .. tostring(pid_or_err)) - stdout:read_start(function(err, chunk) - assert(not err, err) - if chunk then - vim.schedule(function() - require("dap.repl").append(chunk) - end) - end - end) - -- Wait for delve to start - vim.defer_fn(function() - callback({ type = "server", host = "127.0.0.1", port = port }) - end, 100) - end - -- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md - dap.configurations.go = { - { type = "go", name = "Debug", request = "launch", program = "${file}" }, - { - type = "go", - name = "Debug test", -- configuration for debugging test files - request = "launch", - mode = "test", - program = "${file}", - }, -- works with go.mod packages and sub packages - { - type = "go", - name = "Debug test (go.mod)", - request = "launch", - mode = "test", - program = "./${relativeFileDirname}", - }, - } - - dap.adapters.python = { - type = "executable", - command = "/usr/bin/python", - args = { "-m", "debugpy.adapter" }, - } - dap.configurations.python = { - { - -- The first three options are required by nvim-dap - type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python` - request = "launch", - name = "Launch file", - -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options - - program = "${file}", -- This configuration will launch the current file if used. - pythonPath = function() - -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. - -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. - -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. - local cwd = vim.fn.getcwd() - if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then - return cwd .. "/venv/bin/python" - elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then - return cwd .. "/.venv/bin/python" - else - return "/usr/bin/python" - end - end, - }, - } -end - -function config.specs() - require("specs").setup({ - show_jumps = true, - min_jump = 10, - popup = { - delay_ms = 0, -- delay before popup displays - inc_ms = 10, -- time increments used for fade/resize effects - blend = 10, -- starting blend, between 0-100 (fully transparent), see :h winblend - width = 10, - winhl = "PMenu", - fader = require("specs").pulse_fader, - resizer = require("specs").shrink_resizer, - }, - ignore_filetypes = {}, - ignore_buftypes = { nofile = true }, - }) -end - -function config.imselect() - -- fcitx5 need a manual config - if vim.fn.executable("fcitx5-remote") == 1 then - vim.api.nvim_cmd({ - [[ let g:im_select_get_im_cmd = ["fcitx5-remote"] ]], - [[ let g:im_select_default = '1' ]], - [[ let g:ImSelectSetImCmd = { - \ key -> - \ key == 1 ? ['fcitx5-remote', '-c'] : - \ key == 2 ? ['fcitx5-remote', '-o'] : - \ key == 0 ? ['fcitx5-remote', '-c'] : - \ execute("throw 'invalid im key'") - \ } - ]], - }, { true, true, true }) - end -end - -function config.better_escape() - require("better_escape").setup({ - mapping = { "jk", "jj" }, -- a table with mappings to use - timeout = 500, -- the time in which the keys must be hit in ms. Use option timeoutlen by default - clear_empty_lines = false, -- clear line after escaping if there is only whitespace - keys = "", -- keys used for escaping, if it is a function will use the result everytime - -- example(recommended) - -- keys = function() - -- return vim.api.nvim_win_get_cursor(0)[2] > 1 and 'l' or '' - -- end, - }) -end - -function config.accelerated_jk() - require("accelerated-jk").setup({ - mode = "time_driven", - enable_deceleration = false, - acceleration_motions = {}, - acceleration_limit = 150, - acceleration_table = { 7, 12, 17, 21, 24, 26, 28, 30 }, - -- when 'enable_deceleration = true', 'deceleration_table = { {200, 3}, {300, 7}, {450, 11}, {600, 15}, {750, 21}, {900, 9999} }' - deceleration_table = { { 150, 9999 } }, - }) -end - -function config.clever_f() - vim.api.nvim_set_hl( - 0, - "CleverChar", - { underline = true, bold = true, fg = "Orange", bg = "NONE", ctermfg = "Red", ctermbg = "NONE" } - ) - vim.g.clever_f_mark_char_color = "CleverChar" - vim.g.clever_f_mark_direct_color = "CleverChar" - vim.g.clever_f_mark_direct = true - vim.g.clever_f_timeout_ms = 1500 -end - -function config.smartyank() - require("smartyank").setup({ - highlight = { - enabled = false, -- highlight yanked text - higroup = "IncSearch", -- highlight group of yanked text - timeout = 2000, -- timeout for clearing the highlight - }, - clipboard = { - enabled = true, - }, - tmux = { - enabled = true, - -- remove `-w` to disable copy to host client's clipboard - cmd = { "tmux", "set-buffer", "-w" }, - }, - osc52 = { - enabled = true, - escseq = "tmux", -- use tmux escape sequence, only enable if you're using remote tmux and have issues (see #4) - ssh_only = true, -- false to OSC52 yank also in local sessions - silent = false, -- true to disable the "n chars copied" echo - echo_hl = "Directory", -- highlight group of the OSC52 echo message - }, - }) -end - -function config.tabout() - require("tabout").setup({ - tabkey = "", -- key to trigger tabout, set to an empty string to disable - backwards_tabkey = "", -- key to trigger backwards tabout, set to an empty string to disable - act_as_tab = true, -- shift content if tab out is not possible - act_as_shift_tab = false, -- reverse shift content if tab out is not possible (if your keyboard/terminal supports ) - enable_backwards = true, - completion = true, -- if the tabkey is used in a completion pum - tabouts = { - { open = "'", close = "'" }, - { open = '"', close = '"' }, - { open = "`", close = "`" }, - { open = "(", close = ")" }, - { open = "[", close = "]" }, - { open = "{", close = "}" }, - }, - ignore_beginning = true, -- if the cursor is at the beginning of a filled element it will rather tab out than shift the content - exclude = {}, -- tabout will ignore these filetypes - }) -end - -function config.bigfile() - local ftdetect = { - name = "ftdetect", - opts = { defer = true }, - disable = function() - vim.api.nvim_set_option_value("filetype", "big_file_disabled_ft", { scope = "local" }) - end, - } - - local cmp = { - name = "nvim-cmp", - opts = { defer = true }, - disable = function() - require("cmp").setup.buffer({ enabled = false }) - end, - } - - require("bigfile").config({ - filesize = 1, -- size of the file in MiB - pattern = { "*" }, -- autocmd pattern - features = { -- features to disable - "indent_blankline", - "lsp", - "illuminate", - "treesitter", - "syntax", - "vimopts", - ftdetect, - cmp, - }, - }) -end - -return config diff --git a/lua/modules/completion/plugins.lua b/lua/modules/plugins/completion.lua similarity index 56% rename from lua/modules/completion/plugins.lua rename to lua/modules/plugins/completion.lua index 4f66ce9a3..b8fbefb69 100644 --- a/lua/modules/completion/plugins.lua +++ b/lua/modules/plugins/completion.lua @@ -1,24 +1,33 @@ local completion = {} -local conf = require("modules.completion.config") completion["neovim/nvim-lspconfig"] = { lazy = true, event = { "BufReadPost", "BufAdd", "BufNewFile" }, - config = conf.nvim_lsp, + config = require("completion.lsp"), dependencies = { { "creativenull/efmls-configs-nvim" }, { "williamboman/mason.nvim" }, { "williamboman/mason-lspconfig.nvim" }, - { "WhoIsSethDaniel/mason-tool-installer.nvim", config = conf.mason_install }, - { "glepnir/lspsaga.nvim", config = conf.lspsaga }, + { + "WhoIsSethDaniel/mason-tool-installer.nvim", + config = require("completion.mason-tool-installer"), + }, + { + "glepnir/lspsaga.nvim", + config = require("completion.lspsaga"), + }, { "ray-x/lsp_signature.nvim" }, }, } completion["hrsh7th/nvim-cmp"] = { - config = conf.cmp, event = "InsertEnter", + config = require("completion.cmp"), dependencies = { - { "L3MON4D3/LuaSnip", config = conf.luasnip, dependencies = { "rafamadriz/friendly-snippets" } }, + { + "L3MON4D3/LuaSnip", + dependencies = { "rafamadriz/friendly-snippets" }, + config = require("completion.luasnip"), + }, { "onsails/lspkind.nvim" }, { "lukas-reineke/cmp-under-comparator" }, { "saadparwaiz1/cmp_luasnip" }, @@ -29,20 +38,21 @@ completion["hrsh7th/nvim-cmp"] = { { "f3fora/cmp-spell" }, { "hrsh7th/cmp-buffer" }, { "kdheepak/cmp-latex-symbols" }, - { "windwp/nvim-autopairs", config = conf.autopairs }, - -- { "tzachar/cmp-tabnine", build = "./install.sh", config = conf.tabnine }, + { + "windwp/nvim-autopairs", + config = require("completion.autopairs"), + }, + -- { "tzachar/cmp-tabnine", build = "./install.sh", config = require("completion.tabnine") }, }, } completion["zbirenbaum/copilot.lua"] = { cmd = "Copilot", event = "InsertEnter", - config = conf.copilot, + config = require("completion.copilot"), dependencies = { { "zbirenbaum/copilot-cmp", - config = function() - require("copilot_cmp").setup({}) - end, + config = require("completion.copilot-cmp"), }, }, } diff --git a/lua/modules/editor/plugins.lua b/lua/modules/plugins/editor.lua similarity index 51% rename from lua/modules/editor/plugins.lua rename to lua/modules/plugins/editor.lua index 805c0ef45..5782af298 100644 --- a/lua/modules/editor/plugins.lua +++ b/lua/modules/plugins/editor.lua @@ -1,131 +1,94 @@ local editor = {} -local conf = require("modules.editor.config") -editor["junegunn/vim-easy-align"] = { - lazy = true, - cmd = "EasyAlign", -} -editor["RRethy/vim-illuminate"] = { +editor["rainbowhxch/accelerated-jk.nvim"] = { lazy = true, - event = "BufReadPost", - config = conf.illuminate, + event = "VeryLazy", + config = require("editor.accelerated-jk"), } -editor["terrortylor/nvim-comment"] = { +editor["rmagatti/auto-session"] = { lazy = true, - event = { "BufNewFile", "BufReadPre" }, - config = conf.nvim_comment, + cmd = { "SaveSession", "RestoreSession", "DeleteSession" }, + config = require("editor.auto-session"), } -editor["nvim-treesitter/nvim-treesitter"] = { +editor["max397574/better-escape.nvim"] = { lazy = true, - build = ":TSUpdate", event = "BufReadPost", - config = conf.nvim_treesitter, - dependencies = { - { "nvim-treesitter/nvim-treesitter-textobjects" }, - { "p00f/nvim-ts-rainbow" }, - { "JoosepAlviste/nvim-ts-context-commentstring" }, - { "mfussenegger/nvim-ts-hint-textobject" }, - { "andymass/vim-matchup" }, - { "windwp/nvim-ts-autotag", config = conf.autotag }, - { "NvChad/nvim-colorizer.lua", config = conf.nvim_colorizer }, - { "abecodes/tabout.nvim", config = conf.tabout }, - }, + config = require("editor.better-escape"), } -editor["rainbowhxch/accelerated-jk.nvim"] = { - lazy = true, - event = "VeryLazy", - config = conf.accelerated_jk, +editor["LunarVim/bigfile.nvim"] = { + lazy = false, + config = require("editor.bigfile"), + cond = require("core.settings").load_big_files_faster, } -editor["rhysd/clever-f.vim"] = { +editor["ojroques/nvim-bufdel"] = { lazy = true, event = "BufReadPost", - config = conf.clever_f, } -editor["romainl/vim-cool"] = { - lazy = true, - event = { "CursorMoved", "InsertEnter" }, -} -editor["phaazon/hop.nvim"] = { +editor["rhysd/clever-f.vim"] = { lazy = true, - branch = "v2", event = "BufReadPost", - config = conf.hop, + config = require("editor.cleverf"), } -editor["karb94/neoscroll.nvim"] = { +editor["terrortylor/nvim-comment"] = { lazy = true, - event = "BufReadPost", - config = conf.neoscroll, + event = { "BufNewFile", "BufReadPre" }, + config = require("editor.nvim-comment"), } -editor["akinsho/toggleterm.nvim"] = { +editor["sindrets/diffview.nvim"] = { lazy = true, - event = "UIEnter", - config = conf.toggleterm, + cmd = { "DiffviewOpen", "DiffviewClose" }, } -editor["rmagatti/auto-session"] = { +editor["junegunn/vim-easy-align"] = { lazy = true, - cmd = { "SaveSession", "RestoreSession", "DeleteSession" }, - config = conf.auto_session, + cmd = "EasyAlign", } -editor["max397574/better-escape.nvim"] = { +editor["phaazon/hop.nvim"] = { lazy = true, + branch = "v2", event = "BufReadPost", - config = conf.better_escape, + config = require("editor.hop"), } -editor["mfussenegger/nvim-dap"] = { - lazy = true, - cmd = { - "DapSetLogLevel", - "DapShowLog", - "DapContinue", - "DapToggleBreakpoint", - "DapToggleRepl", - "DapStepOver", - "DapStepInto", - "DapStepOut", - "DapTerminate", - }, - config = conf.dap, - dependencies = { - { "rcarriga/nvim-dap-ui", config = conf.dapui }, - }, -} -editor["tpope/vim-fugitive"] = { - lazy = true, - cmd = { "Git", "G" }, -} -editor["ojroques/nvim-bufdel"] = { +editor["RRethy/vim-illuminate"] = { lazy = true, event = "BufReadPost", -} -editor["edluffy/specs.nvim"] = { - lazy = true, - event = "CursorMoved", - config = conf.specs, -} -editor["sindrets/diffview.nvim"] = { - lazy = true, - cmd = { "DiffviewOpen", "DiffviewClose" }, + config = require("editor.vim-illuminate"), } editor["luukvbaal/stabilize.nvim"] = { lazy = true, event = "BufReadPost", } -editor["ibhagwan/smartyank.nvim"] = { +editor["romainl/vim-cool"] = { lazy = true, - event = "BufReadPost", - config = conf.smartyank, -} -editor["LunarVim/bigfile.nvim"] = { - lazy = false, - config = conf.bigfile, - cond = require("core.settings").load_big_files_faster, + event = { "CursorMoved", "InsertEnter" }, } --- only for fcitx5 user who uses non-English language during coding --- editor["brglng/vim-im-select"] = { --- lazy = true, --- event = "BufReadPost", --- config = conf.imselect, --- } +---------------------------------------------------------------------- +--  :treesitter related plugins -- +---------------------------------------------------------------------- +editor["nvim-treesitter/nvim-treesitter"] = { + lazy = true, + build = ":TSUpdate", + event = "BufReadPost", + config = require("editor.treesitter"), + dependencies = { + { "nvim-treesitter/nvim-treesitter-textobjects" }, + { "p00f/nvim-ts-rainbow" }, + { "JoosepAlviste/nvim-ts-context-commentstring" }, + { "mfussenegger/nvim-ts-hint-textobject" }, + { "andymass/vim-matchup" }, + { + "windwp/nvim-ts-autotag", + config = require("editor.autotag"), + }, + { + "NvChad/nvim-colorizer.lua", + config = require("editor.colorizer"), + }, + { + "abecodes/tabout.nvim", + config = require("editor.tabout"), + }, + }, +} return editor diff --git a/lua/modules/lang/plugins.lua b/lua/modules/plugins/lang.lua similarity index 70% rename from lua/modules/lang/plugins.lua rename to lua/modules/plugins/lang.lua index b954b4c05..04f2782c5 100644 --- a/lua/modules/lang/plugins.lua +++ b/lua/modules/plugins/lang.lua @@ -1,17 +1,16 @@ local lang = {} -local conf = require("modules.lang.config") lang["fatih/vim-go"] = { lazy = true, ft = "go", build = ":GoInstallBinaries", - config = conf.lang_go, + config = require("lang.vim-go"), } lang["simrat39/rust-tools.nvim"] = { lazy = true, ft = "rust", - config = conf.rust_tools, - dependencies = { { "nvim-lua/plenary.nvim" } }, + config = require("lang.rust-tools"), + dependencies = { "nvim-lua/plenary.nvim" }, } lang["iamcco/markdown-preview.nvim"] = { lazy = true, diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua new file mode 100644 index 000000000..545f1d91b --- /dev/null +++ b/lua/modules/plugins/tool.lua @@ -0,0 +1,124 @@ +local tool = {} + +tool["tpope/vim-fugitive"] = { + lazy = true, + cmd = { "Git", "G" }, +} +-- only for fcitx5 user who uses non-English language during coding +-- tool["brglng/vim-im-select"] = { +-- lazy = true, +-- event = "BufReadPost", +-- config = require("tool.imselect"), +-- } +tool["mrjones2014/legendary.nvim"] = { + lazy = true, + cmd = "Legendary", + config = require("tool.legendary"), + dependencies = { + { "kkharji/sqlite.lua" }, + { + "stevearc/dressing.nvim", + event = "VeryLazy", + config = require("tool.dressing"), + }, + -- Please don't remove which-key.nvim otherwise you need to set timeoutlen=300 at `lua/core/options.lua` + { + "folke/which-key.nvim", + event = "VeryLazy", + config = require("tool.which-key"), + }, + }, +} +tool["nvim-tree/nvim-tree.lua"] = { + lazy = true, + cmd = { + "NvimTreeToggle", + "NvimTreeOpen", + "NvimTreeFindFile", + "NvimTreeFindFileToggle", + "NvimTreeRefresh", + }, + config = require("tool.nvim-tree"), +} +tool["ibhagwan/smartyank.nvim"] = { + lazy = true, + event = "BufReadPost", + config = require("tool.smartyank"), +} +tool["michaelb/sniprun"] = { + lazy = true, + -- You need to cd to `~/.local/share/nvim/site/lazy/sniprun/` and execute `bash ./install.sh`, + -- if you encountered error about no executable sniprun found. + build = "bash ./install.sh", + cmd = { "SnipRun" }, + config = require("tool.sniprun"), +} +tool["akinsho/toggleterm.nvim"] = { + lazy = true, + event = "UIEnter", + config = require("tool.toggleterm"), +} +tool["folke/trouble.nvim"] = { + lazy = true, + cmd = { "Trouble", "TroubleToggle", "TroubleRefresh" }, + config = require("tool.trouble"), +} +tool["gelguy/wilder.nvim"] = { + lazy = true, + event = "CmdlineEnter", + config = require("tool.wilder"), + dependencies = { "romgrk/fzy-lua-native" }, +} + +---------------------------------------------------------------------- +-- Telescope Plugins -- +---------------------------------------------------------------------- +tool["nvim-telescope/telescope.nvim"] = { + lazy = true, + cmd = "Telescope", + config = require("tool.telescope"), + dependencies = { + { "nvim-tree/nvim-web-devicons" }, + { "nvim-lua/plenary.nvim" }, + { "nvim-lua/popup.nvim" }, + { "debugloop/telescope-undo.nvim" }, + { + "ahmedkhalf/project.nvim", + event = "BufReadPost", + config = require("tool.project"), + }, + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { "nvim-telescope/telescope-frecency.nvim", dependencies = { + { "kkharji/sqlite.lua" }, + } }, + { "jvgrootveld/telescope-zoxide" }, + { "nvim-telescope/telescope-live-grep-args.nvim" }, + }, +} + +---------------------------------------------------------------------- +-- DAP Plugins -- +---------------------------------------------------------------------- +tool["mfussenegger/nvim-dap"] = { + lazy = true, + cmd = { + "DapSetLogLevel", + "DapShowLog", + "DapContinue", + "DapToggleBreakpoint", + "DapToggleRepl", + "DapStepOver", + "DapStepInto", + "DapStepOut", + "DapTerminate", + }, + config = require("tool.dap"), + dependencies = { + { + "rcarriga/nvim-dap-ui", + config = require("tool.dap.dapui"), + }, + }, +} + +return tool diff --git a/lua/modules/ui/plugins.lua b/lua/modules/plugins/ui.lua similarity index 60% rename from lua/modules/ui/plugins.lua rename to lua/modules/plugins/ui.lua index de25fd9c6..106e2dba8 100644 --- a/lua/modules/ui/plugins.lua +++ b/lua/modules/plugins/ui.lua @@ -1,74 +1,72 @@ local ui = {} -local conf = require("modules.ui.config") -ui["shaunsingh/nord.nvim"] = { +ui["goolord/alpha-nvim"] = { lazy = true, - config = conf.nord, + event = "BufWinEnter", + config = require("ui.alpha"), } -ui["sainnhe/edge"] = { +ui["akinsho/bufferline.nvim"] = { lazy = true, - config = conf.edge, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, + config = require("ui.bufferline"), } ui["catppuccin/nvim"] = { lazy = false, name = "catppuccin", - config = conf.catppuccin, + config = require("ui.catppuccin"), } -ui["rcarriga/nvim-notify"] = { +ui["sainnhe/edge"] = { lazy = true, - event = "VeryLazy", - config = conf.notify, + config = require("ui.edge"), } -ui["zbirenbaum/neodim"] = { +ui["j-hui/fidget.nvim"] = { lazy = true, - event = "LspAttach", - config = conf.neodim, + event = "BufReadPost", + config = require("ui.fidget"), } -ui["nvim-lualine/lualine.nvim"] = { +ui["lewis6991/gitsigns.nvim"] = { lazy = true, - event = { "BufReadPost", "BufAdd", "BufNewFile" }, - config = conf.lualine, + event = { "BufReadPost", "BufNewFile" }, + config = require("ui.gitsigns"), } -ui["goolord/alpha-nvim"] = { +ui["lukas-reineke/indent-blankline.nvim"] = { lazy = true, - event = "BufWinEnter", - config = conf.alpha, + event = "BufReadPost", + config = require("ui.indent-blankline"), } -ui["nvim-tree/nvim-tree.lua"] = { +ui["nvim-lualine/lualine.nvim"] = { lazy = true, - cmd = { - "NvimTreeToggle", - "NvimTreeOpen", - "NvimTreeFindFile", - "NvimTreeFindFileToggle", - "NvimTreeRefresh", - }, - config = conf.nvim_tree, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, + config = require("ui.lualine"), } -ui["lewis6991/gitsigns.nvim"] = { +ui["zbirenbaum/neodim"] = { lazy = true, - event = { "BufReadPost", "BufNewFile" }, - config = conf.gitsigns, + event = "LspAttach", + config = require("ui.neodim"), } -ui["lukas-reineke/indent-blankline.nvim"] = { +ui["karb94/neoscroll.nvim"] = { lazy = true, event = "BufReadPost", - config = conf.indent_blankline, + config = require("ui.neoscroll"), } -ui["akinsho/bufferline.nvim"] = { +ui["shaunsingh/nord.nvim"] = { lazy = true, - event = { "BufReadPost", "BufAdd", "BufNewFile" }, - config = conf.nvim_bufferline, + config = require("ui.nord"), +} +ui["rcarriga/nvim-notify"] = { + lazy = true, + event = "VeryLazy", + config = require("ui.notify"), } ui["dstein64/nvim-scrollview"] = { lazy = true, event = "BufReadPost", - config = conf.scrollview, + config = require("ui.scrollview"), } -ui["j-hui/fidget.nvim"] = { +ui["edluffy/specs.nvim"] = { lazy = true, - event = "BufReadPost", - config = conf.fidget, + event = "CursorMoved", + config = require("ui.specs"), } return ui diff --git a/lua/modules/tools/config.lua b/lua/modules/tools/config.lua deleted file mode 100644 index ef9fe3c85..000000000 --- a/lua/modules/tools/config.lua +++ /dev/null @@ -1,439 +0,0 @@ -local config = {} - -function config.telescope() - local icons = { ui = require("modules.ui.icons").get("ui", true) } - local lga_actions = require("telescope-live-grep-args.actions") - - require("telescope").setup({ - defaults = { - initial_mode = "insert", - prompt_prefix = " " .. icons.ui.Telescope .. " ", - selection_caret = icons.ui.ChevronRight, - scroll_strategy = "limit", - results_title = false, - layout_strategy = "horizontal", - path_display = { "absolute" }, - file_ignore_patterns = { ".git/", ".cache", "%.class", "%.pdf", "%.mkv", "%.mp4", "%.zip" }, - layout_config = { - horizontal = { - preview_width = 0.5, - }, - }, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - file_sorter = require("telescope.sorters").get_fuzzy_file, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - }, - extensions = { - fzf = { - fuzzy = false, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = "smart_case", - }, - frecency = { - show_scores = true, - show_unindexed = true, - ignore_patterns = { "*.git/*", "*/tmp/*" }, - }, - live_grep_args = { - auto_quoting = true, -- enable/disable auto-quoting - -- define mappings, e.g. - mappings = { -- extend mappings - i = { - [""] = lga_actions.quote_prompt(), - [""] = lga_actions.quote_prompt({ postfix = " --iglob " }), - }, - }, - }, - undo = { - side_by_side = true, - layout_config = { - preview_height = 0.8, - }, - mappings = { -- this whole table is the default - i = { - -- IMPORTANT: Note that telescope-undo must be available when telescope is configured if - -- you want to use the following actions. This means installing as a dependency of - -- telescope in it's `requirements` and loading this extension from there instead of - -- having the separate plugin definition as outlined above. See issue #6. - [""] = require("telescope-undo.actions").yank_additions, - [""] = require("telescope-undo.actions").yank_deletions, - [""] = require("telescope-undo.actions").restore, - }, - }, - }, - }, - }) - - require("telescope").load_extension("notify") - require("telescope").load_extension("fzf") - require("telescope").load_extension("projects") - require("telescope").load_extension("zoxide") - require("telescope").load_extension("frecency") - require("telescope").load_extension("live_grep_args") - require("telescope").load_extension("undo") -end - -function config.project() - require("project_nvim").setup({ - manual_mode = false, - detection_methods = { "lsp", "pattern" }, - patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, - ignore_lsp = { "efm", "copilot" }, - exclude_dirs = {}, - show_hidden = false, - silent_chdir = true, - scope_chdir = "global", - datapath = vim.fn.stdpath("data"), - }) -end - -function config.trouble() - local icons = { - ui = require("modules.ui.icons").get("ui"), - diagnostics = require("modules.ui.icons").get("diagnostics"), - } - - require("trouble").setup({ - position = "bottom", -- position of the list can be: bottom, top, left, right - height = 10, -- height of the trouble list when position is top or bottom - width = 50, -- width of the list when position is left or right - icons = true, -- use devicons for filenames - mode = "document_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" - fold_open = icons.ui.ArrowOpen, -- icon used for open folds - fold_closed = icons.ui.ArrowClosed, -- icon used for closed folds - group = true, -- group results by file - padding = true, -- add an extra new line on top of the list - action_keys = { - -- key mappings for actions in the trouble list - -- map to {} to remove a mapping, for example: - -- close = {}, - close = "q", -- close the list - cancel = "", -- cancel the preview and get back to your last window / buffer / cursor - refresh = "r", -- manually refresh - jump = { "", "" }, -- jump to the diagnostic or open / close folds - open_split = { "" }, -- open buffer in new split - open_vsplit = { "" }, -- open buffer in new vsplit - open_tab = { "" }, -- open buffer in new tab - jump_close = { "o" }, -- jump to the diagnostic and close the list - toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode - toggle_preview = "P", -- toggle auto_preview - hover = "K", -- opens a small popup with the full multiline message - preview = "p", -- preview the diagnostic location - close_folds = { "zM", "zm" }, -- close all folds - open_folds = { "zR", "zr" }, -- open all folds - toggle_fold = { "zA", "za" }, -- toggle fold of current file - previous = "k", -- preview item - next = "j", -- next item - }, - indent_lines = true, -- add an indent guide below the fold icons - auto_open = false, -- automatically open the list when you have diagnostics - auto_close = false, -- automatically close the list when you have no diagnostics - auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window - auto_fold = false, -- automatically fold a file trouble list at creation - auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result - signs = { - -- icons / text used for a diagnostic - error = icons.diagnostics.Error_alt, - warning = icons.diagnostics.Warning_alt, - hint = icons.diagnostics.Hint_alt, - information = icons.diagnostics.Information_alt, - other = icons.diagnostics.Question_alt, - }, - use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client - }) -end - -function config.sniprun() - require("sniprun").setup({ - selected_interpreters = {}, -- " use those instead of the default for the current filetype - repl_enable = {}, -- " enable REPL-like behavior for the given interpreters - repl_disable = {}, -- " disable REPL-like behavior for the given interpreters - interpreter_options = {}, -- " intepreter-specific options, consult docs / :SnipInfo - -- " you can combo different display modes as desired - display = { - "TempFloatingWindowOk", -- display ok results in the floating window - "NvimNotifyErr", -- display err results with the nvim-notify plugin - -- "Classic", -- display results in the command line" - -- "VirtualText", -- display results in virtual text" - -- "LongTempFloatingWindow", -- display results in the long floating window - -- "Terminal" -- display results in a vertical split - -- "TerminalWithCode" -- display results and code history in a vertical split - }, - display_options = { - terminal_width = 45, - notification_timeout = 5000, - }, - -- " miscellaneous compatibility/adjustement settings - inline_messages = 0, -- " inline_message (0/1) is a one-line way to display messages - -- " to workaround sniprun not being able to display anything - borders = "single", -- " display borders around floating windows - -- " possible values are 'none', 'single', 'double', or 'shadow' - }) -end - -function config.wilder() - local wilder = require("wilder") - local colors = require("modules.utils").get_palette() - local icons = { ui = require("modules.ui.icons").get("ui") } - - wilder.setup({ modes = { ":", "/", "?" } }) - wilder.set_option("use_python_remote_plugin", 0) - wilder.set_option("pipeline", { - wilder.branch( - wilder.cmdline_pipeline({ use_python = 0, fuzzy = 1, fuzzy_filter = wilder.lua_fzy_filter() }), - wilder.vim_search_pipeline(), - { - wilder.check(function(_, x) - return x == "" - end), - wilder.history(), - wilder.result({ - draw = { - function(_, x) - return icons.ui.Calendar .. " " .. x - end, - }, - }), - } - ), - }) - - local match_hl = require("modules.utils").hl_to_rgb("String", false, colors.green) - - local popupmenu_renderer = wilder.popupmenu_renderer(wilder.popupmenu_border_theme({ - border = "rounded", - highlights = { - border = "Title", -- highlight to use for the border - accent = wilder.make_hl("WilderAccent", "Pmenu", { { a = 0 }, { a = 0 }, { foreground = match_hl } }), - }, - empty_message = wilder.popupmenu_empty_message_with_spinner(), - highlighter = wilder.lua_fzy_highlighter(), - left = { - " ", - wilder.popupmenu_devicons(), - wilder.popupmenu_buffer_flags({ - flags = " a + ", - icons = { ["+"] = icons.ui.Pencil, a = icons.ui.Indicator, h = icons.ui.File }, - }), - }, - right = { - " ", - wilder.popupmenu_scrollbar(), - }, - })) - local wildmenu_renderer = wilder.wildmenu_renderer({ - highlighter = wilder.lua_fzy_highlighter(), - apply_incsearch_fix = true, - }) - wilder.set_option( - "renderer", - wilder.renderer_mux({ - [":"] = popupmenu_renderer, - ["/"] = wildmenu_renderer, - substitute = wildmenu_renderer, - }) - ) -end - -function config.which_key() - local icons = { - ui = require("modules.ui.icons").get("ui"), - misc = require("modules.ui.icons").get("misc"), - } - - require("which-key").setup({ - plugins = { - presets = { - operators = false, - motions = false, - text_objects = false, - windows = false, - nav = false, - z = true, - g = true, - }, - }, - - icons = { - breadcrumb = icons.ui.Separator, - separator = icons.misc.Vbar, - group = icons.misc.Add, - }, - - window = { - border = "none", - position = "bottom", - margin = { 1, 0, 1, 0 }, - padding = { 1, 1, 1, 1 }, - winblend = 0, - }, - }) -end - -function config.legendary() - require("legendary").setup({ - which_key = { - auto_register = true, - do_binding = false, - }, - scratchpad = { - view = "float", - results_view = "float", - keep_contents = true, - }, - sort = { - -- sort most recently used item to the top - most_recent_first = true, - -- sort user-defined items before built-in items - user_items_first = true, - frecency = { - -- the directory to store the database in - db_root = string.format("%s/legendary/", vim.fn.stdpath("data")), - -- the maximum number of timestamps for a single item - -- to store in the database - max_timestamps = 10, - }, - }, - -- Directory used for caches - cache_path = string.format("%s/legendary/", vim.fn.stdpath("cache")), - -- Log level, one of 'trace', 'debug', 'info', 'warn', 'error', 'fatal' - log_level = "info", - }) - - require("which-key").register({ - [""] = { - b = { - name = "Bufferline commands", - d = "buffer: Sort by directory", - e = "buffer: Sort by extension", - }, - d = { - name = "Dap commands", - b = "debug: Set breakpoint with condition", - c = "debug: Run to cursor", - l = "debug: Run last", - o = "debug: Open repl", - }, - f = { - name = "Telescope commands", - p = "find: Project", - w = "find: Word", - r = "find: File by frecency", - e = "find: File by history", - c = "ui: Change color scheme", - z = "edit: Change current directory by zoxide", - f = "find: File under current work directory", - g = "find: File under current git directory", - n = "edit: New file", - b = "find: Buffer opened", - }, - h = { - name = "Gitsigns commands", - b = "git: Blame line", - p = "git: Preview hunk", - s = "git: Stage hunk", - u = "git: Undo stage hunk", - r = "git: Reset hunk", - R = "git: Reset buffer", - }, - l = { - name = "LSP commands", - i = "lsp: LSP Info", - r = "lsp: LSP Restart", - }, - n = { - name = "NvimTree commands", - f = "filetree: NvimTree find file", - r = "filetree: NvimTree refresh", - }, - p = { - name = "Package commands", - h = "package: Show", - s = "package: Sync", - i = "package: Install", - c = "package: Check", - d = "package: Debug", - l = "package: Log", - p = "package: Profile", - r = "package: Restore", - x = "package: Clean", - u = "package: Update", - }, - s = { - c = "lsp: Show cursor disgnostics", - l = "lsp: Show line disgnostics", - s = "sesson: Save session", - r = "sesson: Restore session", - d = "sesson: Delete session", - }, - t = { - name = "Trouble commands", - d = "lsp: Show document diagnostics", - w = "lsp: Show workspace diagnostics", - q = "lsp: Show quickfix list", - l = "lsp: Show loclist", - r = "lsp: Show lsp references", - }, - }, - ["g"] = { - a = "lsp: Code action", - d = "lsp: Preview definition", - D = "lsp: Goto definition", - h = "lsp: Show reference", - o = "lsp: Toggle outline", - r = "lsp: Rename in file range", - R = "lsp: Rename in project range", - s = "lsp: Signature help", - t = "lsp: Toggle trouble list", - b = "buffer: Buffer pick", - p = { - name = "git commands", - s = "git: Push", - l = "git: Pull", - }, - }, - [""] = "debug: Run/Continue", - [""] = "debug: Terminate debug session", - [""] = "debug: Toggle breakpoint", - [""] = "debug: Step into", - [""] = "debug: Step out", - [""] = "debug: Step over", - ["G"] = "git: Show fugitive", - ["g"] = "git: Show lazygit", - ["D"] = "git: Show diff", - ["D"] = "git: Close diff", - ["]g"] = "git: Goto next hunk", - ["[g"] = "git: Goto prev hunk", - ["g["] = "lsp: Goto prev diagnostic", - ["g]"] = "lsp: Goto next diagnostic", - ["ci"] = "lsp: Incoming calls", - ["co"] = "lsp: Outgoing calls", - ["w"] = "jump: Goto word", - ["j"] = "jump: Goto line", - ["k"] = "jump: Goto line", - ["c"] = "jump: Goto one char", - ["cc"] = "jump: Goto two chars", - ["o"] = "edit: Check spell", - ["u"] = "edit: Show undo history", - ["r"] = "tool: Code snip run", - [""] = "tool: Markdown preview", - }) -end - -function config.dressing() - require("dressing").setup({ - input = { - enabled = true, - }, - select = { - enabled = true, - backend = "telescope", - trim_prompt = true, - }, - }) -end - -return config diff --git a/lua/modules/tools/plugins.lua b/lua/modules/tools/plugins.lua deleted file mode 100644 index 9463f9bff..000000000 --- a/lua/modules/tools/plugins.lua +++ /dev/null @@ -1,53 +0,0 @@ -local tools = {} -local conf = require("modules.tools.config") - -tools["nvim-telescope/telescope.nvim"] = { - lazy = true, - cmd = "Telescope", - config = conf.telescope, - dependencies = { - { "nvim-tree/nvim-web-devicons" }, - { "nvim-lua/plenary.nvim" }, - { "nvim-lua/popup.nvim" }, - { "debugloop/telescope-undo.nvim" }, - { "ahmedkhalf/project.nvim", event = "BufReadPost", config = conf.project }, - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - { "nvim-telescope/telescope-frecency.nvim", dependencies = { - { "kkharji/sqlite.lua" }, - } }, - { "jvgrootveld/telescope-zoxide" }, - { "nvim-telescope/telescope-live-grep-args.nvim" }, - }, -} -tools["michaelb/sniprun"] = { - lazy = true, - -- You need to cd to `~/.local/share/nvim/site/lazy/sniprun/` and execute `bash ./install.sh`, - -- if you encountered error about no executable sniprun found. - build = "bash ./install.sh", - cmd = { "SnipRun" }, - config = conf.sniprun, -} -tools["folke/trouble.nvim"] = { - lazy = true, - cmd = { "Trouble", "TroubleToggle", "TroubleRefresh" }, - config = conf.trouble, -} -tools["gelguy/wilder.nvim"] = { - lazy = true, - event = "CmdlineEnter", - config = conf.wilder, - dependencies = { { "romgrk/fzy-lua-native" } }, -} -tools["mrjones2014/legendary.nvim"] = { - lazy = true, - cmd = "Legendary", - config = conf.legendary, - dependencies = { - { "kkharji/sqlite.lua" }, - { "stevearc/dressing.nvim", event = "VeryLazy", config = conf.dressing }, - -- Please don't remove which-key.nvim otherwise you need to set timeoutlen=300 at `lua/core/options.lua` - { "folke/which-key.nvim", event = "VeryLazy", config = conf.which_key }, - }, -} - -return tools diff --git a/lua/modules/ui/config.lua b/lua/modules/ui/config.lua deleted file mode 100644 index 9615fcd79..000000000 --- a/lua/modules/ui/config.lua +++ /dev/null @@ -1,991 +0,0 @@ -local config = {} - -function config.alpha() - local alpha = require("alpha") - local dashboard = require("alpha.themes.dashboard") - - dashboard.section.header.val = { - [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⣾⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⣿⣟⠻⣿⣿⣿⣿⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⣿⣿⡿⢫⣷⣿⣿⣿⣿⣿⣿⣿⣾⣯⣿⡿⢧⡚⢷⣌⣽⣿⣿⣿⣿⣿⣶⡌⣿⣿⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣇⣘⠿⢹⣿⣿⣿⣿⣿⣻⢿⣿⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⣿⣿⠀⢸⣿⣿⡇⣿⣿⣿⣿⣿⣿⣿⣿⡟⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣻⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⣿⡇⠀⣬⠏⣿⡇⢻⣿⣿⣿⣿⣿⣿⣿⣷⣼⣿⣿⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⣿⠀⠈⠁⠀⣿⡇⠘⡟⣿⣿⣿⣿⣿⣿⣿⣿⡏⠿⣿⣟⣿⣿⣿⣿⣿⣿⣿⣿⣇⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⡏⠀⠀⠐⠀⢻⣇⠀⠀⠹⣿⣿⣿⣿⣿⣿⣩⡶⠼⠟⠻⠞⣿⡈⠻⣟⢻⣿⣿⣿⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⢿⠀⡆⠀⠘⢿⢻⡿⣿⣧⣷⢣⣶⡃⢀⣾⡆⡋⣧⠙⢿⣿⣿⣟⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⡥⠂⡐⠀⠁⠑⣾⣿⣿⣾⣿⣿⣿⡿⣷⣷⣿⣧⣾⣿⣿⣿⣿⣿⣿⣿]], - [[⣿⣿⡿⣿⣍⡴⠆⠀⠀⠀⠀⠀⠀⠀⠀⣼⣄⣀⣷⡄⣙⢿⣿⣿⣿⣿⣯⣶⣿⣿⢟⣾⣿⣿⢡⣿⣿⣿⣿⣿]], - [[⣿⡏⣾⣿⣿⣿⣷⣦⠀⠀⠀⢀⡀⠀⠀⠠⣭⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⣡⣾⣿⣿⢏⣾⣿⣿⣿⣿⣿]], - [[⣿⣿⣿⣿⣿⣿⣿⣿⡴⠀⠀⠀⠀⠀⠠⠀⠰⣿⣿⣿⣷⣿⠿⠿⣿⣿⣭⡶⣫⠔⢻⢿⢇⣾⣿⣿⣿⣿⣿⣿]], - [[⣿⣿⣿⡿⢫⣽⠟⣋⠀⠀⠀⠀⣶⣦⠀⠀⠀⠈⠻⣿⣿⣿⣾⣿⣿⣿⣿⡿⣣⣿⣿⢸⣾⣿⣿⣿⣿⣿⣿⣿]], - [[⡿⠛⣹⣶⣶⣶⣾⣿⣷⣦⣤⣤⣀⣀⠀⠀⠀⠀⠀⠀⠉⠛⠻⢿⣿⡿⠫⠾⠿⠋⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], - [[⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣀⡆⣠⢀⣴⣏⡀⠀⠀⠀⠉⠀⠀⢀⣠⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], - [[⠿⠛⠛⠛⠛⠛⠛⠻⢿⣿⣿⣿⣿⣯⣟⠷⢷⣿⡿⠋⠀⠀⠀⠀⣵⡀⢠⡿⠋⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], - [[⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⢿⣿⣿⠂⠀⠀⠀⠀⠀⢀⣽⣿⣿⣿⣿⣿⣿⣿⣍⠛⠿⣿⣿⣿⣿⣿⣿]], - } - dashboard.section.header.opts.hl = "Type" - - local function button(sc, txt, leader_txt, keybind, keybind_opts) - local sc_after = sc:gsub("%s", ""):gsub(leader_txt, "") - - local opts = { - position = "center", - shortcut = sc, - cursor = 5, - width = 50, - align_shortcut = "right", - hl_shortcut = "Keyword", - } - - if nil == keybind then - keybind = sc_after - end - keybind_opts = vim.F.if_nil(keybind_opts, { noremap = true, silent = true, nowait = true }) - opts.keymap = { "n", sc_after, keybind, keybind_opts } - - local function on_press() - -- local key = vim.api.nvim_replace_termcodes(keybind .. '', true, false, true) - local key = vim.api.nvim_replace_termcodes(sc_after .. "", true, false, true) - vim.api.nvim_feedkeys(key, "t", false) - end - - return { - type = "button", - val = txt, - on_press = on_press, - opts = opts, - } - end - - local leader = " " - dashboard.section.buttons.val = { - button("space f c", " Scheme change", leader, "Telescope colorscheme"), - button("space f r", " File frecency", leader, "Telescope frecency"), - button("space f e", " File history", leader, "Telescope oldfiles"), - button("space f p", " Project find", leader, "Telescope projects"), - button("space f f", " File find", leader, "Telescope find_files"), - button("space f n", " File new", leader, "enew"), - button("space f w", " Word find", leader, "Telescope live_grep"), - } - dashboard.section.buttons.opts.hl = "String" - - local function footer() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return "  Have Fun with neovim" - .. "  v" - .. vim.version().major - .. "." - .. vim.version().minor - .. "." - .. vim.version().patch - .. "  " - .. stats.count - .. " plugins in " - .. ms - .. "ms" - end - - dashboard.section.footer.val = footer() - dashboard.section.footer.opts.hl = "Function" - - local head_butt_padding = 2 - local occu_height = #dashboard.section.header.val + 2 * #dashboard.section.buttons.val + head_butt_padding - local header_padding = math.max(0, math.ceil((vim.fn.winheight("$") - occu_height) * 0.25)) - local foot_butt_padding = 1 - - dashboard.config.layout = { - { type = "padding", val = header_padding }, - dashboard.section.header, - { type = "padding", val = head_butt_padding }, - dashboard.section.buttons, - { type = "padding", val = foot_butt_padding }, - dashboard.section.footer, - } - - alpha.setup(dashboard.opts) - - vim.api.nvim_create_autocmd("User", { - pattern = "LazyVimStarted", - callback = function() - dashboard.section.footer.val = footer() - pcall(vim.cmd.AlphaRedraw) - end, - }) -end - -function config.edge() - vim.g.edge_style = "aura" - vim.g.edge_enable_italic = 1 - vim.g.edge_disable_italic_comment = 1 - vim.g.edge_show_eob = 1 - vim.g.edge_better_performance = 1 - vim.g.edge_transparent_background = 1 -end - -function config.nord() - vim.g.nord_contrast = true - vim.g.nord_borders = false - vim.g.nord_cursorline_transparent = true - vim.g.nord_disable_background = false - vim.g.nord_enable_sidebar_background = true - vim.g.nord_italic = true -end - -function config.catppuccin() - local transparent_background = false -- Set background transparency here! - - require("catppuccin").setup({ - flavour = "mocha", -- Can be one of: latte, frappe, macchiato, mocha - background = { light = "latte", dark = "mocha" }, - dim_inactive = { - enabled = false, - -- Dim inactive splits/windows/buffers. - -- NOT recommended if you use old palette (a.k.a., mocha). - shade = "dark", - percentage = 0.15, - }, - transparent_background = transparent_background, - show_end_of_buffer = false, -- show the '~' characters after the end of buffers - term_colors = true, - compile_path = vim.fn.stdpath("cache") .. "/catppuccin", - styles = { - comments = { "italic" }, - properties = { "italic" }, - functions = { "italic", "bold" }, - keywords = { "italic" }, - operators = { "bold" }, - conditionals = { "bold" }, - loops = { "bold" }, - booleans = { "bold", "italic" }, - numbers = {}, - types = {}, - strings = {}, - variables = {}, - }, - integrations = { - treesitter = true, - native_lsp = { - enabled = true, - virtual_text = { - errors = { "italic" }, - hints = { "italic" }, - warnings = { "italic" }, - information = { "italic" }, - }, - underlines = { - errors = { "underline" }, - hints = { "underline" }, - warnings = { "underline" }, - information = { "underline" }, - }, - }, - aerial = false, - barbar = false, - beacon = false, - cmp = true, - coc_nvim = false, - dap = { enabled = true, enable_ui = true }, - dashboard = false, - fern = false, - fidget = true, - gitgutter = false, - gitsigns = true, - harpoon = false, - hop = true, - illuminate = true, - indent_blankline = { enabled = true, colored_indent_levels = false }, - leap = false, - lightspeed = false, - lsp_saga = true, - lsp_trouble = true, - markdown = true, - mason = true, - mini = false, - navic = { enabled = false }, - neogit = false, - neotest = false, - neotree = { enabled = false, show_root = true, transparent_panel = false }, - noice = false, - notify = true, - nvimtree = true, - overseer = false, - pounce = false, - semantic_tokens = false, - symbols_outline = false, - telekasten = false, - telescope = true, - treesitter_context = false, - ts_rainbow = true, - vim_sneak = false, - vimwiki = false, - which_key = true, - }, - color_overrides = { - mocha = { - rosewater = "#F5E0DC", - flamingo = "#F2CDCD", - mauve = "#DDB6F2", - pink = "#F5C2E7", - red = "#F28FAD", - maroon = "#E8A2AF", - peach = "#F8BD96", - yellow = "#FAE3B0", - green = "#ABE9B3", - blue = "#96CDFB", - sky = "#89DCEB", - teal = "#B5E8E0", - lavender = "#C9CBFF", - - text = "#D9E0EE", - subtext1 = "#BAC2DE", - subtext0 = "#A6ADC8", - overlay2 = "#C3BAC6", - overlay1 = "#988BA2", - overlay0 = "#6E6C7E", - surface2 = "#6E6C7E", - surface1 = "#575268", - surface0 = "#302D41", - - base = "#1E1E2E", - mantle = "#1A1826", - crust = "#161320", - }, - }, - highlight_overrides = { - mocha = function(cp) - return { - -- For base configs. - NormalFloat = { fg = cp.text, bg = transparent_background and cp.none or cp.base }, - CursorLineNr = { fg = cp.green }, - Search = { bg = cp.surface1, fg = cp.pink, style = { "bold" } }, - IncSearch = { bg = cp.pink, fg = cp.surface1 }, - Keyword = { fg = cp.pink }, - Type = { fg = cp.blue }, - Typedef = { fg = cp.yellow }, - StorageClass = { fg = cp.red, style = { "italic" } }, - - -- For native lsp configs. - DiagnosticVirtualTextError = { bg = cp.none }, - DiagnosticVirtualTextWarn = { bg = cp.none }, - DiagnosticVirtualTextInfo = { bg = cp.none }, - DiagnosticVirtualTextHint = { fg = cp.rosewater, bg = cp.none }, - - DiagnosticHint = { fg = cp.rosewater }, - LspDiagnosticsDefaultHint = { fg = cp.rosewater }, - LspDiagnosticsHint = { fg = cp.rosewater }, - LspDiagnosticsVirtualTextHint = { fg = cp.rosewater }, - LspDiagnosticsUnderlineHint = { sp = cp.rosewater }, - - -- For fidget. - FidgetTask = { bg = cp.none, fg = cp.surface2 }, - FidgetTitle = { fg = cp.blue, style = { "bold" } }, - - -- For trouble.nvim - TroubleNormal = { bg = cp.base }, - - -- For treesitter. - ["@field"] = { fg = cp.rosewater }, - ["@property"] = { fg = cp.yellow }, - - ["@include"] = { fg = cp.teal }, - -- ["@operator"] = { fg = cp.sky }, - ["@keyword.operator"] = { fg = cp.sky }, - ["@punctuation.special"] = { fg = cp.maroon }, - - -- ["@float"] = { fg = cp.peach }, - -- ["@number"] = { fg = cp.peach }, - -- ["@boolean"] = { fg = cp.peach }, - - ["@constructor"] = { fg = cp.lavender }, - -- ["@constant"] = { fg = cp.peach }, - -- ["@conditional"] = { fg = cp.mauve }, - -- ["@repeat"] = { fg = cp.mauve }, - ["@exception"] = { fg = cp.peach }, - - ["@constant.builtin"] = { fg = cp.lavender }, - -- ["@function.builtin"] = { fg = cp.peach, style = { "italic" } }, - -- ["@type.builtin"] = { fg = cp.yellow, style = { "italic" } }, - ["@type.qualifier"] = { link = "@keyword" }, - ["@variable.builtin"] = { fg = cp.red, style = { "italic" } }, - - -- ["@function"] = { fg = cp.blue }, - ["@function.macro"] = { fg = cp.red, style = {} }, - ["@parameter"] = { fg = cp.rosewater }, - ["@keyword"] = { fg = cp.red, style = { "italic" } }, - ["@keyword.function"] = { fg = cp.maroon }, - ["@keyword.return"] = { fg = cp.pink, style = {} }, - - -- ["@text.note"] = { fg = cp.base, bg = cp.blue }, - -- ["@text.warning"] = { fg = cp.base, bg = cp.yellow }, - -- ["@text.danger"] = { fg = cp.base, bg = cp.red }, - -- ["@constant.macro"] = { fg = cp.mauve }, - - -- ["@label"] = { fg = cp.blue }, - ["@method"] = { fg = cp.blue, style = { "italic" } }, - ["@namespace"] = { fg = cp.rosewater, style = {} }, - - ["@punctuation.delimiter"] = { fg = cp.teal }, - ["@punctuation.bracket"] = { fg = cp.overlay2 }, - -- ["@string"] = { fg = cp.green }, - -- ["@string.regex"] = { fg = cp.peach }, - ["@type"] = { fg = cp.yellow }, - ["@variable"] = { fg = cp.text }, - ["@tag.attribute"] = { fg = cp.mauve, style = { "italic" } }, - ["@tag"] = { fg = cp.peach }, - ["@tag.delimiter"] = { fg = cp.maroon }, - ["@text"] = { fg = cp.text }, - - -- ["@text.uri"] = { fg = cp.rosewater, style = { "italic", "underline" } }, - -- ["@text.literal"] = { fg = cp.teal, style = { "italic" } }, - -- ["@text.reference"] = { fg = cp.lavender, style = { "bold" } }, - -- ["@text.title"] = { fg = cp.blue, style = { "bold" } }, - -- ["@text.emphasis"] = { fg = cp.maroon, style = { "italic" } }, - -- ["@text.strong"] = { fg = cp.maroon, style = { "bold" } }, - -- ["@string.escape"] = { fg = cp.pink }, - - -- ["@property.toml"] = { fg = cp.blue }, - -- ["@field.yaml"] = { fg = cp.blue }, - - -- ["@label.json"] = { fg = cp.blue }, - - ["@function.builtin.bash"] = { fg = cp.red, style = { "italic" } }, - ["@parameter.bash"] = { fg = cp.yellow, style = { "italic" } }, - - ["@field.lua"] = { fg = cp.lavender }, - ["@constructor.lua"] = { fg = cp.flamingo }, - - ["@constant.java"] = { fg = cp.teal }, - - ["@property.typescript"] = { fg = cp.lavender, style = { "italic" } }, - -- ["@constructor.typescript"] = { fg = cp.lavender }, - - -- ["@constructor.tsx"] = { fg = cp.lavender }, - -- ["@tag.attribute.tsx"] = { fg = cp.mauve }, - - ["@type.css"] = { fg = cp.lavender }, - ["@property.css"] = { fg = cp.yellow, style = { "italic" } }, - - ["@type.builtin.c"] = { fg = cp.yellow, style = {} }, - - ["@property.cpp"] = { fg = cp.text }, - ["@type.builtin.cpp"] = { fg = cp.yellow, style = {} }, - - -- ["@symbol"] = { fg = cp.flamingo }, - } - end, - }, - }) -end - -function config.neodim() - local blend_color = require("modules.utils").hl_to_rgb("Normal", true) - - require("neodim").setup({ - alpha = 0.45, - blend_color = blend_color, - update_in_insert = { - enable = true, - delay = 100, - }, - hide = { - virtual_text = true, - signs = false, - underline = false, - }, - }) -end - -function config.notify() - local notify = require("notify") - local icons = { - diagnostics = require("modules.ui.icons").get("diagnostics"), - ui = require("modules.ui.icons").get("ui"), - } - - notify.setup({ - ---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" } - stages = "slide", - ---@usage Function called when a new window is opened, use for changing win settings/config - on_open = nil, - ---@usage Function called when a window is closed - on_close = nil, - ---@usage timeout for notifications in ms, default 5000 - timeout = 2000, - -- @usage User render fps value - fps = 30, - -- Render function for notifications. See notify-render() - render = "default", - ---@usage highlight behind the window for stages that change opacity - background_colour = "Normal", - ---@usage minimum width for notification windows - minimum_width = 50, - ---@usage notifications with level lower than this would be ignored. [ERROR > WARN > INFO > DEBUG > TRACE] - level = "TRACE", - ---@usage Icons for the different levels - icons = { - ERROR = icons.diagnostics.Error, - WARN = icons.diagnostics.Warning, - INFO = icons.diagnostics.Information, - DEBUG = icons.ui.Bug, - TRACE = icons.ui.Pencil, - }, - }) - - vim.notify = notify -end - -function config.lualine() - local colors = require("modules.utils").get_palette() - local icons = { - diagnostics = require("modules.ui.icons").get("diagnostics", true), - misc = require("modules.ui.icons").get("misc", true), - ui = require("modules.ui.icons").get("ui", true), - } - - local function escape_status() - local ok, m = pcall(require, "better_escape") - return ok and m.waiting and icons.misc.EscapeST or "" - end - - local _cache = { context = "", bufnr = -1 } - local function lspsaga_symbols() - local exclude = { - ["terminal"] = true, - ["toggleterm"] = true, - ["prompt"] = true, - ["NvimTree"] = true, - ["help"] = true, - } - if vim.api.nvim_win_get_config(0).zindex or exclude[vim.bo.filetype] then - return "" -- Excluded filetypes - else - local currbuf = vim.api.nvim_get_current_buf() - local ok, lspsaga = pcall(require, "lspsaga.symbolwinbar") - if ok and lspsaga:get_winbar() ~= nil then - _cache.context = lspsaga:get_winbar() - _cache.bufnr = currbuf - elseif _cache.bufnr ~= currbuf then - _cache.context = "" -- Reset [invalid] cache (usually from another buffer) - end - - return _cache.context - end - end - - local function diff_source() - local gitsigns = vim.b.gitsigns_status_dict - if gitsigns then - return { - added = gitsigns.added, - modified = gitsigns.changed, - removed = gitsigns.removed, - } - end - end - - local function get_cwd() - local cwd = vim.fn.getcwd() - local is_windows = require("core.global").is_windows - if not is_windows then - local home = require("core.global").home - if cwd:find(home, 1, true) == 1 then - cwd = "~" .. cwd:sub(#home + 1) - end - end - return icons.ui.RootFolderOpened .. cwd - end - - local mini_sections = { - lualine_a = { "filetype" }, - lualine_b = {}, - lualine_c = {}, - lualine_x = {}, - lualine_y = {}, - lualine_z = {}, - } - local outline = { - sections = mini_sections, - filetypes = { "lspsagaoutline" }, - } - local diffview = { - sections = mini_sections, - filetypes = { "DiffviewFiles" }, - } - - local function python_venv() - local function env_cleanup(venv) - if string.find(venv, "/") then - local final_venv = venv - for w in venv:gmatch("([^/]+)") do - final_venv = w - end - venv = final_venv - end - return venv - end - - if vim.bo.filetype == "python" then - local venv = os.getenv("CONDA_DEFAULT_ENV") - if venv then - return string.format("%s", env_cleanup(venv)) - end - venv = os.getenv("VIRTUAL_ENV") - if venv then - return string.format("%s", env_cleanup(venv)) - end - end - return "" - end - - require("lualine").setup({ - options = { - icons_enabled = true, - theme = "catppuccin", - disabled_filetypes = {}, - component_separators = "|", - section_separators = { left = "", right = "" }, - }, - sections = { - lualine_a = { { "mode" } }, - lualine_b = { { "branch" }, { "diff", source = diff_source } }, - lualine_c = { lspsaga_symbols }, - lualine_x = { - { escape_status }, - { - "diagnostics", - sources = { "nvim_diagnostic" }, - symbols = { - error = icons.diagnostics.Error, - warn = icons.diagnostics.Warning, - info = icons.diagnostics.Information, - }, - }, - { get_cwd }, - }, - lualine_y = { - { "filetype", colored = true, icon_only = true }, - { python_venv }, - { "encoding" }, - { - "fileformat", - icons_enabled = true, - symbols = { - unix = "LF", - dos = "CRLF", - mac = "CR", - }, - }, - }, - lualine_z = { "progress", "location" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { "filename" }, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, - }, - tabline = {}, - extensions = { - "quickfix", - "nvim-tree", - "nvim-dap-ui", - "toggleterm", - "fugitive", - outline, - diffview, - }, - }) - - -- Properly set background color for lspsaga - local winbar_bg = require("modules.utils").hl_to_rgb("StatusLine", true, colors.mantle) - for _, hlGroup in pairs(require("lspsaga.lspkind").get_kind()) do - require("modules.utils").extend_hl("LspSagaWinbar" .. hlGroup[1], { bg = winbar_bg }) - end - require("modules.utils").extend_hl("LspSagaWinbarSep", { bg = winbar_bg }) -end - -function config.nvim_tree() - local icons = { - diagnostics = require("modules.ui.icons").get("diagnostics"), - documents = require("modules.ui.icons").get("documents"), - git = require("modules.ui.icons").get("git"), - ui = require("modules.ui.icons").get("ui"), - } - - require("nvim-tree").setup({ - create_in_closed_folder = false, - respect_buf_cwd = false, - auto_reload_on_write = true, - disable_netrw = false, - hijack_cursor = true, - hijack_netrw = true, - hijack_unnamed_buffer_when_opening = true, - ignore_buffer_on_setup = false, - open_on_setup = false, - open_on_setup_file = false, - open_on_tab = false, - sort_by = "name", - sync_root_with_cwd = true, - view = { - adaptive_size = false, - centralize_selection = false, - width = 30, - side = "left", - preserve_window_proportions = false, - number = false, - relativenumber = false, - signcolumn = "yes", - hide_root_folder = false, - float = { - enable = false, - open_win_config = { - relative = "editor", - border = "rounded", - width = 30, - height = 30, - row = 1, - col = 1, - }, - }, - }, - renderer = { - add_trailing = false, - group_empty = true, - highlight_git = false, - full_name = false, - highlight_opened_files = "none", - special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md", "CMakeLists.txt" }, - symlink_destination = true, - indent_markers = { - enable = true, - icons = { - corner = "└ ", - edge = "│ ", - item = "│ ", - none = " ", - }, - }, - root_folder_label = ":.:s?.*?/..?", - icons = { - webdev_colors = true, - git_placement = "before", - show = { - file = true, - folder = true, - folder_arrow = false, - git = true, - }, - padding = " ", - symlink_arrow = "  ", - glyphs = { - default = icons.documents.Default, -- - symlink = icons.documents.Symlink, -- - bookmark = icons.ui.Bookmark, - git = { - unstaged = icons.git.Mod_alt, - staged = icons.git.Add, -- - unmerged = icons.git.Unmerged, - renamed = icons.git.Rename, -- - untracked = icons.git.Untracked, -- "ﲉ" - deleted = icons.git.Remove, -- - ignored = icons.git.Ignore, --◌ - }, - folder = { - -- arrow_open = "", - -- arrow_closed = "", - arrow_open = "", - arrow_closed = "", - default = icons.ui.Folder, - open = icons.ui.FolderOpen, - empty = icons.ui.EmptyFolder, - empty_open = icons.ui.EmptyFolderOpen, - symlink = icons.ui.SymlinkFolder, - symlink_open = icons.ui.FolderOpen, - }, - }, - }, - }, - hijack_directories = { - enable = true, - auto_open = true, - }, - update_focused_file = { - enable = true, - update_root = true, - ignore_list = {}, - }, - ignore_ft_on_setup = {}, - filters = { - dotfiles = false, - custom = { ".DS_Store" }, - exclude = {}, - }, - actions = { - use_system_clipboard = true, - change_dir = { - enable = true, - global = false, - }, - open_file = { - quit_on_open = false, - resize_window = false, - window_picker = { - enable = true, - chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", - exclude = { - filetype = { "notify", "qf", "diff", "fugitive", "fugitiveblame" }, - buftype = { "terminal", "help" }, - }, - }, - }, - remove_file = { - close_window = true, - }, - }, - diagnostics = { - enable = false, - show_on_dirs = false, - debounce_delay = 50, - icons = { - hint = icons.diagnostics.Hint_alt, - info = icons.diagnostics.Information_alt, - warning = icons.diagnostics.Warning_alt, - error = icons.diagnostics.Error_alt, - }, - }, - filesystem_watchers = { - enable = true, - debounce_delay = 50, - }, - git = { - enable = true, - ignore = true, - show_on_dirs = true, - timeout = 400, - }, - trash = { - cmd = "gio trash", - require_confirm = true, - }, - live_filter = { - prefix = "[FILTER]: ", - always_show_folders = true, - }, - log = { - enable = false, - truncate = false, - types = { - all = false, - config = false, - copy_paste = false, - dev = false, - diagnostics = false, - git = false, - profile = false, - watcher = false, - }, - }, - }) -end - -function config.nvim_bufferline() - local icons = { ui = require("modules.ui.icons").get("ui") } - - local opts = { - options = { - number = nil, - modified_icon = icons.ui.Modified, - buffer_close_icon = icons.ui.Close, - left_trunc_marker = icons.ui.Left, - right_trunc_marker = icons.ui.Right, - max_name_length = 14, - max_prefix_length = 13, - tab_size = 20, - show_buffer_close_icons = true, - show_buffer_icons = true, - show_tab_indicators = true, - diagnostics = "nvim_lsp", - always_show_bufferline = true, - separator_style = "thin", - offsets = { - { - filetype = "NvimTree", - text = "File Explorer", - text_align = "center", - padding = 1, - }, - { - filetype = "lspsagaoutline", - text = "Lspsaga Outline", - text_align = "center", - padding = 1, - }, - }, - diagnostics_indicator = function(count) - return "(" .. count .. ")" - end, - }, - -- Change bufferline's highlights here! See `:h bufferline-highlights` for detailed explanation. - -- Note: If you use catppuccin then modify the colors below! - highlights = {}, - } - - if vim.g.colors_name == "catppuccin" then - local cp = require("modules.utils").get_palette() -- Get the palette. - - local catppuccin_hl_overwrite = { - highlights = require("catppuccin.groups.integrations.bufferline").get({ - styles = { "italic", "bold" }, - custom = { - mocha = { - -- Hint - hint = { fg = cp.rosewater }, - hint_visible = { fg = cp.rosewater }, - hint_selected = { fg = cp.rosewater }, - hint_diagnostic = { fg = cp.rosewater }, - hint_diagnostic_visible = { fg = cp.rosewater }, - hint_diagnostic_selected = { fg = cp.rosewater }, - }, - }, - }), - } - - opts = vim.tbl_deep_extend("force", opts, catppuccin_hl_overwrite) - end - - require("bufferline").setup(opts) -end - -function config.gitsigns() - require("gitsigns").setup({ - signs = { - add = { - hl = "GitSignsAdd", - text = "│", - numhl = "GitSignsAddNr", - linehl = "GitSignsAddLn", - }, - change = { - hl = "GitSignsChange", - text = "│", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - delete = { - hl = "GitSignsDelete", - text = "_", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - topdelete = { - hl = "GitSignsDelete", - text = "‾", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - changedelete = { - hl = "GitSignsChange", - text = "~", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - }, - keymaps = { - -- Default keymap options - noremap = true, - buffer = true, - ["n ]g"] = { - expr = true, - "&diff ? ']g' : 'lua require\"gitsigns\".next_hunk()'", - }, - ["n [g"] = { - expr = true, - "&diff ? '[g' : 'lua require\"gitsigns\".prev_hunk()'", - }, - ["n hs"] = 'lua require"gitsigns".stage_hunk()', - ["v hs"] = 'lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})', - ["n hu"] = 'lua require"gitsigns".undo_stage_hunk()', - ["n hr"] = 'lua require"gitsigns".reset_hunk()', - ["v hr"] = 'lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})', - ["n hR"] = 'lua require"gitsigns".reset_buffer()', - ["n hp"] = 'lua require"gitsigns".preview_hunk()', - ["n hb"] = 'lua require"gitsigns".blame_line({full=true})', - -- Text objects - ["o ih"] = ':lua require"gitsigns".text_object()', - ["x ih"] = ':lua require"gitsigns".text_object()', - }, - watch_gitdir = { interval = 1000, follow_files = true }, - current_line_blame = true, - current_line_blame_opts = { delay = 1000, virtual_text_pos = "eol" }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - word_diff = false, - diff_opts = { internal = true }, - }) -end - -function config.indent_blankline() - require("indent_blankline").setup({ - char = "│", - show_first_indent_level = true, - filetype_exclude = { - "startify", - "dashboard", - "dotooagenda", - "log", - "fugitive", - "gitcommit", - "vimwiki", - "markdown", - "json", - "txt", - "vista", - "help", - "todoist", - "NvimTree", - "peekaboo", - "git", - "TelescopePrompt", - "flutterToolsOutline", - "", -- for all buffers without a file type - }, - buftype_exclude = { "terminal", "nofile" }, - show_trailing_blankline_indent = false, - show_current_context = true, - context_patterns = { - "class", - "function", - "method", - "block", - "list_literal", - "selector", - "^if", - "^table", - "if_statement", - "while", - "for", - "type", - "var", - "import", - }, - space_char_blankline = " ", - }) -end - -function config.scrollview() - require("scrollview").setup({}) -end - -function config.fidget() - require("fidget").setup({ - window = { blend = 0 }, - }) -end - -return config diff --git a/lua/modules/ui/icons.lua b/lua/modules/utils/icons.lua similarity index 100% rename from lua/modules/ui/icons.lua rename to lua/modules/utils/icons.lua diff --git a/lua/modules/utils/init.lua b/lua/modules/utils/init.lua index 20a5e1388..db4c8dfee 100644 --- a/lua/modules/utils/init.lua +++ b/lua/modules/utils/init.lua @@ -74,17 +74,6 @@ local function init_palette() return palette end ----Generate universal highlight groups ----@param overwrite palette? @The color to be overwritten | highest priority ----@return palette -function M.get_palette(overwrite) - if not overwrite then - return init_palette() - else - return vim.tbl_extend("force", init_palette(), overwrite) - end -end - ---@param c string @The color in hexadecimal. local function hexToRgb(c) c = string.lower(c) @@ -134,6 +123,7 @@ end ---@param background string @The background color to blend with ---@param alpha number|string @Number between 0 and 1 for blending amount. function M.blend(foreground, background, alpha) + ---@diagnostic disable-next-line: cast-local-type alpha = type(alpha) == "string" and (tonumber(alpha, 16) / 0xff) or alpha local bg = hexToRgb(background) local fg = hexToRgb(foreground) @@ -182,6 +172,17 @@ function M.extend_hl(name, def) vim.api.nvim_set_hl(0, name, combined_def) end +---Generate universal highlight groups +---@param overwrite palette? @The color to be overwritten | highest priority +---@return palette +function M.get_palette(overwrite) + if not overwrite then + return init_palette() + else + return vim.tbl_extend("force", init_palette(), overwrite) + end +end + ---Convert number (0/1) to boolean ---@param value number @The value to check ---@return boolean|nil @Returns nil if failed diff --git a/install/install.ps1 b/scripts/install.ps1 similarity index 98% rename from install/install.ps1 rename to scripts/install.ps1 index 30ee3caff..94c34d16f 100644 --- a/install/install.ps1 +++ b/scripts/install.ps1 @@ -373,6 +373,8 @@ You must install Git before installing this Nvim config. See: } prompt -Msg "Spawning neovim and fetching plugins... (You'll be redirected shortly)" + prompt -Msg 'To make sqlite work with lua, manually grab the dlls from "https://www.sqlite.org/download.html" and' + prompt -Msg ' replace vim.g.sqlite_clib_path with your path at the bottom of `lua/core/options.lua`' prompt -Msg 'If lazy.nvim failed to fetch any plugin(s), maunally execute `:Lazy sync` until everything is up-to-date.' Write-Host @' diff --git a/install/install.sh b/scripts/install.sh old mode 100755 new mode 100644 similarity index 100% rename from install/install.sh rename to scripts/install.sh diff --git a/my-snippets/package.json b/snips/package.json similarity index 99% rename from my-snippets/package.json rename to snips/package.json index 5aa630d5c..8ff8b639d 100644 --- a/my-snippets/package.json +++ b/snips/package.json @@ -1,5 +1,5 @@ { - "name": "my-snippets", + "name": "snips", "engines": { "vscode": "^1.11.0" }, diff --git a/my-snippets/snippets/c.json b/snips/snippets/c.json similarity index 100% rename from my-snippets/snippets/c.json rename to snips/snippets/c.json diff --git a/my-snippets/snippets/cpp.json b/snips/snippets/cpp.json similarity index 100% rename from my-snippets/snippets/cpp.json rename to snips/snippets/cpp.json diff --git a/my-snippets/snippets/go.json b/snips/snippets/go.json similarity index 100% rename from my-snippets/snippets/go.json rename to snips/snippets/go.json