From b3530d7c4a102935fa26498a160ee1dc6c1e9c03 Mon Sep 17 00:00:00 2001 From: delta Date: Fri, 4 Jul 2025 00:38:29 +0200 Subject: :3 --- .config/nvim/lua/autocmd.lua | 34 ++ .config/nvim/lua/binds.lua | 54 +++ .config/nvim/lua/cmds.lua | 20 + .config/nvim/lua/dash.lua | 147 +++++++ .config/nvim/lua/icons.lua | 45 ++ .../color_converter/lua/color_converter.lua | 14 + .../lua/local_plugins/color_converter/lua/ui.lua | 47 ++ .config/nvim/lua/options.lua | 35 +- .config/nvim/lua/plugins.lua | 83 ---- .config/nvim/lua/plugins/coding.lua | 150 +++++++ .config/nvim/lua/plugins/colorscheme.lua | 57 +++ .config/nvim/lua/plugins/editor.lua | 24 ++ .config/nvim/lua/plugins/lsp.lua | 254 +++++++++++ .config/nvim/lua/plugins/ui.lua | 477 +++++++++++++++++++++ .config/nvim/lua/plugins/utils.lua | 4 + 15 files changed, 1347 insertions(+), 98 deletions(-) create mode 100644 .config/nvim/lua/autocmd.lua create mode 100644 .config/nvim/lua/binds.lua create mode 100644 .config/nvim/lua/cmds.lua create mode 100644 .config/nvim/lua/dash.lua create mode 100644 .config/nvim/lua/icons.lua create mode 100644 .config/nvim/lua/local_plugins/color_converter/lua/color_converter.lua create mode 100644 .config/nvim/lua/local_plugins/color_converter/lua/ui.lua delete mode 100644 .config/nvim/lua/plugins.lua create mode 100644 .config/nvim/lua/plugins/coding.lua create mode 100644 .config/nvim/lua/plugins/colorscheme.lua create mode 100644 .config/nvim/lua/plugins/editor.lua create mode 100644 .config/nvim/lua/plugins/lsp.lua create mode 100644 .config/nvim/lua/plugins/ui.lua create mode 100644 .config/nvim/lua/plugins/utils.lua (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/autocmd.lua b/.config/nvim/lua/autocmd.lua new file mode 100644 index 0000000..f13e2e9 --- /dev/null +++ b/.config/nvim/lua/autocmd.lua @@ -0,0 +1,34 @@ +local group = vim.api.nvim_create_augroup("PrismiteNvim", { clear = true }) +vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { + group = group, + callback = function() + if require("nvim-tree.utils").is_nvim_tree_buf() then + vim.cmd "stopinsert" + end + end, +}) + +-- By https://github.com/marvinth01, taken from https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close#marvinth01 +vim.api.nvim_create_autocmd("QuitPre", { + group = group, + callback = function() + local tree_wins = {} + local floating_wins = {} + local wins = vim.api.nvim_list_wins() + for _, w in ipairs(wins) do + local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) + if bufname:match "NvimTree_" ~= nil then + table.insert(tree_wins, w) + end + if vim.api.nvim_win_get_config(w).relative ~= "" then + table.insert(floating_wins, w) + end + end + if 1 == #wins - #floating_wins - #tree_wins then + -- Should quit, so we close all invalid windows. + for _, w in ipairs(tree_wins) do + vim.api.nvim_win_close(w, true) + end + end + end, +}) diff --git a/.config/nvim/lua/binds.lua b/.config/nvim/lua/binds.lua new file mode 100644 index 0000000..55da905 --- /dev/null +++ b/.config/nvim/lua/binds.lua @@ -0,0 +1,54 @@ +local map = vim.keymap.set +-- local color_converter = require "color_converter" + +-- toggle nvim-tree +map("n", "t", "NvimTreeToggle") +-- toggle trouble +map("n", "e", "TroubleToggle") +-- undo +map("n", "U", "") + +map("c", "", function() + if vim.fn.pumvisible() == 1 then + return "" + end + return "" +end, { expr = true }) + +map("n", "H", "5h") +map("n", "J", "5j") +map("n", "K", "5k") +map("n", "L", "5l") + +-- disable arrow keys +map("n", "", "") +map("n", "", "") +map("n", "", "") +map("n", "", "") + +map("i", "", "") +map("i", "", "") +map("i", "", "") +map("i", "", "") + +map("n", "h", vim.lsp.buf.hover) +map("n", "gd", vim.lsp.buf.definition) + +map("n", "bp", function() + require('cokeline.mappings').pick("focus") +end, { desc = "Pick a buffer to focus" }) +map("n", "bq", function() + require('cokeline.mappings').pick("close") +end, { desc = "Pick a buffer to close" }) +map("n", "p", function () + require("cokeline.mappings").by_step("switch", -1) +end, { silent = true }) +map("n", "n", function () + require("cokeline.mappings").by_step("switch", 1) +end, { silent = true }) + + +-- local function setup_lsp_keys(_client, buffer) +-- map("d", vim.diagnostic.open_float, "Line diagnostics") +-- +-- end diff --git a/.config/nvim/lua/cmds.lua b/.config/nvim/lua/cmds.lua new file mode 100644 index 0000000..1426b99 --- /dev/null +++ b/.config/nvim/lua/cmds.lua @@ -0,0 +1,20 @@ +local M = {} +local fn = vim.fn + +local function cabbrev(input, replace) + local cmd = 'cnoreabbrev %s v:lua.cmds.command("%s", "%s")' + + vim.cmd(cmd:format(input, input, replace)) +end + +function M.command(cmd, match) + if fn.getcmdtype() == ":" and fn.getcmdline():match("^" .. cmd) then + return match + else + return cmd + end +end + +cabbrev("vs", "vert sb") + +return M diff --git a/.config/nvim/lua/dash.lua b/.config/nvim/lua/dash.lua new file mode 100644 index 0000000..fd9f03c --- /dev/null +++ b/.config/nvim/lua/dash.lua @@ -0,0 +1,147 @@ +local lazy = require "lazy" +local alpha = require "alpha" + +vim.api.nvim_create_autocmd("ColorScheme", { + callback = function() + local groups = { + Red = "#ff928a", + Orange = "#ff9f6f", + Yellow = "#ecb256", + Green = "#8bd294", + Cyan = "#6dd3c2", + Blue = "#8bc3fc", + Purple = "#c4b1f6", + Pink = "#e5acb4", + } + for group, color in pairs(groups) do + vim.api.nvim_set_hl(0, "Dash" .. group, { fg = color, bold = true }) + end + local comment = vim.api.nvim_get_hl(0, { name = "Comment" }) + vim.api.nvim_set_hl(0, "DashEmphasis", vim.tbl_deep_extend("keep", comment, { bold = true })) + end, +}) + + +return { + layout = { + { + type = "padding", + val = 4, + }, + { + type = "text", + val = { + [[ ___ ___ ___ ___ ___ ___ ___ ___ ]], + [[ /\ \ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /\ \ ]], + [[ /::\ \ /::\ \ _\:\ \ /::\ \ /::L_L_ _\:\ \ \:\ \ /::\ \ ]], + [[ /::\:\__\ /::\:\__\ /\/::\__\ /\:\:\__\ /:/L:\__\ /\/::\__\ /::\__\ /::\:\__\ ]], + [[ \/\::/ / \;:::/ / \::/\/__/ \:\:\/__/ \/_/:/ / \::/\/__/ /:/\/__/ \:\:\/ / ]], + [[ \/__/ |:\/__/ \:\__\ \::/ / /:/ / \:\__\ \/__/ \:\/ / ]], + [[ \|__| \/__/ \/__/ \/__/ \/__/ \/__/ ]], + [[ ]], + }, + opts = { + position = "center", + hl = { + { + { "DashRed", 1, 10 }, + { "DashOrange", 10, 20 }, + { "DashYellow", 20, 30 }, + { "DashGreen", 30, 40 }, + { "DashCyan", 40, 50 }, + { "DashBlue", 50, 60 }, + { "DashPurple", 60, 70 }, + { "DashPink", 70, 80 }, + }, + { + { "DashRed", 1, 10 }, + { "DashOrange", 10, 20 }, + { "DashYellow", 20, 30 }, + { "DashGreen", 30, 40 }, + { "DashCyan", 40, 50 }, + { "DashBlue", 50, 60 }, + { "DashPurple", 60, 70 }, + { "DashPink", 70, 80 }, + }, + { + { "DashRed", 1, 10 }, + { "DashOrange", 10, 20 }, + { "DashYellow", 20, 30 }, + { "DashGreen", 30, 40 }, + { "DashCyan", 40, 50 }, + { "DashBlue", 50, 60 }, + { "DashPurple", 60, 70 }, + { "DashPink", 70, 80 }, + }, + { + { "DashRed", 1, 10 }, + { "DashOrange", 10, 20 }, + { "DashYellow", 20, 30 }, + { "DashGreen", 30, 40 }, + { "DashCyan", 40, 50 }, + { "DashBlue", 50, 60 }, + { "DashPurple", 60, 70 }, + { "DashPink", 70, 80 }, + }, + { + { "DashRed", 1, 10 }, + { "DashOrange", 10, 20 }, + { "DashYellow", 20, 30 }, + { "DashGreen", 30, 40 }, + { "DashCyan", 40, 50 }, + { "DashBlue", 50, 60 }, + { "DashPurple", 60, 70 }, + { "DashPink", 70, 80 }, + }, + { + { "DashRed", 1, 10 }, + { "DashOrange", 10, 20 }, + { "DashYellow", 20, 30 }, + { "DashGreen", 30, 40 }, + { "DashCyan", 40, 50 }, + { "DashBlue", 50, 60 }, + { "DashPurple", 60, 70 }, + { "DashPink", 70, 80 }, + }, + { + { "DashRed", 1, 10 }, + { "DashOrange", 10, 20 }, + { "DashYellow", 20, 30 }, + { "DashGreen", 30, 40 }, + { "DashCyan", 40, 50 }, + { "DashBlue", 50, 60 }, + { "DashPurple", 60, 70 }, + { "DashPink", 70, 80 }, + }, + }, + }, + }, + { + type = "padding", + val = 2, + }, + { + type = "group", + val = { + { + type = "text", + val = function() return lazy.stats().loaded .. " plugin" .. (lazy.stats().loaded == 1 and "" or "s") .. " loaded" end, + opts = { + position = "center", + } + }, + { + type = "text", + val = "prismite | a theme made by delta___", + opts = { + position = "center", + hl = { + { "Comment", 0, 27 }, + { "DashEmphasis", 27, 35 } + } + } + } + }, + }, + }, +} diff --git a/.config/nvim/lua/icons.lua b/.config/nvim/lua/icons.lua new file mode 100644 index 0000000..e058e29 --- /dev/null +++ b/.config/nvim/lua/icons.lua @@ -0,0 +1,45 @@ +return { + diagnostics = { + Error = " ", + Warn = " ", + Hint = " ", + Info = " ", + }, + kinds = { + Array = " ", + Boolean = " ", + Class = " ", + Color = " ", + Constant = " ", + Constructor = " ", + Copilot = " ", + Enum = " ", + EnumMember = " ", + Event = " ", + Field = " ", + File = " ", + Folder = " ", + Function = " ", + Interface = " ", + Key = " ", + Keyword = " ", + Method = " ", + Module = " ", + Namespace = " ", + Null = " ", + Number = " ", + Object = " ", + Operator = " ", + Package = " ", + Property = " ", + Reference = " ", + Snippet = " ", + String = " ", + Struct = " ", + Text = " ", + TypeParameter = " ", + Unit = " ", + Value = " ", + Variable = " ", + }, +} diff --git a/.config/nvim/lua/local_plugins/color_converter/lua/color_converter.lua b/.config/nvim/lua/local_plugins/color_converter/lua/color_converter.lua new file mode 100644 index 0000000..ff8aa70 --- /dev/null +++ b/.config/nvim/lua/local_plugins/color_converter/lua/color_converter.lua @@ -0,0 +1,14 @@ +local menu = require "ui" + +return { + setup = function () + vim.api.nvim_create_user_command( + "ColorConverter", + function() + menu:mount() + end, + {} + ) + end, + config = function(opt) end +} diff --git a/.config/nvim/lua/local_plugins/color_converter/lua/ui.lua b/.config/nvim/lua/local_plugins/color_converter/lua/ui.lua new file mode 100644 index 0000000..a2bf115 --- /dev/null +++ b/.config/nvim/lua/local_plugins/color_converter/lua/ui.lua @@ -0,0 +1,47 @@ +local mcolors = require "mini.colors" +local Menu = require("nui.menu") +local event = require("nui.utils.autocmd").event + +local popup_options = { + relative = "cursor", + position = { + row = 2, + col = 1, + }, + border = { + style = "rounded", + text = { + top = "[Choose Item]", + top_align = "center", + }, + }, +} + +local menu = Menu(popup_options, { + lines = { + Menu.separator("Group One"), + Menu.item("Item 1"), + Menu.item("Item 2"), + Menu.separator("Group Two", { + char = "-", + text_align = "right", + }), + Menu.item("Item 3"), + Menu.item("Item 4"), + }, + -- max_width = 20, + keymap = { + focus_next = { "j", "", "" }, + focus_prev = { "k", "", "" }, + close = { "", "" }, + submit = { "", "" }, + }, + on_close = function() + print("CLOSED") + end, + on_submit = function(item) + print("SUBMITTED", vim.inspect(item)) + end, +}) + +return menu diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua index 94ded94..6153825 100644 --- a/.config/nvim/lua/options.lua +++ b/.config/nvim/lua/options.lua @@ -1,23 +1,28 @@ local o = vim.o local opt = vim.opt -local wo = vim.wo -local bo = vim.bo --- Global options -- o.smarttab = true +o.exrc = true o.clipboard = "unnamedplus" -o.termguicolors = 24 +o.termguicolors = true o.list = true -opt.listchars = { space = "⋅", tab = " " } o.autochdir = true +o.wrap = false +o.number = true +o.relativenumber = true +o.expandtab = true +o.tabstop = 4 +o.smartindent = true +o.shiftwidth = 4 +o.sidescroll = 5 +o.timeout= false +o.scrolloff = 4 +o.sidescrolloff = 4 +o.sidescroll = 1 +o.cursorline = true +o.mouse = "" +o.fillchars = 'eob: ' +vim.g.mapleader = " " +vim.g.maplocalleader = vim.g.mapleader --- Window options -- -wo.number = true -wo.relativenumber = true - --- Buffer options -- -bo.expandtab = true -bo.tabstop = 4 -bo.smartindent = true ---bo.softtabstop = 0 -bo.shiftwidth = 2 +opt.listchars = { space = "⋅", tab = "--", precedes = "…", extends = "…" } diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua deleted file mode 100644 index 7cc8321..0000000 --- a/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,83 +0,0 @@ -return { - { "echasnovski/mini.move", config = true }, - -- QoL - { "max397574/better-escape.nvim", config = true }, - - { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, - - -- UI - { - "lukas-reineke/indent-blankline.nvim", - config = true - }, - { - "folke/noice.nvim", - event = "VeryLazy", - opts = { - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - }, - -- you can enable a preset for easier configuration - presets = { - -- bottom_search = true, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help - }, - }, - dependencies = { - "MunifTanjim/nui.nvim", - }, - }, - { - "nvim-telescope/telescope.nvim", - config = true, - dependencies = { "nvim-lua/plenary.nvim" } - }, - { - "nvim-lualine/lualine.nvim", - opts = { - options = { - section_separators = { left = " ", right = " " }, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "filename" }, - lualine_c = {}, - lualine_x = { "filetype" }, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - }, - }, - { "stevearc/dressing.nvim", config = true }, - { - "folke/tokyonight.nvim", - lazy = false, - priority = 1000, - config = function() - vim.cmd [[colorscheme tokyonight-night]] - end, - }, - { - "nvim-neo-tree/neo-tree.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - }, - }, - { - "goolord/alpha-nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require("alpha").setup(require("alpha.themes.dashboard").config) - end, - }, -} diff --git a/.config/nvim/lua/plugins/coding.lua b/.config/nvim/lua/plugins/coding.lua new file mode 100644 index 0000000..fd636fa --- /dev/null +++ b/.config/nvim/lua/plugins/coding.lua @@ -0,0 +1,150 @@ +return { + -- { "echasnovski/mini.move", config = true }, + { "echasnovski/mini.comment", config = true }, + { "max397574/better-escape.nvim", config = true }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local configs = require "nvim-treesitter.configs" + configs.setup { + ensure_installed = { + "lua", + "c", + "vim", + "vimdoc", + "query", + "rust", + "fish", + "json", + "javascript", + "latex", + "markdown", + "markdown_inline", + "zig", + "typescript", + "toml", + "svelte", + "comment", + "html", + "typst", + "ron" + }, + highlight = { enable = true }, + indent = { enable = true }, + } + end, + }, + { + "ggandor/leap.nvim", + config = function() + local leap = require "leap" + leap.add_default_mappings() + leap.opts.highlight_unlabeled_phase_one_targets = true + end, + dependencies = { + "tpope/vim-repeat", + }, + }, + { + "hrsh7th/nvim-cmp", + opts = function() + vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) + local cmp = require "cmp" + local defaults = require "cmp.config.default"() + return { + enabled = function() + local context = require "cmp.config.context" + if vim.api.nvim_get_mode().mode == "c" then + return true + else + return not context.in_treesitter_capture "comment" and not context.in_syntax_group "Comment" + end + end, + + completion = { + completeopt = "menu,menuone,noinsert", + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert { + [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm { select = false }, + }, + sources = cmp.config.sources { + { name = "nvim_lsp" }, + { name = "path" }, + }, + formatting = { + format = function(_, item) + local icons = require("icons").kinds + if icons[item.kind] then + item.kind = icons[item.kind] .. item.kind + end + return item + end, + }, + experimental = { + ghost_text = { + hl_group = "CmpGhostText", + }, + }, + sorting = defaults.sorting, + } + end, + dependencies = { + { "L3MON4D3/LuaSnip", build = "make install_jsregexp" }, + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, + disabled = true + }, + { + "NvChad/nvim-colorizer.lua", + opts = { + user_default_options = { RGB = true, RRGGBB = true, RRGGBBAA = true, always_update = true, names = false }, + }, + }, + { + "echasnovski/mini.surround", + version = false, + opts = { + mappings = { + add = "\\a", -- Add surrounding in Normal and Visual modes + delete = "\\d", -- Delete surrounding + find = "\\f", -- Find surrounding (to the right) + find_left = "\\F", -- Find surrounding (to the left) + highlight = "\\h", -- Highlight surrounding + replace = "\\r", -- Replace surrounding + update_n_lines = "\\n", -- Update `n_lines` + } + } + }, + { + "color_converter", + dev = true, + dependencies = { + { 'echasnovski/mini.colors', version = '*' }, + "MunifTanjim/nui.nvim", + }, + -- lazy = false, + cmd = "ColorConverter", + config = true + }, + -- { + -- "m4xshen/hardtime.nvim", + -- config = true, + -- disabled = true + -- } +} diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..e0f2a96 --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,57 @@ +return { + -- { + -- "folke/tokyonight.nvim", + -- lazy = false, + -- priority = 1000, + -- config = function() + -- vim.cmd [[colorscheme tokyonight-night]] + -- end, + -- }, + -- { + -- "chadcat7/prism", + -- config = function() + -- require("prism"):setup { + -- customSchemes = { + -- { + -- name = "prismite", + -- background = "#1b2026", + -- foreground = "#d9dfe4", + -- cursorline = "#1f242b", + -- comment = "#434754", + -- darker = "#161b22", + -- cursor = "#fdc267", + -- black = "#1b2026", -- useful when background is transparent + -- color0 = "#1f242b", + -- color1 = "#df625d", + -- color2 = "#91d89a", + -- color3 = "#fdc267", + -- color4 = "#8ec6ff", + -- color5 = "#f2b9c1", + -- color6 = "#77e2e3", + -- color7 = "#d9dfe4", + -- color8 = "#373D41", + -- color9 = "#f1726b", + -- color10 = "#a1e9aa", + -- color11 = "#ffd79d", + -- color12 = "#add6ff", + -- color13 = "#ffcbd2", + -- color14 = "#88f3f3", + -- color15 = "#d9dfe4", + -- }, + -- }, + -- currentTheme = "prismite", + -- reset = true, + -- reload = { "lualine" }, + -- } + -- end, + -- enabled = false + -- }, + { + dir = "/home/delta/Documents/RealProjects/lua/prismite.nvim", + lazy = false, + priority = 1000, + config = function() + vim.cmd [[colo prismite]] + end, + }, +} diff --git a/.config/nvim/lua/plugins/editor.lua b/.config/nvim/lua/plugins/editor.lua new file mode 100644 index 0000000..47fe8b4 --- /dev/null +++ b/.config/nvim/lua/plugins/editor.lua @@ -0,0 +1,24 @@ +return { + -- { "Saecki/crates.nvim", config = true }, + { + "nvim-telescope/telescope.nvim", + config = true, + dependencies = { "nvim-lua/plenary.nvim" }, + }, + { + "natecraddock/sessions.nvim", + config = true + }, + { + "f-person/git-blame.nvim", + event = "VeryLazy", + opts = { + date_format = "%r" + }, + }, + { + "chentoast/marks.nvim", + -- event = "VeryLazy", + config = true + } +} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..1063c5d --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,254 @@ +local icons = require("icons") + +-- this is horrible and it should be redone someday +-- but that day is not today + +return { + { + "neovim/nvim-lspconfig", + -- enabled = false, + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + { "williamboman/mason.nvim", config = true, lazy = false }, + { "mason-org/mason-lspconfig.nvim", opts = { automatic_enable = false } }, + "hrsh7th/cmp-nvim-lsp", + }, + opts = { + diagnostics = { + }, + servers = { + lua_ls = { + settings = { + Lua = { + -- workspace = { + -- checkThirdParty = false, + -- library = { + -- vim.env.VIMRUNTIME, + -- }, + -- }, + completion = { + showWord = "Disable", + displayContext = 8, + }, + hint = { + enable = true, + }, + diagnostics = { "trailing-space" }, + }, + }, + }, + rust_analyzer = { settings = { completion = { fullFunctionSignatures = true } } }, + ts_ls = {}, + }, + setup = {} + }, + config = function(_, opts) + local function on_attach(fn) + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local buffer = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + fn(client, buffer) + end, + }) + end + + ---@param method string + ---@param fn fun(client:vim.lsp.Client, buffer) + local function on_supports_method(method, fn) + -- cache[method] = cache[method] or setmetatable({}, { __mode = "k" }) + return vim.api.nvim_create_autocmd("User", { + pattern = "LspSupportsMethod", + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + local buffer = args.data.buffer ---@type number + if client and method == args.data.method then + return fn(client, buffer) + end + end, + }) + end + + -- function _check_methods(client, buffer) + -- if + -- -- don't trigger on invalid buffers + -- not vim.api.nvim_buf_is_valid(buffer) or + -- -- don't trigger on non-listed buffers + -- vim.bo[buffer].buflisted or + -- -- don't trigger on nofile buffers + -- vim.bo[buffer].buftype == "nofile" + -- then + -- return + -- end + -- for method, clients in pairs(M._supports_method) do + -- clients[client] = clients[client] or {} + -- if not clients[client][buffer] then + -- if client.supports_method and client.supports_method(method, { bufnr = buffer }) then + -- clients[client][buffer] = true + -- vim.api.nvim_exec_autocmds("User", { + -- pattern = "LspSupportsMethod", + -- data = { client_id = client.id, buffer = buffer, method = method }, + -- }) + -- end + -- end + -- end + -- end + + on_supports_method("textDocument/inlayHint", function(client, buffer) + if + vim.api.nvim_buf_is_valid(buffer) + and vim.bo[buffer].buftype == "" + and not vim.tbl_contains(opts.inlay_hints.exclude, vim.bo[buffer].filetype) + then + vim.lsp.inlay_hint.enable(true, { bufnr = buffer }) + end + end) + + vim.diagnostic.config({ + underline = true, + update_in_insert = false, + virtual_text = { + spacing = 4, + source = "if_many", + prefix = function(diagnostic) + for name, icon in pairs(icons.diagnostics) do + if diagnostic.severity == vim.diagnostic.severity[name:upper()] then + return icon + end + end + end + + }, + severity_sort = true, + }) + + local servers = opts.servers + local cmp_nvim_lsp = require "cmp_nvim_lsp" + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + cmp_nvim_lsp.default_capabilities() + ) + + local function setup(server) + local server_opts = vim.tbl_deep_extend("force", { + capabilities = vim.deepcopy(capabilities), + }, servers[server] or {}) + + if opts.setup[server] then + if opts.setup[server](server, server_opts) then + return + end + elseif opts.setup["*"] then + if opts.setup["*"](server, server_opts) then + return + end + end + require("lspconfig")[server].setup(server_opts) + end + + local mlsp = require "mason-lspconfig" + local all_mslp_servers = require("mason-lspconfig").get_mappings().lspconfig_to_package + + local ensure_installed = {} + for server, server_opts in pairs(servers) do + if server_opts then + server_opts = server_opts == true and {} or server_opts + if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server + end + end + end + + -- mlsp.setup { ensure_installed = ensure_installed, handlers = { setup } } + mlsp.setup { ensure_installed = ensure_installed } + end, + -- config = function(_, opts) + -- local cache = {} + -- + -- + -- + -- + -- on_attach(function(client, buffer) + -- -- TODO: add keybinds + -- end) + -- + -- local register_capability = vim.lsp.handlers["client/registerCapability"] + -- + -- vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx) + -- local ret = register_capability(err, res, ctx) + -- local client_id = ctx.client_id + -- local client = vim.lsp.get_client_by_id(client_id) + -- local buffer = vim.api.nvim_get_current_buf() + -- -- TODO: add keybinds + -- return ret + -- end + -- + -- for name, icon in pairs(require("icons").diagnostics) do + -- name = "DiagnosticSign" .. name + -- vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) + -- end + -- + -- local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint + -- + -- + -- if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then + -- opts.diagnostics.virtual_text.prefix = vim.fn.has "nvim-0.10.0" == 0 and "●" + -- end + -- +-- ) + -- + -- local servers = opts.servers + -- local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") + -- local capabilities = vim.tbl_deep_extend( + -- "force", + -- {}, + -- vim.lsp.protocol.make_client_capabilities(), + -- has_cmp and cmp_nvim_lsp.default_capabilities() or {}, + -- opts.capabilities or {} + -- ) + -- + -- local function setup(server) + -- local server_opts = vim.tbl_deep_extend("force", { + -- capabilities = vim.deepcopy(capabilities), + -- }, servers[server] or {}) + -- + -- if opts.setup[server] then + -- if opts.setup[server](server, server_opts) then + -- return + -- end + -- elseif opts.setup["*"] then + -- if opts.setup["*"](server, server_opts) then + -- return + -- end + -- end + -- require("lspconfig")[server].setup(server_opts) + -- end + -- + -- local have_mason, mlsp = pcall(require, "mason-lspconfig") + -- local all_mslp_servers = {} + -- if have_mason then + -- all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package) + -- end + -- + -- local ensure_installed = {} + -- for server, server_opts in pairs(servers) do + -- if server_opts then + -- server_opts = server_opts == true and {} or server_opts + -- if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then + -- setup(server) + -- else + -- ensure_installed[#ensure_installed + 1] = server + -- end + -- end + -- end + -- + -- if have_mason then + -- mlsp.setup { ensure_installed = ensure_installed, handlers = { setup } } + -- end + -- end, + }, +} diff --git a/.config/nvim/lua/plugins/ui.lua b/.config/nvim/lua/plugins/ui.lua new file mode 100644 index 0000000..e79ee3a --- /dev/null +++ b/.config/nvim/lua/plugins/ui.lua @@ -0,0 +1,477 @@ +local leap_active = false +vim.api.nvim_create_autocmd("User", { + pattern = "LeapEnter", + callback = function() + leap_active = true + end, +}) + +vim.api.nvim_create_autocmd("User", { + pattern = "LeapLeave", + callback = function() + leap_active = false + end, +}) + +local nvim_tree_root = nil + +return { + { + "willothy/nvim-cokeline", + + config = function() + local hl = require("cokeline.hlgroups") + local is_picking_focus = require('cokeline.mappings').is_picking_focus + local is_picking_close = require('cokeline.mappings').is_picking_close + + local function has_diagnostics(buffer) + return buffer.diagnostics.errors > 0 or buffer.diagnostics.warnings > 0 or buffer.diagnostics.infos > 0 or buffer.diagnostics.hints > 0 + end + + require("cokeline").setup { + show_if_buffers_are_at_least = 0, + components = { + { + text = function(buffer) + return buffer.is_first and (require "cokeline.sidebar".get_width("left") == 0 and "" or "│") or "▎" + end, + fg = function() + return hl.get_hl_attr("WinSeparator", "fg") + end, + }, + { + text = function (buffer) + return (is_picking_focus() or is_picking_close()) and " " .. buffer.pick_letter or "" + end, + fg = function () + return hl.get_hl_attr("PrismiteYellow", "fg") + end + }, + { + text = function(buffer) + return " " .. buffer.devicon.icon + end, + fg = function(buffer) + return buffer.devicon.color + end, + }, + { + text = function(buffer) + return buffer.unique_prefix + end, + fg = function() + return hl.get_hl_attr("Comment", "fg") + end, + italic = true, + }, + { + text = function(buffer) + return buffer.filename + end, + }, + { + ---@param buffer Buffer + text = function(buffer) + return buffer.is_modified and " " or "" + end, + }, + { + text = function(buffer) + return has_diagnostics(buffer) and " [" or "" + end, + fg = function() + return hl.get_hl_attr("WinSeparator", "fg") + end, + }, + { + text = function(buffer) + local errors = buffer.diagnostics.errors + return errors > 0 and errors or "" + end, + fg = function () + return hl.get_hl_attr("DiagnosticError", "fg") + + end + }, + { + text = function (buffer) + local bd = buffer.diagnostics + return (bd.errors > 0 and (bd.warnings > 0 or bd.infos > 0 or bd.hints > 0)) and "|" or "" + end, + fg = function() + return hl.get_hl_attr("WinSeparator", "fg") + end, + }, + { + text = function(buffer) + local warnings = buffer.diagnostics.warnings + return warnings > 0 and warnings or "" + end, + fg = function () + return hl.get_hl_attr("DiagnosticWarn", "fg") + end + }, + { + text = function (buffer) + local bd = buffer.diagnostics + return (bd.warnings > 0 and (bd.infos > 0 or bd.hints > 0)) and "|" or "" + end, + fg = function() + return hl.get_hl_attr("WinSeparator", "fg") + end, + }, + { + text = function(buffer) + local infos = buffer.diagnostics.infos + return infos > 0 and infos or "" + end, + fg = function () + return hl.get_hl_attr("DiagnosticInfo", "fg") + end + }, + { + text = function (buffer) + local bd = buffer.diagnostics + return (bd.infos > 0 and bd.hints > 0) and "|" or "" + end, + fg = function() + return hl.get_hl_attr("WinSeparator", "fg") + end, + }, + { + text = function(buffer) + local hints = buffer.diagnostics.hints + return hints > 0 and hints or "" + end, + fg = function () + return hl.get_hl_attr("DiagnosticHint", "fg") + end + }, + { + text = function(buffer) + return has_diagnostics(buffer) and "]" or "" + end, + fg = function() + return hl.get_hl_attr("WinSeparator", "fg") + end, + }, + { + text = " " + } + }, + buffers = { + delete_on_right_click = false + }, + mappings = { + disable_mouse = true + }, + sidebar = { + components = { + { + text = function() + local width = require("cokeline.sidebar").get_width("left") + if #nvim_tree_root > width then + return nvim_tree_root:sub(1, width - 2) .. "…" + else + return nvim_tree_root + end + end, + bg = function() + return hl.get_hl_attr("TabLineSel", "bg") + end, + }, + { + text = function() + return string.rep( + " ", + math.max(0, require("cokeline.sidebar").get_width("left") - #nvim_tree_root) + ) + end, + bg = function() + return hl.get_hl_attr("TabLineSel", "bg") + end + }, + } + } + } + end, + dependencies = { "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" }, + }, + { + "folke/trouble.nvim", + opts = {}, + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, + { + "nvimdev/indentmini.nvim", + config = true, + opts = { + char = "▏" + } + }, + { + "folke/noice.nvim", + event = "VeryLazy", + opts = { + cmdline = { + format = { + cmdline = { icon = ":" }, + }, + }, + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + }, + presets = { + command_palette = true, + long_message_to_split = true, + inc_rename = false, + lsp_doc_border = true, + }, + messages = { + view_search = false, + }, + routes = { + { + filter = { + event = "msg_show", + kind = "", + find = "Already at newest change", + }, + view = "mini", + }, + { + filter = { + event = "msg_show", + kind = "", + find = "Already at oldest change", + }, + view = "mini", + }, + { + filter = { + event = "msg_show", + kind = "", + find = "E486: Pattern not found:" + }, + view = "mini" + }, + -- normal search + { + filter = { + event = "msg_show", + kind = "", + find = "E486: Pattern not found:" + }, + view = "mini" + }, + -- failed search + { + filter = { + event = "msg_show", + kind = "", + find = "E486: Pattern not found:" + }, + view = "mini" + }, + -- undo + { + filter = { + event = "msg_show", + kind = "", + find = "%d+ .+ line.?; before #%d+", + }, + view = "mini", + }, + { + filter = { + event = "msg_show", + kind = "", + find = "%d+ .+ line.?; before #%d+", + }, + view = "mini", + }, + -- redo + { + filter = { + event = "msg_show", + kind = "", + find = "%d+ change; after #%d+", + }, + view = "mini" + }, + }, + }, + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + }, + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + opts = { + options = { + section_separators = { left = "", right = "" }, + component_separators = { left = "", right = "" }, + fmt = function(str) + return vim.trim(str) + end, + globalstatus = true, + disabled_filetypes = { "NvimTree" }, + }, + sections = { + lualine_a = { + "mode", + { + function() + return "[L]" + end, + cond = function () + return leap_active + end + }, + { + function() + local reg = vim.fn.reg_recording() + if reg == "" then return "" end -- not recording + return "[@" .. reg .. "]" + end + } + }, + lualine_b = { "filename" }, + lualine_c = { "diagnostics", "diff" }, + lualine_x = { + { + function () + local noice_loaded, noice = pcall(require, "noice") + if noice_loaded then + return noice.api.status.command.get() + else + return "" + end + end, + cond = function() + local noice_loaded, noice = pcall(require, "noice") + if noice_loaded then + return noice.api.status.command.has() + else + return false + end + end + } + }, + lualine_y = { "filetype" }, + lualine_z = { "searchcount", "progress", "location" }, + }, + }, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + }, + { "stevearc/dressing.nvim", config = true }, + { + "nvim-tree/nvim-tree.lua", + opts = { + sort_by = "case_sensitive", + view = { + width = 30, + }, + renderer = { + root_folder_label = function() return ".." end, + indent_markers = { + enable = true, + }, + icons = { + show = { + folder_arrow = false, + }, + glyphs = { + git = { + unstaged = "-", + staged = "+", + unmerged = "", + renamed = "󰏪", + untracked = "", + deleted = "󰆴", + ignored = "", + }, + }, + }, + }, + filters = { + git_ignored = false, + custom = { + "^.git$", + }, + }, + }, + config = function(_, opts) + local api = require("nvim-tree.api") + local Event = api.events.Event + + api.events.subscribe(Event.Ready, function() + nvim_tree_root = api.tree.get_nodes().absolute_path + end) + + api.events.subscribe(Event.TreeRendered, function() + nvim_tree_root = api.tree.get_nodes().absolute_path + end) + + require("nvim-tree").setup(vim.tbl_extend("force", opts, { + -- on_attach = function () + -- local function opts(desc) + -- return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + -- end + -- + -- local function edit_or_open() + -- local node = api.tree.get_node_under_cursor() + -- + -- if node.nodes ~= nil then + -- -- expand or collapse folder + -- api.node.open.edit() + -- else + -- -- open file + -- api.node.open.edit() + -- -- Close the tree if file was opened + -- api.tree.close() + -- end + -- end + -- + -- -- open as vsplit on current node + -- local function vsplit_preview() + -- local node = api.tree.get_node_under_cursor() + -- + -- if node.nodes ~= nil then + -- -- expand or collapse folder + -- api.node.open.edit() + -- else + -- -- open file as vsplit + -- api.node.open.vertical() + -- end + -- + -- -- Finally refocus on tree if it was lost + -- api.tree.focus() + -- end + -- + -- vim.keymap.set("n", "l", edit_or_open, opts("Edit Or Open")) + -- vim.keymap.set("n", "h", api.tree.close, opts("Close")) + -- end + -- + })) + end, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + }, + { + "goolord/alpha-nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("alpha").setup(require "dash") + end, + }, +} diff --git a/.config/nvim/lua/plugins/utils.lua b/.config/nvim/lua/plugins/utils.lua new file mode 100644 index 0000000..3c16433 --- /dev/null +++ b/.config/nvim/lua/plugins/utils.lua @@ -0,0 +1,4 @@ +return { + { 'echasnovski/mini.colors', version = '*' }, + "MunifTanjim/nui.nvim", +} -- cgit v1.2.3