From 9660893b91342334a9a7faf030c1170210b639e3 Mon Sep 17 00:00:00 2001 From: Oliver Ladner Date: Sun, 4 May 2025 13:11:56 +0200 Subject: [PATCH] feat: random beautification --- lsp/bicep.lua | 8 ++ lsp/docker-compose.lua | 7 ++ lsp/woke.lua | 5 + lsp/write-good.lua | 6 + lua/weeheavy/plugins/lsp/nvim-lint.lua | 54 ++++----- lua/weeheavy/plugins/lualine.lua | 135 ++++++++++++---------- lua/weeheavy/plugins/mini.lua | 25 +++- lua/weeheavy/plugins/oil.lua | 71 ++++++------ lua/weeheavy/plugins/pomo.lua | 10 ++ lua/weeheavy/plugins/telescope.lua | 101 ++++++++-------- lua/weeheavy/plugins/theme/catppuccin.lua | 102 ++++++++-------- lua/weeheavy/plugins/theme/kanagawa.lua | 18 +++ lua/weeheavy/plugins/theme/rosepine.lua | 17 +++ lua/weeheavy/prefs.lua | 1 + lua/weeheavy/remap.lua | 34 +++--- 15 files changed, 348 insertions(+), 246 deletions(-) create mode 100644 lsp/bicep.lua create mode 100644 lsp/docker-compose.lua create mode 100644 lsp/woke.lua create mode 100644 lsp/write-good.lua create mode 100644 lua/weeheavy/plugins/pomo.lua create mode 100644 lua/weeheavy/plugins/theme/kanagawa.lua diff --git a/lsp/bicep.lua b/lsp/bicep.lua new file mode 100644 index 0000000..6162e44 --- /dev/null +++ b/lsp/bicep.lua @@ -0,0 +1,8 @@ +---@type vim.lsp.Config + +local bicep_lsp_bin = "/Users/oliver.ladner/bicep-langserver/Bicep.LangServer.dll" +return { + cmd = { "/opt/homebrew/opt/dotnet@8/libexec/dotnet", bicep_lsp_bin }, + root_markers = { ".git" }, + filetypes = { "bicep" }, +} diff --git a/lsp/docker-compose.lua b/lsp/docker-compose.lua new file mode 100644 index 0000000..011a55d --- /dev/null +++ b/lsp/docker-compose.lua @@ -0,0 +1,7 @@ +---@type vim.lsp.Config +return { + cmd = { "docker-compose-langserver", "--stdio" }, + root_markers = { "docker_compose*.yml", "docker-compose.yml" }, + filetypes = { "yaml.docker-compose" }, + single_file_support = true, +} diff --git a/lsp/woke.lua b/lsp/woke.lua new file mode 100644 index 0000000..79c7927 --- /dev/null +++ b/lsp/woke.lua @@ -0,0 +1,5 @@ +---@type vim.lsp.Config +return { + cmd = { "woke", "--stdin" }, + filetypes = { "markdown", "text", "gitcommit", "plaintext" }, +} diff --git a/lsp/write-good.lua b/lsp/write-good.lua new file mode 100644 index 0000000..68fb51d --- /dev/null +++ b/lsp/write-good.lua @@ -0,0 +1,6 @@ +---@type vim.lsp.Config +return { + cmd = { "write-good", "/dev/stdin" }, + -- root_markers = { ".md" }, + filetypes = { "markdown", "text", "gitcommit" }, +} diff --git a/lua/weeheavy/plugins/lsp/nvim-lint.lua b/lua/weeheavy/plugins/lsp/nvim-lint.lua index 33524f2..de54784 100644 --- a/lua/weeheavy/plugins/lsp/nvim-lint.lua +++ b/lua/weeheavy/plugins/lsp/nvim-lint.lua @@ -1,32 +1,34 @@ return { - "mfussenegger/nvim-lint", - event = { "BufReadPre", "BufNewFile" }, - config = function() - local lint = require("lint") + "mfussenegger/nvim-lint", + -- event = { "BufReadPre", "BufNewFile" }, + event = "VeryLazy", + config = function() + local lint = require("lint") - lint.linters_by_ft = { - javascript = { "eslint_d" }, - typescript = { "eslint_d" }, - javascriptreact = { "eslint_d" }, - typescriptreact = { "eslint_d" }, - svelte = { "eslint_d" }, - python = { "pylint" }, - ansible = { "woke" }, - markdown = { "woke" }, - sh = { "woke" }, - } + lint.linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + javascriptreact = { "eslint_d" }, + typescriptreact = { "eslint_d" }, + svelte = { "eslint_d" }, + python = { "pylint" }, + ansible = { "woke" }, + markdown = { "woke" }, + text = { "woke" }, + sh = { "woke" }, + } - local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + -- local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) - vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { - group = lint_augroup, - callback = function() - lint.try_lint() - end, - }) + vim.api.nvim_create_autocmd({ "BufEnter", "BufReadPost", "BufWritePost", "InsertLeave" }, { + -- group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) - vim.keymap.set("n", "l", function() - lint.try_lint() - end, { desc = "Trigger linting for current file" }) - end, + vim.keymap.set("n", "l", function() + lint.try_lint() + end, { desc = "Trigger linting for current file" }) + end, } diff --git a/lua/weeheavy/plugins/lualine.lua b/lua/weeheavy/plugins/lualine.lua index cf0e3dc..b2b1aa2 100644 --- a/lua/weeheavy/plugins/lualine.lua +++ b/lua/weeheavy/plugins/lualine.lua @@ -2,78 +2,91 @@ -- Display attached LSP client local function lsp_client_name() - local bufnr = vim.api.nvim_get_current_buf() + local bufnr = vim.api.nvim_get_current_buf() - -- local clients = vim.lsp.buf_get_clients(bufnr) - local clients = vim.lsp.get_clients({ bufnr = 0 }) - if next(clients) == nil then - return "n/a" - end + -- local clients = vim.lsp.buf_get_clients(bufnr) + local clients = vim.lsp.get_clients({ bufnr = 0 }) + if next(clients) == nil then + return "n/a" + end - local c = {} - for _, client in pairs(clients) do - table.insert(c, client.name) - -- table.insert(c, string.sub(client.name, 0, 8) .. "...") - end - return "\u{f085} " .. table.concat(c, ",") + local c = {} + for _, client in pairs(clients) do + table.insert(c, client.name) + -- table.insert(c, string.sub(client.name, 0, 8) .. "...") + end + return "\u{f085} " .. table.concat(c, ",") end -- hide content on narrow windows local function hide_in_width() - return vim.fn.winwidth(0) > 80 + return vim.fn.winwidth(0) > 80 end local function clock() - local time = tostring(os.date()):sub(12, 16) - return time + local time = tostring(os.date()):sub(12, 16) + return time end return { - "nvim-lualine/lualine.nvim", - lazy = true, - event = { "BufReadPre", "BufNewFile" }, + "nvim-lualine/lualine.nvim", + lazy = true, + event = { "BufReadPre", "BufNewFile" }, - opts = { - options = { - globalstatus = false, -- true == single statusline - icons_enabled = true, - theme = "auto", - component_separators = "⋮", - --section_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - }, - sections = { - lualine_a = { - { - -- shorten mode names - -- https://github.com/nvim-lualine/lualine.nvim/issues/614#issuecomment-1072275099 - "mode", - fmt = function(res) - return res:sub(1, 1) - end, - }, - }, - lualine_c = { - --{ "searchcount" }, - { - "buffers", - show_filename_only = true, - --fmt = function(str) - -- return str:sub(1, 1) - --end, - --fmt = function() - -- return string.gsub(vim.api.nvim_buf_get_name(0), vim.loop.cwd(), "") - --end, - }, - }, - lualine_x = { - -- specify full list of elements when adding custom things - { "encoding", cond = hide_in_width }, - { "fileformat" }, - { "filetype", cond = hide_in_width }, - { lsp_client_name, cond = hide_in_width }, - --{ clock, cond = hide_in_width }, - }, - }, - }, + opts = { + options = { + globalstatus = false, -- true == single statusline + icons_enabled = true, + theme = "rose-pine", + component_separators = "⋮", + --section_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { + { + -- shorten mode names + -- https://github.com/nvim-lualine/lualine.nvim/issues/614#issuecomment-1072275099 + "mode", + fmt = function(res) + return res:sub(1, 1) + end, + }, + }, + lualine_c = { + --{ "searchcount" }, + { + "buffers", + show_filename_only = true, + --fmt = function(str) + -- return str:sub(1, 1) + --end, + --fmt = function() + -- return string.gsub(vim.api.nvim_buf_get_name(0), vim.loop.cwd(), "") + --end, + }, + }, + lualine_x = { + -- specify full list of elements when adding custom things + { "encoding", cond = hide_in_width }, + { "fileformat", cond = hide_in_width }, + { "filetype" }, + { lsp_client_name, cond = hide_in_width }, + --{ clock, cond = hide_in_width }, + function() + local ok, pomo = pcall(require, "pomo") + if not ok then + return "" + end + + local timer = pomo.get_first_to_finish() + if timer == nil then + return "" + end + + return "󰄉 " .. tostring(timer) + end, + }, + }, + }, } diff --git a/lua/weeheavy/plugins/mini.lua b/lua/weeheavy/plugins/mini.lua index 9259da7..05ae225 100644 --- a/lua/weeheavy/plugins/mini.lua +++ b/lua/weeheavy/plugins/mini.lua @@ -1,9 +1,22 @@ -- Adds git related signs to the gutter, as well as utilities for managing changes return { - "echasnovski/mini.nvim", - version = false, - config = function() - local icons = require("mini.icons") - icons.setup({}) - end, + "echasnovski/mini.nvim", + version = false, + config = function() + require("mini.icons").setup() + require("mini.surround").setup({ + mappings = { + add = "wq", -- Add surrounding in Normal and Visual modes + delete = "wd", -- Delete surrounding + -- find = "sf", -- Find surrounding (to the right) + -- find_left = "sF", -- Find surrounding (to the left) + highlight = "hs", -- Highlight surrounding + replace = "wc", -- Replace surrounding + -- update_n_lines = "sn", -- Update `n_lines` + + -- suffix_last = "l", -- Suffix to search with "prev" method + -- suffix_next = "n", -- Suffix to search with "next" method + }, + }) + end, } diff --git a/lua/weeheavy/plugins/oil.lua b/lua/weeheavy/plugins/oil.lua index 0b67c31..5d279b4 100644 --- a/lua/weeheavy/plugins/oil.lua +++ b/lua/weeheavy/plugins/oil.lua @@ -1,41 +1,40 @@ -- File system operations for nerds -- https://github.com/stevearc/oil.nvim return { - "stevearc/oil.nvim", - lazy = true, - cmd = "Oil", - config = function() - local oil = require("oil") - oil.setup({ - -- Leave netrw there, so we can open link with `gx` - --default_file_explorer = false, - default_file_explorer = true, - columns = { - --"size", - "icon", - }, - view_options = { - show_hidden = true, - }, - keymaps = { - -- This should be matched to the open action in remap.lua - ["e"] = "actions.close", - [""] = "actions.select_vsplit", - [""] = "actions.select_split", - [""] = "actions.close", - ["q"] = "actions.close", - }, + "stevearc/oil.nvim", + lazy = true, + cmd = "Oil", + config = function() + require("oil").setup({ + default_file_explorer = true, + columns = { + -- "size", + "icon", + -- "mtime", + }, + view_options = { + show_hidden = true, + }, + keymaps = { + -- This should be matched to the open action in remap.lua + ["e"] = "actions.close", + [""] = "actions.select_vsplit", + [""] = "actions.select_split", + [""] = "actions.close", + ["q"] = "actions.close", + [""] = "actions.close", + }, - float = { - -- Padding around the floating window - padding = 4, - max_width = 80, - max_height = 25, - border = "rounded", - win_options = { - winblend = 0, - }, - }, - }) - end, + float = { + -- Padding around the floating window + padding = 4, + max_width = 80, + max_height = 25, + border = "rounded", + win_options = { + winblend = 0, + }, + }, + }) + end, } diff --git a/lua/weeheavy/plugins/pomo.lua b/lua/weeheavy/plugins/pomo.lua new file mode 100644 index 0000000..e8779fb --- /dev/null +++ b/lua/weeheavy/plugins/pomo.lua @@ -0,0 +1,10 @@ +return { + "epwalsh/pomo.nvim", + version = "*", -- Recommended, use latest release instead of latest commit + lazy = true, + cmd = { "TimerStart", "TimerRepeat", "TimerSession" }, + opts = { + -- See below for full list of options 👇 + update_interval = 20000, + }, +} diff --git a/lua/weeheavy/plugins/telescope.lua b/lua/weeheavy/plugins/telescope.lua index b1b70a3..0c171c7 100644 --- a/lua/weeheavy/plugins/telescope.lua +++ b/lua/weeheavy/plugins/telescope.lua @@ -1,52 +1,53 @@ return { - "nvim-telescope/telescope.nvim", - lazy = true, - --event = "VeryLazy", - cmd = "Telescope", - tag = "0.1.5", - dependencies = { - "nvim-lua/plenary.nvim", - }, - --config = function(lazy, opts) - config = function() - local telescope = require("telescope") - telescope.load_extension("fzf") - --telescope.load_extension("file_browser") - telescope.setup({ - defaults = { - sorting_strategy = "ascending", - wrap_result = true, - layout_strategy = "horizontal", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.45, - width = 0.90, - height = 0.75, - preview_cutoff = 90, - }, - }, - }, - pickers = { - find_files = { - hidden = true, - wrap_results = false, -- this is not about the preview - }, - live_grep = { - additional_args = function() - return { "--hidden", "--glob", "!**/.git/*" } - end, - }, - grep_string = { - additional_args = function() - return { "--hidden", "--glob", "!**/.git/*" } - end, - }, - ["lsp_references"] = { wrap_results = true }, - ["lsp_definitions"] = { wrap_results = true }, - ["diagnostics"] = { wrap_results = true }, - ["buffers"] = { sort_mru = true, sort_lastused = true, ignore_current_buffer = false }, - }, - }) - end, + "nvim-telescope/telescope.nvim", + lazy = true, + --event = "VeryLazy", + cmd = "Telescope", + tag = "0.1.8", + dependencies = { + "nvim-lua/plenary.nvim", + }, + --config = function(lazy, opts) + config = function() + local telescope = require("telescope") + telescope.load_extension("fzf") + --telescope.load_extension("file_browser") + telescope.setup({ + defaults = { + border = false, + sorting_strategy = "ascending", + wrap_result = true, + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.45, + width = 0.90, + height = 0.75, + preview_cutoff = 90, + }, + }, + }, + pickers = { + find_files = { + hidden = true, + wrap_results = false, -- this is not about the preview + }, + live_grep = { + additional_args = function() + return { "--hidden", "--glob", "!**/.git/*" } + end, + }, + grep_string = { + additional_args = function() + return { "--hidden", "--glob", "!**/.git/*" } + end, + }, + ["lsp_references"] = { wrap_results = true }, + ["lsp_definitions"] = { wrap_results = true }, + ["diagnostics"] = { wrap_results = true }, + ["buffers"] = { sort_mru = true, sort_lastused = true, ignore_current_buffer = false }, + }, + }) + end, } diff --git a/lua/weeheavy/plugins/theme/catppuccin.lua b/lua/weeheavy/plugins/theme/catppuccin.lua index 2d13f2b..866fc1a 100644 --- a/lua/weeheavy/plugins/theme/catppuccin.lua +++ b/lua/weeheavy/plugins/theme/catppuccin.lua @@ -3,57 +3,57 @@ return { name = "catppuccin", tag = "stable", lazy = false, - enabled = false, + enabled = true, priority = 1000, opts = {}, - -- config = function() - -- local tokyonight = require("tokyonight") - -- local util = require("tokyonight.util") - -- tokyonight.setup({ - -- styles = { - -- comments = { italic = true }, - -- }, - -- on_colors = function(colors) - -- -- Brighten up comments a bit - -- colors.comment = "#888fac" - -- -- Better visible visual selection background color - -- colors.bg_visual = "#e82a86" - -- end, - -- on_highlights = function(hl, c) - -- -- Brighter line numbers - -- hl.LineNr = { - -- fg = util.darken(c.dark5, 0.6), - -- } - -- -- Remove borders from Telescope windows - -- local prompt = "#4e3e6c" - -- hl.TelescopeNormal = { - -- bg = c.bg_dark, - -- fg = c.fg_dark, - -- } - -- hl.TelescopeBorder = { - -- bg = c.bg_dark, - -- fg = c.bg_dark, - -- } - -- hl.TelescopePromptNormal = { - -- bg = prompt, - -- } - -- hl.TelescopePromptBorder = { - -- bg = prompt, - -- fg = prompt, - -- } - -- hl.TelescopePromptTitle = { - -- bg = prompt, - -- fg = prompt, - -- } - -- hl.TelescopePreviewTitle = { - -- bg = c.bg_dark, - -- fg = c.bg_dark, - -- } - -- hl.TelescopeResultsTitle = { - -- bg = c.bg_dark, - -- fg = c.bg_dark, - -- } - -- end, - -- }) - -- end, + config = function() + require("catppuccin").setup({ + flavour = "auto", -- latte, frappe, macchiato, mocha + background = { -- :h background + light = "latte", + dark = "mocha", + }, + transparent_background = false, -- disables setting the background color. + show_end_of_buffer = false, -- shows the '~' characters after the end of buffers + term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) + dim_inactive = { + enabled = false, -- dims the background color of inactive window + shade = "dark", + percentage = 0.15, -- percentage of the shade to apply to the inactive window + }, + no_italic = false, -- Force no italic + no_bold = false, -- Force no bold + no_underline = false, -- Force no underline + styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): + comments = { "italic" }, -- Change the style of comments + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + -- miscs = {}, -- Uncomment to turn off hard-coded styles + }, + color_overrides = {}, + custom_highlights = {}, + default_integrations = true, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + treesitter = true, + notify = false, + mini = { + enabled = true, + indentscope_color = "", + }, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, + }) + end, } diff --git a/lua/weeheavy/plugins/theme/kanagawa.lua b/lua/weeheavy/plugins/theme/kanagawa.lua new file mode 100644 index 0000000..668bd77 --- /dev/null +++ b/lua/weeheavy/plugins/theme/kanagawa.lua @@ -0,0 +1,18 @@ +return { + "rebelot/kanagawa.nvim", + name = "kanagawa", + branch = "master", + lazy = false, + enabled = false, + priority = 1000, + opts = {}, + config = function() + require("kanagawa").setup({ + theme = "lotus", -- Load "wave" theme + background = { -- map the value of 'background' option to a theme + dark = "wave", -- try "dragon" ! + light = "lotus", + }, + }) + end, +} diff --git a/lua/weeheavy/plugins/theme/rosepine.lua b/lua/weeheavy/plugins/theme/rosepine.lua index c9ff694..5c44525 100644 --- a/lua/weeheavy/plugins/theme/rosepine.lua +++ b/lua/weeheavy/plugins/theme/rosepine.lua @@ -21,6 +21,23 @@ return { styles = { transparency = false, }, + highlight_groups = { + -- TelescopeResultsNormal = { fg = "subtle", bg = "none" }, + + TelescopeBorder = { fg = "overlay", bg = "overlay" }, + TelescopeNormal = { fg = "subtle", bg = "overlay" }, + TelescopeSelection = { fg = "text", bg = "highlight_med" }, + -- TelescopeSelectionCaret = { fg = "love", bg = "highlight_med" }, + TelescopeSelectionCaret = { fg = "rose", bg = "rose" }, + TelescopeMultiSelection = { fg = "text", bg = "highlight_high" }, + + TelescopeTitle = { fg = "base", bg = "love" }, + TelescopePromptTitle = { fg = "base", bg = "pine" }, + TelescopePreviewTitle = { fg = "base", bg = "iris" }, + + TelescopePromptNormal = { fg = "text", bg = "surface" }, + TelescopePromptBorder = { fg = "surface", bg = "surface" }, + }, }) end, } diff --git a/lua/weeheavy/prefs.lua b/lua/weeheavy/prefs.lua index 531d075..dd448d6 100644 --- a/lua/weeheavy/prefs.lua +++ b/lua/weeheavy/prefs.lua @@ -10,6 +10,7 @@ vim.lsp.enable({ "woke", "tailwind", "docker-compose", + "bicep", }) -- Set highlight on search diff --git a/lua/weeheavy/remap.lua b/lua/weeheavy/remap.lua index bb7bbcd..1bd4959 100644 --- a/lua/weeheavy/remap.lua +++ b/lua/weeheavy/remap.lua @@ -1,4 +1,5 @@ -- keyboard shortcuts +-- -- Leader key. Base for any key combo vim.g.mapleader = ";" @@ -43,13 +44,8 @@ vim.keymap.set("n", "gd", function() else vim.cmd("DiffviewClose") end -end, { noremap = true, desc = "Toggle diff/stage UI " }) -vim.keymap.set( - "n", - "gb", - ":Gitsigns toggle_current_line_blame", - { noremap = true, desc = "Toggle git blame" } -) +end, { noremap = true, desc = "Git diff/stage" }) +vim.keymap.set("n", "gb", ":Gitsigns toggle_current_line_blame", { noremap = true, desc = "Git blame" }) -- Remapping of existing Vim key binds vim.keymap.set("n", "w", "W") -- skip punctuation when moving to start of next word @@ -65,12 +61,12 @@ vim.keymap.set("n", "", "zz") -- eye-friendly down scrolling vim.keymap.set("n", "", "zz") -- eye-friendly up scrolling vim.keymap.set("n", "J", "mzJ`z") -- when merging lines, keep cursor at current position -vim.keymap.set( - "n", - "s", - [[:%s/\<\>//gI]], - { noremap = true, desc = "Replace word below cursor" } -) +-- vim.keymap.set( +-- "n", +-- "s", +-- [[:%s/\<\>//gI]], +-- { noremap = true, desc = "Replace word below cursor" } +-- ) -- Apply conform.nvim formatting on keypress (same as on save) vim.keymap.set({ "n", "v" }, "o", function() @@ -83,19 +79,19 @@ vim.keymap.set({ "n", "v" }, "o", function() end, { desc = "Format file or range (in visual mode)" }) -- Go to next diagnostic item (any severity) -vim.keymap.set({ "n", "v" }, "da", function() +vim.keymap.set("n", "da", function() vim.diagnostic.get_next({}) vim.api.nvim_feedkeys("zz", "n", false) end, { desc = "Go to next diagnostic" }) -- Go to next diagnostic item (error severity) -vim.keymap.set({ "n", "v" }, "de", function() +vim.keymap.set("n", "de", function() vim.diagnostic.get_next({ severity = vim.diagnostic.severity.ERROR }) vim.api.nvim_feedkeys("zz", "n", false) end, { desc = "Go to next error diagnostic" }) -- Go to next diagnostic item (warning severity) -vim.keymap.set({ "n", "v" }, "dw", function() +vim.keymap.set("n", "dw", function() vim.diagnostic.get_next({ severity = vim.diagnostic.severity.WARN }) vim.api.nvim_feedkeys("zz", "n", false) end, { desc = "Go to next warning diagnostic" }) @@ -114,3 +110,9 @@ vim.keymap.set("n", "tdd", function() virtual_text = not vim.diagnostic.config().virtual_text, }) end, { desc = "Toggle diagnostic virtual lines and virtual text" }) + +-- Enclose word with double quotes +-- vim.keymap.set("n", "wq", 'ciw""P', { desc = "Enclose in double quotes" }) + +-- Pomodoro timer +vim.keymap.set("n", "p", ":TimerStart 30m", { desc = "Pomodoro" })