From d36811ef6f79336290746bb8eb943d5df88fdf53 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 13 Aug 2024 18:00:36 -0400 Subject: [PATCH] Update nvim --- .config/nvim/lazy-lock.json | 95 ++++++----- .config/nvim/lua/halfdan/init.lua | 2 +- .config/nvim/lua/halfdan/lazy.lua | 51 ++++-- .config/nvim/lua/halfdan/lualine.lua | 52 ------ .../nvim/lua/halfdan/lualine/components.lua | 160 ++++++++++++++++++ .config/nvim/lua/halfdan/lualine/config.lua | 40 +++++ .../nvim/lua/halfdan/lualine/highlights.lua | 111 ++++++++++++ .config/nvim/lua/halfdan/lualine/init.lua | 60 +++++++ .config/nvim/lua/halfdan/settings.lua | 4 + 9 files changed, 459 insertions(+), 116 deletions(-) delete mode 100644 .config/nvim/lua/halfdan/lualine.lua create mode 100644 .config/nvim/lua/halfdan/lualine/components.lua create mode 100644 .config/nvim/lua/halfdan/lualine/config.lua create mode 100644 .config/nvim/lua/halfdan/lualine/highlights.lua create mode 100644 .config/nvim/lua/halfdan/lualine/init.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 977edcb..25096d8 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,65 +1,68 @@ { - "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "FTerm.nvim": { "branch": "master", "commit": "d1320892cc2ebab472935242d9d992a2c9570180" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" }, + "bufferline.nvim": { "branch": "main", "commit": "2e3c8cc5a57ddd32f1edd2ffd2ccb10c09421f6c" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, - "cmp-git": { "branch": "main", "commit": "8d8993680d627c8f13bd85094eba84604107dbdd" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-git": { "branch": "main", "commit": "3d83031c4b63f9b10703e32e070cda0700a81992" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, - "editorconfig-vim": { "branch": "master", "commit": "0956bc257ca4eaa3e087e0ba2253a3e980805820" }, - "elixir-tools.nvim": { "branch": "main", "commit": "163522196c962fa87cac0df2a0d1ad332e1e0755" }, - "fzf-lua": { "branch": "main", "commit": "f021b287bf095f20cb5062fc9486dd3243ae220c" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "editorconfig-vim": { "branch": "master", "commit": "8b7da79e9daee7a3f3a8d4fe29886b9756305aff" }, + "elixir-tools.nvim": { "branch": "main", "commit": "5e7596be469be0800e9cbe3415de971f7286c3d0" }, + "fzf-lua": { "branch": "main", "commit": "8f9c3a2e308755c25630087f3c5d35786803cfd0" }, + "git-blame.nvim": { "branch": "master", "commit": "50543e3993f4b996eea01ff5ccc8fe2a354c5388" }, "git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" }, - "gruvbox-baby": { "branch": "main", "commit": "436f73d6a45777eadedbd2f842f766d093266eb3" }, + "gruvbox-baby": { "branch": "main", "commit": "bd52e62d8134647090108189e69c8b3cd18bdbbf" }, "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, - "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lsp-status.nvim": { "branch": "master", "commit": "54f48eb5017632d81d0fd40112065f1d062d0629" }, - "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, - "lspsaga.nvim": { "branch": "main", "commit": "3112b7aba57653199ad20198f477d94781bb2310" }, - "monokai-pro.nvim": { "branch": "master", "commit": "add6e9107eec368acde6caed0766256c5dae5005" }, - "neo-tree.nvim": { "branch": "v3.x", "commit": "2f2d08894bbc679d4d181604c16bb7079f646384" }, - "neogit": { "branch": "master", "commit": "38dd297a905ec6869f4c20ea9184a3e514316e3b" }, - "neotest": { "branch": "master", "commit": "dcdb40ea48f9c7b67a5576f6bb2e5f63ec15f2c0" }, - "neotest-elixir": { "branch": "master", "commit": "3117ca5442c02998847131c39551b76a6ceac9d7" }, - "neotest-rust": { "branch": "main", "commit": "3c06f239ad260f02c8678141e08b57d20fbe2c55" }, + "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, + "lspsaga.nvim": { "branch": "main", "commit": "a751b92b5d765a99fe3a42b9e51c046f81385e15" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "monokai-pro.nvim": { "branch": "master", "commit": "2bad2a92fe0ff6c8581d33a853a1b17592b83239" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" }, + "neogit": { "branch": "master", "commit": "2b74a777b963dfdeeabfabf84d5ba611666adab4" }, + "neotest": { "branch": "master", "commit": "32ff2ac21135a372a42b38ae131e531e64833bd3" }, + "neotest-elixir": { "branch": "master", "commit": "c5067bcc3ec6a0bba7b5694fa15aeb17f16aeb3c" }, + "neotest-rust": { "branch": "main", "commit": "0418811e1e3499b2501593f2e131d02f5e6823d4" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, - "nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" }, + "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, - "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, - "nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" }, - "nvim-dap-ui": { "branch": "master", "commit": "a6beb3a855b42faa1d0fee1081602257719c2c5e" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "d4542ac257d3c7ee4131350db6179ae6340ce40b" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-dap": { "branch": "master", "commit": "2b428ff2632e73295e9decbcf1c40d8e26213305" }, + "nvim-dap-ui": { "branch": "master", "commit": "a5606bc5958db86f8d92803bea7400ee26a8d7e4" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "484995d573c0f0563f6a66ebdd6c67b649489615" }, "nvim-lsp-installer": { "branch": "main", "commit": "17e0bfa5f2c8854d1636fcd036dc8284db136baa" }, - "nvim-lspconfig": { "branch": "master", "commit": "042aa6b27b8b8d4f4e1bd42de2037c83d676a8a0" }, - "nvim-notify": { "branch": "master", "commit": "80b67b265530632505193553d05127ae7fe09ddd" }, - "nvim-treesitter": { "branch": "master", "commit": "090880c0f1fec219f7de838cb51b8dc07ce74a6d" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "19a91a38b02c1c28c14e0ba468d20ae1423c39b2" }, - "nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" }, + "nvim-lspconfig": { "branch": "master", "commit": "a67bc39aaa4f1e13212c5022a561120846eaef27" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-treesitter": { "branch": "master", "commit": "047ce49ccf9a2dce22e1cf3843bef3b5682a8144" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "ced6375723b20616282f9f6a1018a63ae19b106a" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, - "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "rust-tools.nvim": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" }, "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, - "smart-open.nvim": { "branch": "0.2.x", "commit": "026091fe7f9b283aa1f5f4bb8c56aa5bcad43dbd" }, - "sqlite.lua": { "branch": "master", "commit": "b7e28c8463254c46a8e61c52d27d6a2040492fc3" }, + "smart-open.nvim": { "branch": "0.2.x", "commit": "87626ee8748b9bba22093adec7bb58c63e7214f0" }, + "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "symbols-outline.nvim": { "branch": "master", "commit": "564ee65dfc9024bdde73a6621820866987cbb256" }, - "tagbar": { "branch": "master", "commit": "fcd31ec145bbc628b90371be381717a1498b7c12" }, + "tagbar": { "branch": "master", "commit": "d55d454bd3d5b027ebf0e8c75b8f88e4eddad8d8" }, "telescope-dap.nvim": { "branch": "master", "commit": "8c88d9716c91eaef1cdea13cb9390d8ef447dbfe" }, - "telescope-egrepify.nvim": { "branch": "master", "commit": "acd69d06a774f930edac5bd75ebe8d4e2854f336" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, - "telescope.nvim": { "branch": "master", "commit": "9cf58f438f95f04cf1709b734bbcb9243c262d70" }, - "toggleterm.nvim": { "branch": "main", "commit": "cbd041d91b90cd3c02df03fe6133208888f8e008" }, - "vim-dispatch": { "branch": "master", "commit": "6cc2691576f97d43f8751664d1a1a908b99927e5" }, - "vim-easy-align": { "branch": "master", "commit": "12dd6316974f71ce333e360c0260b4e1f81169c3" }, - "vim-fugitive": { "branch": "master", "commit": "ec8f7eed103c6d5b75eac69196bb87db0825629a" }, - "vim-gitgutter": { "branch": "main", "commit": "67ef116100b40f9ca128196504a2e0bc0a2753b0" }, - "vim-highlightedyank": { "branch": "master", "commit": "fa3f57b097e9521ce41a66b6c7cf5d9adea70ea3" }, - "vim-projectionist": { "branch": "master", "commit": "a57b9bf11ecfef16f767034550472830b48ad3e2" }, - "vim-sneak": { "branch": "master", "commit": "29ec9167d4a609f74c130b46265aa17eb2736e6a" }, + "telescope-egrepify.nvim": { "branch": "master", "commit": "a30396791c3f67b8f34d42dfc26db2f868ae9154" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope.nvim": { "branch": "master", "commit": "43c47ebc49ba601c7f0d06d65ce61d6aa8e670ab" }, + "toggleterm.nvim": { "branch": "main", "commit": "48be57eaba817f038d61bbf64d2c597f578c0827" }, + "vim-dispatch": { "branch": "master", "commit": "4c695bc052cad2ae6b980aebbe48d046466e27ae" }, + "vim-easy-align": { "branch": "master", "commit": "9815a55dbcd817784458df7a18acacc6f82b1241" }, + "vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" }, + "vim-gitgutter": { "branch": "main", "commit": "7b0b5098e3e57be86bb96cfbf2b8902381eef57c" }, + "vim-highlightedyank": { "branch": "master", "commit": "afb0f262b490706c23e94012c2ab9fa67c0481ce" }, + "vim-projectionist": { "branch": "master", "commit": "3736bd4a5f23b30821cbb892385bb1f1b0088cfc" }, + "vim-sneak": { "branch": "master", "commit": "c13d0497139b8796ff9c44ddb9bc0dc9770ad2dd" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-test": { "branch": "master", "commit": "c83d5dffa054ac4663aea1eb7374f638b0462510" } -} \ No newline at end of file + "vim-test": { "branch": "master", "commit": "75b64f23c923d34b56e47846a026210feb57146a" } +} diff --git a/.config/nvim/lua/halfdan/init.lua b/.config/nvim/lua/halfdan/init.lua index 29977e2..e598b41 100644 --- a/.config/nvim/lua/halfdan/init.lua +++ b/.config/nvim/lua/halfdan/init.lua @@ -16,7 +16,7 @@ else require('halfdan.colorscheme') require('halfdan.treesitter') require('halfdan.telescope') - -- require('halfdan.lualine') + require('halfdan.lualine') require('halfdan.autocmds') diff --git a/.config/nvim/lua/halfdan/lazy.lua b/.config/nvim/lua/halfdan/lazy.lua index 690db47..2b7717e 100644 --- a/.config/nvim/lua/halfdan/lazy.lua +++ b/.config/nvim/lua/halfdan/lazy.lua @@ -83,23 +83,39 @@ require("lazy").setup({ {'preservim/tagbar'}, + {'f-person/git-blame.nvim'}, -- Status Line and Bufferline - -- { - -- 'nvim-lualine/lualine.nvim', - -- dependencies = {'kyazdani42/nvim-web-devicons'} - -- }, - - {'rcarriga/nvim-notify'}, - - -- { "nvim-neorg/neorg" }, - -- {'nvim-neorg/neorg-telescope'}, - - {'justinmk/vim-sneak'}, - - {'machakann/vim-highlightedyank'}, - - -- LSP / Language Server Protocol { + 'nvim-lualine/lualine.nvim', + dependencies = {'kyazdani42/nvim-web-devicons'}, + event = { "BufReadPost", "BufNewFile" }, + opts = function() + local monokai_opts = require("halfdan.util").opts("monokai-pro.nvim") + return { + float = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), + separator = "bubble", -- bubble | triangle + ---@type any + colorful = true, + } + end, + config = function(_, opts) + local lualine_config = require("halfdan.lualine") + lualine_config.setup(opts) + lualine_config.load() + end, + }, + + {'rcarriga/nvim-notify'}, + + -- { "nvim-neorg/neorg" }, + -- {'nvim-neorg/neorg-telescope'}, + + {'justinmk/vim-sneak'}, + + {'machakann/vim-highlightedyank'}, + + -- LSP / Language Server Protocol + { 'neovim/nvim-lspconfig', 'williamboman/nvim-lsp-installer', }, @@ -176,6 +192,7 @@ require("lazy").setup({ -- Debugging "mfussenegger/nvim-dap", "rcarriga/nvim-dap-ui", + "nvim-neotest/nvim-nio", "theHamsta/nvim-dap-virtual-text", -- => Language Support @@ -190,10 +207,10 @@ require("lazy").setup({ local elixirls = require("elixir.elixirls") -- elixir.setup { - nextls = {enable = false}, + nextls = {enable = true}, credo = {}, elixirls = { - enable = true, + enable = false, settings = elixirls.settings { dialyzerEnabled = false, enableTestLenses = false, diff --git a/.config/nvim/lua/halfdan/lualine.lua b/.config/nvim/lua/halfdan/lualine.lua deleted file mode 100644 index c4747e2..0000000 --- a/.config/nvim/lua/halfdan/lualine.lua +++ /dev/null @@ -1,52 +0,0 @@ - -local function formatted_status() - local status = require'lsp-status'.status() - status = string.gsub(status, "%%", "%%%%") - return status -end - - -require 'lualine'.setup { - options = { - icons_enabled = true, - theme = 'monokai-pro', - --component_separators = {'', ''}, - --section_separators = {'', ''}, - disabled_filetypes = {} - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { 'filename' }, - lualine_x = { - {"require'lsp-status'.status()", fmt = function (str) - return string.gsub(str, "%%", "%%%%") - end}, - 'filetype' - }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { 'filename' }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = {}, - winbar = { - lualine_a = { - }, - lualine_b = {}, - lualine_c = { 'filename' }, - lualine_x = {}, - lualine_y = {}, - lualine_z = {} - }, - inactive_winbar = { - lualine_c = { 'filename' }, - } -} diff --git a/.config/nvim/lua/halfdan/lualine/components.lua b/.config/nvim/lua/halfdan/lualine/components.lua new file mode 100644 index 0000000..c827ad1 --- /dev/null +++ b/.config/nvim/lua/halfdan/lualine/components.lua @@ -0,0 +1,160 @@ +local config = require("halfdan.lualine.config").options +local icons = require("halfdan.icons") + +local M = {} + +local hl_str = function(str, hl_cur, hl_after) + if hl_after == nil then + return "%#" .. hl_cur .. "#" .. str .. "%*" + end + return "%#" .. hl_cur .. "#" .. str .. "%*" .. "%#" .. hl_after .. "#" +end + +local function hide_in_width() + return vim.fn.winwidth(0) > 85 +end + +local prev_branch = "" +M.branch = { + "branch", + icons_enabled = false, + icon = hl_str("", "SLGitIcon", "SLBranchName"), + colored = false, + fmt = function(str) + if vim.bo.filetype == "toggleterm" then + str = prev_branch + elseif str == "" or str == nil then + str = "!=vcs" + end + prev_branch = str + local icon = hl_str(" ", "SLGitIcon", "SLBranchName") + return hl_str(config.separator_icon.left, "SLSeparator") + .. hl_str(icon, "SLGitIcon") + .. hl_str(str, "SLBranchName") + .. hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator") + end, +} + +M.position = function() + -- print(vim.inspect(config.separator_icon)) + local current_line = vim.fn.line(".") + local current_column = vim.fn.col(".") + local left_sep = hl_str(config.separator_icon.left, "SLSeparator") + local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator") + local str = "Ln " .. current_line .. ", Col " .. current_column + return left_sep .. hl_str(str, "SLPosition", "SLPosition") .. right_sep +end + +M.spaces = function() + local left_sep = hl_str(config.separator_icon.left, "SLSeparator") + local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator") + local str = "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") + return left_sep .. hl_str(str, "SLShiftWidth", "SLShiftWidth") .. right_sep +end + +M.diagnostics = function() + local function nvim_diagnostic() + local diagnostics = vim.diagnostic.get(0) + local count = { 0, 0, 0, 0 } + for _, diagnostic in ipairs(diagnostics) do + count[diagnostic.severity] = count[diagnostic.severity] + 1 + end + return count[vim.diagnostic.severity.ERROR], + count[vim.diagnostic.severity.WARN], + count[vim.diagnostic.severity.INFO], + count[vim.diagnostic.severity.HINT] + end + + local error_count, warn_count, info_count, hint_count = nvim_diagnostic() + local error_hl = hl_str(icons.diagnostics.Error .. " " .. error_count, "SLError", "SLError") + local warn_hl = hl_str(icons.diagnostics.Warn .. " " .. warn_count, "SLWarning", "SLWarning") + local info_hl = hl_str(icons.diagnostics.Info .. " " .. info_count, "SLInfo", "SLInfo") + local hint_hl = hl_str(icons.diagnostics.Hint .. " " .. hint_count, "SLInfo", "SLInfo") + local left_sep = hl_str(config.thin_separator_icon.left, "SLSeparator") + local right_sep = hl_str(config.thin_separator_icon.right, "SLSeparator", "SLSeparator") + return left_sep .. error_hl .. " " .. warn_hl .. " " .. hint_hl .. right_sep +end + +M.diff = { + "diff", + colored = true, + diff_color = { + added = "SLDiffAdd", + modified = "SLDiffChange", + removed = "SLDiffDelete", + }, + symbols = { + added = icons.git.added .. " ", + modified = icons.git.modified .. " ", + removed = icons.git.removed .. " ", + }, -- changes diff symbols + fmt = function(str) + if str == "" then + return "" + end + local left_sep = hl_str(config.thin_separator_icon.left, "SLSeparator") + local right_sep = hl_str(config.thin_separator_icon.right, "SLSeparator", "SLSeparator") + return left_sep .. str .. right_sep + end, + cond = hide_in_width, +} + +M.mode = { + "mode", + fmt = function(str) + local left_sep = hl_str(config.separator_icon.left, "SLSeparator", "SLPadding") + local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLPadding") + return left_sep .. hl_str(str, "SLMode") .. right_sep + end, +} + +local prev_filetype = "" +M.filetype = { + "filetype", + icons_enabled = false, + icons_only = false, + fmt = function(str) + local ui_filetypes = { + "help", + "packer", + "neogitstatus", + "NvimTree", + "Trouble", + "lir", + "Outline", + "spectre_panel", + "toggleterm", + "DressingSelect", + "neo-tree", + "", + } + local filetype_str = "" + + if str == "toggleterm" then + --  + filetype_str = "ToggleTerm " .. vim.api.nvim_buf_get_var(0, "toggle_number") + elseif str == "TelescopePrompt" then + filetype_str = "" + elseif str == "neo-tree" or str == "neo-tree-popup" then + if prev_filetype == "" then + return + end + filetype_str = prev_filetype + elseif str == "help" then + filetype_str = "" + elseif vim.tbl_contains(ui_filetypes, str) then + return + else + prev_filetype = str + filetype_str = str + end + local left_sep = hl_str(config.separator_icon.left, "SLSeparator") + local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator") + -- Upper case first character + filetype_str = filetype_str:gsub("%a", string.upper, 1) + local filetype_hl = hl_str(filetype_str, "SLFiletype", "SLFiletype") + return left_sep .. filetype_hl .. right_sep + end, +} + +return M diff --git a/.config/nvim/lua/halfdan/lualine/config.lua b/.config/nvim/lua/halfdan/lualine/config.lua new file mode 100644 index 0000000..ee41330 --- /dev/null +++ b/.config/nvim/lua/halfdan/lualine/config.lua @@ -0,0 +1,40 @@ +local M = {} + +---@class LualineConfig +local default = { + float = true, + separator = "bubble", -- bubble | triangle + ---@type any + colorful = true, + separator_icon = { left = "", right = " " }, + thin_separator_icon = { left = "", right = " " }, + -- separator_icon = { left = "█", right = "█" }, + -- thin_separator_icon = { left = " ", right = " " }, +} + +---@type LualineConfig +M.options = {} + +---@param type "bubble" | "triangle" +local function make_separator(type) + if type == "bubble" then + M.options.separator_icon = { left = "█", right = "█" } + M.options.thin_separator_icon = { left = " ", right = " " } + elseif type == "triangle" then + M.options.separator_icon = { left = "█", right = "█" } + M.options.thin_separator_icon = { left = " ", right = " " } + else + return + end +end + +M.setup = function(opts) + M.options = vim.tbl_deep_extend("force", {}, default, opts or {}) + if M.options.float then + make_separator(M.options.separator) + end +end + +M.setup() + +return M diff --git a/.config/nvim/lua/halfdan/lualine/highlights.lua b/.config/nvim/lua/halfdan/lualine/highlights.lua new file mode 100644 index 0000000..2fc5260 --- /dev/null +++ b/.config/nvim/lua/halfdan/lualine/highlights.lua @@ -0,0 +1,111 @@ +local M = {} +local util = require("halfdan.util") + +local function draw(groups) + if groups == nil then + return + end + for group, value in pairs(groups) do + vim.api.nvim_set_hl(0, group, value) + end +end + +local function generate(config, palette) + local float = config.float + local colorful = config.colorful + if colorful then + palette.yellow = util.get_highlight_value("String").foreground or "#ffff00" + palette.white = util.get_highlight_value("Normal").foreground or "#ffffff" + palette.red = util.get_highlight_value("DiagnosticError").foreground or "#ff0000" + palette.orange = util.get_highlight_value("DiagnosticWarn").foreground or "#ff7700" + palette.blue = util.get_highlight_value("DiagnosticHint").foreground or "#00ffff" + palette.magenta = util.get_highlight_value("Statement").foreground or "#ff00ff" + palette.green = util.get_highlight_value("healthSuccess").foreground or "#00ff00" + end + return { + SLGitIcon = { + bg = float and palette.float_background or palette.statusbar_bg, + fg = colorful and palette.white or palette.statusbar_fg, + }, + SLBranchName = { + bg = float and palette.float_background or palette.statusbar_bg, + fg = colorful and palette.yellow or palette.statusbar_fg, + }, + SLError = { + bg = float and palette.editor_bg or palette.statusbar_bg, + fg = colorful and palette.red or palette.statusbar_fg, + }, + SLWarning = { + bg = float and palette.editor_bg or palette.statusbar_bg, + fg = colorful and palette.orange or palette.statusbar_fg, + }, + SLInfo = { + bg = float and palette.editor_bg or palette.statusbar_bg, + fg = colorful and palette.blue or palette.statusbar_fg, + }, + SLDiffAdd = { + bg = float and palette.editor_bg or palette.statusbar_bg, + fg = colorful and palette.green or palette.statusbar_fg, + }, + SLDiffChange = { + bg = float and palette.editor_bg or palette.statusbar_bg, + fg = colorful and palette.yellow or palette.statusbar_fg, + }, + SLDiffDelete = { + bg = float and palette.editor_bg or palette.statusbar_bg, + fg = colorful and palette.red or palette.statusbar_fg, + }, + SLPosition = { + bg = float and palette.float_background or palette.statusbar_bg, + fg = colorful and palette.magenta or palette.statusbar_fg, + }, + SLFiletype = { + bg = float and palette.float_background or palette.statusbar_bg, + fg = colorful and palette.blue or palette.statusbar_fg, + }, + SLShiftWidth = { + bg = float and palette.float_background or palette.statusbar_bg, + fg = colorful and palette.yellow or palette.statusbar_fg, + }, + SLEncoding = { + bg = float and palette.float_background or palette.statusbar_bg, + fg = colorful and palette.green or palette.statusbar_fg, + }, + SLMode = { + bg = float and palette.float_background or palette.statusbar_bg, + fg = colorful and palette.green or palette.statusbar_fg, + bold = true, + }, + SLSeparatorUnused = { + bg = float and palette.float_background or palette.statusbar_bg, + fg = colorful and palette.editor_bg or palette.statusbar_fg, + }, + SLSeparator = { + bg = float and palette.editor_bg or palette.statusbar_bg, + fg = float and palette.float_background or palette.statusbar_bg, + }, + SLPadding = { + bg = float and palette.editor_bg or palette.statusbar_bg, + fg = palette.editor_bg, + }, + } +end + +---@param config LualineConfig +M.custom = function(config) + local statusline_hl = util.get_highlight_value("StatusLine") + local palette = { + float_background = util.get_highlight_value("CursorLine").background, + editor_bg = util.get_highlight_value("Normal").background or "NONE", + statusbar_bg = statusline_hl.background or "#000000", + statusbar_fg = statusline_hl.foreground or "#505050", + } + local groups = generate(config, palette) + + draw(groups) + -- clear theme if float ortherwhise, make it auto + local theme = config.float and { normal = { c = { bg = palette.editor_bg } } } or "auto" + return theme +end + +return M diff --git a/.config/nvim/lua/halfdan/lualine/init.lua b/.config/nvim/lua/halfdan/lualine/init.lua new file mode 100644 index 0000000..e89420a --- /dev/null +++ b/.config/nvim/lua/halfdan/lualine/init.lua @@ -0,0 +1,60 @@ +local config = require("halfdan.lualine.config") + +local git_blame = require('gitblame') +local M = {} + +local function setup() + local cpn = require("halfdan.lualine.components") + local theme = require("halfdan.lualine.highlights").custom(config.options) + + require("lualine").setup({ + options = { + theme = theme, + icons_enabled = true, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = { "dashboard", "lazy", "alpha" }, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = true, + refresh = { + statusline = 1000, + tabline = 1000, + -- winbar = 100, + }, + }, + sections = { + lualine_a = { cpn.branch }, + lualine_b = { cpn.diagnostics }, + lualine_c = {}, + lualine_x = { { git_blame.get_current_blame_text, cond = git_blame.is_blame_text_available }, cpn.diff }, + lualine_y = { cpn.position, cpn.filetype }, + lualine_z = { cpn.spaces, cpn.mode }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = {}, + }) +end + +M.setup = config.setup + +M.load = function() + setup() + vim.api.nvim_create_autocmd("ColorScheme", { + callback = function() + setup() + end, + }) +end + +return M diff --git a/.config/nvim/lua/halfdan/settings.lua b/.config/nvim/lua/halfdan/settings.lua index 7bd6be9..507fd8a 100644 --- a/.config/nvim/lua/halfdan/settings.lua +++ b/.config/nvim/lua/halfdan/settings.lua @@ -63,3 +63,7 @@ vim.g.netrw_preview = 1 -- Split preview vertically vim.g.netrw_alo = 1 -- Show preview window to the right vim.g.netrw_winsize = 30 -- Have the preview window take up 70% -- vim.g.netrw_liststyle = 3 -- Use tree style +-- +vim.g.gitblame_display_virtual_text = 0 +vim.g.gitblame_date_format = '%r' +vim.g.gitblame_message_template = ''