From a7d7d03a01afae30fbb0d32a427897f4d80b91f3 Mon Sep 17 00:00:00 2001 From: winston Date: Sat, 11 Mar 2023 22:52:33 +0100 Subject: [PATCH] feat(nvim): replace feline with lualine, remove barbecue --- home/apps/neovim.nix | 2 + home/apps/neovim/after/plugin/catppuccin.lua | 3 + home/apps/neovim/after/plugin/copilot.lua | 10 +- home/apps/neovim/after/plugin/feline.lua | 73 -------------- home/apps/neovim/after/plugin/fidget.lua | 19 ++++ home/apps/neovim/after/plugin/lualine.lua | 101 +++++++++++++++++++ home/apps/neovim/after/plugin/neorg.lua | 9 +- home/apps/neovim/after/plugin/presence.lua | 31 ++++-- home/apps/neovim/after/plugin/which-key.lua | 26 ++--- home/apps/neovim/init.lua | 5 +- home/apps/neovim/lazy-lock.json | 26 ++--- home/apps/neovim/lua/binds.lua | 2 +- home/apps/neovim/lua/plugins.lua | 14 +-- 13 files changed, 191 insertions(+), 130 deletions(-) delete mode 100644 home/apps/neovim/after/plugin/feline.lua create mode 100644 home/apps/neovim/after/plugin/fidget.lua create mode 100644 home/apps/neovim/after/plugin/lualine.lua diff --git a/home/apps/neovim.nix b/home/apps/neovim.nix index 785079b..6633a2f 100644 --- a/home/apps/neovim.nix +++ b/home/apps/neovim.nix @@ -27,6 +27,8 @@ # lua stylua lua-language-server + luaPackages.tl + luaPackages.teal-language-server # data taplo diff --git a/home/apps/neovim/after/plugin/catppuccin.lua b/home/apps/neovim/after/plugin/catppuccin.lua index cee9953..b4f4723 100644 --- a/home/apps/neovim/after/plugin/catppuccin.lua +++ b/home/apps/neovim/after/plugin/catppuccin.lua @@ -73,6 +73,9 @@ catppuccin.setup({ BufferLineTabSeparator = { link = "FloatBorder" }, BufferLineSeparator = { link = "FloatBorder" }, BufferLineOffsetSeparator = { link = "FloatBorder" }, + -- + FidgetTitle = { fg = colors.subtext1 }, + FidgetTask = { fg = colors.subtext0 }, } end, mocha = function(colors) diff --git a/home/apps/neovim/after/plugin/copilot.lua b/home/apps/neovim/after/plugin/copilot.lua index cc3fdc3..d5b0954 100644 --- a/home/apps/neovim/after/plugin/copilot.lua +++ b/home/apps/neovim/after/plugin/copilot.lua @@ -1,4 +1,10 @@ -require("copilot").setup({ +local present, copilot = pcall(require, "copilot") + +if not present then + return +end + +copilot.setup({ panel = { enabled = false, }, @@ -11,7 +17,7 @@ require("copilot").setup({ }, }, filetypes = { - yaml = false, + yaml = true, markdown = false, help = false, gitcommit = false, diff --git a/home/apps/neovim/after/plugin/feline.lua b/home/apps/neovim/after/plugin/feline.lua deleted file mode 100644 index 42f4f9d..0000000 --- a/home/apps/neovim/after/plugin/feline.lua +++ /dev/null @@ -1,73 +0,0 @@ -local get_config = function() - -- unload these if loaded, so that theme switching works - package.loaded["feline"] = nil - package.loaded["catppuccin.groups.integrations.feline"] = nil - - local present, feline = pcall(require, "feline") - local ctp_present, ctp_feline = - pcall(require, "catppuccin.groups.integrations.feline") - - if not (present and ctp_present) then - return - end - - local clrs = require("catppuccin.palettes").get_palette() - ctp_feline.setup({ - assets = { - left_separator = "", - right_separator = "", - bar = "█", - mode_icon = " ", - dir = " ", - file = " ", - git = { - branch = " ", - added = " ", - changed = " ", - removed = " ", - }, - lsp = { - server = " ", - error = " ", - warning = " ", - info = " ", - hint = " ", - }, - }, - sett = { - show_modified = true, - curr_dir = clrs.mauve, - curr_file = clrs.blue, - bkg = clrs.crust, - }, - mode_colors = { - ["n"] = { "NORMAL", clrs.blue }, - }, - }) - - feline.setup({ - components = ctp_feline.get(), - force_inactive = { - filetypes = { - "^startify$", - "^fugitive$", - "^fugitiveblame$", - "^qf$", - "^help$", - }, - buftypes = { - "^terminal$", - }, - bufnames = {}, - }, - }) -end - -get_config() - -vim.api.nvim_create_autocmd("ColorScheme", { - pattern = "*", - callback = function() - get_config() - end, -}) diff --git a/home/apps/neovim/after/plugin/fidget.lua b/home/apps/neovim/after/plugin/fidget.lua new file mode 100644 index 0000000..13d7bea --- /dev/null +++ b/home/apps/neovim/after/plugin/fidget.lua @@ -0,0 +1,19 @@ +local present, fidget = pcall(require, "fidget") + +if not present then + return +end + +fidget.setup({ + text = { + spinner = "dots", + done = "﫠", + commenced = "init", + completed = "done", + }, + window = { blend = 0 }, + sources = { + ["copilot"] = { ignore = true }, + ["null-ls"] = { ignore = true }, + }, +}) diff --git a/home/apps/neovim/after/plugin/lualine.lua b/home/apps/neovim/after/plugin/lualine.lua new file mode 100644 index 0000000..42ec54b --- /dev/null +++ b/home/apps/neovim/after/plugin/lualine.lua @@ -0,0 +1,101 @@ +local present, lualine = pcall(require, "lualine") + +if not present then + return +end + +local navic_present, navic = pcall(require, "nvim-navic") + +if navic_present then + navic.setup({ + icons = { + File = " ", + Module = " ", + Namespace = " ", + Package = " ", + Class = " ", + Method = " ", + Property = " ", + Field = " ", + Constructor = " ", + Enum = " ", + Interface = " ", + Function = " ", + Variable = " ", + Constant = " ", + String = " ", + Number = " ", + Boolean = " ", + Array = " ", + Object = " ", + Key = " ", + Null = " ", + EnumMember = " ", + Struct = " ", + Event = " ", + Operator = " ", + TypeParameter = " ", + }, + }) +end + +local function navic_available() + return navic_present and navic.is_available() +end + +local function navic_get_location() + if not navic_available() then + return "" + end + return navic.get_location() +end + +local config = { + options = { + icons_enabled = true, + theme = "auto", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = true, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { + { + "mode", + fmt = function(str) + return " " .. str + end, + }, + }, + lualine_b = { + { "branch", icon = "" }, + "diff", + "diagnostics", + }, + lualine_c = { + { navic_get_location, condition = navic_available }, + "searchcount", + "lsp_progress", + }, + lualine_x = { "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, +} + +lualine.setup(config) diff --git a/home/apps/neovim/after/plugin/neorg.lua b/home/apps/neovim/after/plugin/neorg.lua index 27f0722..d345eae 100644 --- a/home/apps/neovim/after/plugin/neorg.lua +++ b/home/apps/neovim/after/plugin/neorg.lua @@ -1,5 +1,10 @@ -vim.env.CC = "g++" -require("neorg").setup({ +local present, neorg = pcall(require, "neorg") + +if not present then + return +end + +neorg.setup({ load = { ["core.defaults"] = {}, }, diff --git a/home/apps/neovim/after/plugin/presence.lua b/home/apps/neovim/after/plugin/presence.lua index 32bb562..9873e4e 100644 --- a/home/apps/neovim/after/plugin/presence.lua +++ b/home/apps/neovim/after/plugin/presence.lua @@ -13,6 +13,9 @@ local home = vim.fn.expand("$HOME") .. "/Code/" local blacklist = { [vim.fn.resolve(home .. "work")] = "Using nvim at work.", [vim.fn.resolve(home .. "freelance")] = "Using nvim to freelance.", + [vim.fn.resolve(vim.fn.stdpath("config"))] = "Configuring nvim. (" + .. require("lazy").stats().count + .. " plugins)", } local conceal = function(activity, info) @@ -38,14 +41,24 @@ presence:setup({ -- Main image display (either "neovim" or "file") main_image = "file", show_time = false, - -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches - ---@diagnostic disable-next-line: unused-local - buttons = { - { - label = "Steal the code", - url = "https://git.winston.sh/winston/holy-grail.git", - }, - }, + buttons = function(buffer, repo_url) + local concealed = conceal() + if concealed then + return { + { + label = "View my config", + url = "https://github.com/nekowinston/dotfiles", + }, + } + else + return { + { + label = "View the repository", + url = repo_url, + }, + } + end + end, file_assets = { ["k8s.yaml"] = { "Kubernetes", @@ -87,7 +100,7 @@ presence:setup({ if s ~= nil and not concealed then return "Working on " .. s else - return "Masochism " .. vStr + return nil end end, git_commit_text = "Committing changes", diff --git a/home/apps/neovim/after/plugin/which-key.lua b/home/apps/neovim/after/plugin/which-key.lua index c33d2b1..bd111c2 100644 --- a/home/apps/neovim/after/plugin/which-key.lua +++ b/home/apps/neovim/after/plugin/which-key.lua @@ -1,4 +1,9 @@ -local wk = require("which-key") +local present, wk = pcall(require, "which-key") + +if not present then + return +end + wk.setup({ key_labels = { [""] = "␣", @@ -17,8 +22,7 @@ wk.setup({ wk.register({ ["f"] = { name = "+Telescope", - b = { "Telescope file_browser", "File Browser" }, - c = { "Easypick chezmoi", "Chezmoi" }, + b = { "Telescope buffers", "File Browser" }, d = { "Telescope find_files", "Find File" }, g = { "Telescope live_grep", "Live Grep" }, h = { "Telescope help_tags", "Help Tags" }, @@ -45,19 +49,3 @@ wk.register({ sl = { "SessionLoad", "Load Session" }, }, }, { mode = { "n", "v" } }) - -wk.register({ - -- easier split navigation - [""] = { "j" }, - [""] = { "k" }, - [""] = { "l" }, - [""] = { "h" }, - ["\\"] = { "vsplit" }, - ["-"] = { "split" }, - ["x"] = { "q" }, - -- diffs - ["gd"] = { "Gvdiff!", "Diff vsplit" }, - ["gd"] = { "diffget", "Get from diff" }, - ["gdh"] = { "diffget //2", "Get diff from the left" }, - ["gdl"] = { "diffget //3", "Get diff from the right" }, -}) diff --git a/home/apps/neovim/init.lua b/home/apps/neovim/init.lua index c99499b..43f0402 100644 --- a/home/apps/neovim/init.lua +++ b/home/apps/neovim/init.lua @@ -12,9 +12,10 @@ vim.o.relativenumber = true -- scroll offsets vim.o.scrolloff = 5 vim.o.sidescrolloff = 15 --- always show status & tab line +-- always show status vim.o.laststatus = 3 -vim.o.showtabline = 2 +-- hide tab line +vim.o.showtabline = 0 vim.g.termguicolors = false -- completion height vim.o.pumheight = 15 diff --git a/home/apps/neovim/lazy-lock.json b/home/apps/neovim/lazy-lock.json index f2977cc..6a0df88 100644 --- a/home/apps/neovim/lazy-lock.json +++ b/home/apps/neovim/lazy-lock.json @@ -2,45 +2,45 @@ "asyncrun.vim": { "branch": "master", "commit": "80750a80e7999318f14d754bb68b64de7af93bc3" }, "asynctasks.vim": { "branch": "master", "commit": "784a4b1f75a913cc6c43dd6c4dbe69d648dbbfa5" }, "auto-dark-mode.nvim": { "branch": "master", "commit": "9a7515c180c73ccbab9fce7124e49914f88cd763" }, - "barbecue": { "branch": "main", "commit": "65df9a7d51f11df6bd4f8bd9f0d8b378e92bb9b0" }, "bufferline.nvim": { "branch": "main", "commit": "3677aceb9a72630b0613e56516c8f7151b86f95c" }, - "catppuccin": { "branch": "main", "commit": "be055a9a397f283dc09a544514632f4581299425" }, + "catppuccin": { "branch": "main", "commit": "90c4d1c6e1f8dd2cff9962b36a70b1e681947621" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "8fcc934a52af96120fe26358985c10c035984b53" }, "cmp-git": { "branch": "main", "commit": "a798a25b21e7204597f56029af2e8a17d65e2518" }, "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, - "comment.nvim": { "branch": "master", "commit": "6821b3ae27a57f1f3cf8ed030e4a55d70d0c4e43" }, + "comment.nvim": { "branch": "master", "commit": "8d3aa5c22c2d45e788c7a5fe13ad77368b783c20" }, "copilot.lua": { "branch": "master", "commit": "b41d4c9c7d4f5e0272bcf94061b88e244904c56f" }, "dressing.nvim": { "branch": "master", "commit": "5f44f829481640be0f96759c965ae22a3bcaf7ce" }, "editorconfig.nvim": { "branch": "master", "commit": "5b9e303e1d6f7abfe616ce4cc8d3fffc554790bf" }, - "feline.nvim": { "branch": "master", "commit": "d48b6f92c6ccdd6654c956f437be49ea160b5b0c" }, "fidget.nvim": { "branch": "main", "commit": "688b4fec4517650e29c3e63cfbb6e498b3112ba1" }, "friendly-snippets": { "branch": "main", "commit": "009887b76f15d16f69ae1341f86a7862f61cf2a1" }, "gitsigns.nvim": { "branch": "main", "commit": "b1f9cf7c5c5639c006c937fc1819e09f358210fc" }, - "go.nvim": { "branch": "master", "commit": "1844fd11a143aba3eec644c2e2099a20f79c1ec1" }, + "go.nvim": { "branch": "master", "commit": "f80661a7109373aedee491acd8ddadc57e5c60aa" }, "guihua.lua": { "branch": "master", "commit": "a19ac4447021f21383fadd7a9e1fc150d0b67e1f" }, "indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" }, "lazy.nvim": { "branch": "main", "commit": "5b4444f0d7e556deba3f7ca949a2ba0e2c3369fb" }, "lightspeed.nvim": { "branch": "main", "commit": "299eefa6a9e2d881f1194587c573dad619fdb96f" }, + "lsp-status.nvim": { "branch": "master", "commit": "54f48eb5017632d81d0fd40112065f1d062d0629" }, "lspkind.nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, "ltex-extra.nvim": { "branch": "master", "commit": "1d2f288ceedc70d5a9c00f55c0d0cc788b5164f2" }, + "lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" }, "markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" }, "neogit": { "branch": "master", "commit": "c4068a22a60981f1bedd9672cdad34b79411ed7a" }, - "neorg": { "branch": "main", "commit": "3e09f698b8a4151f2b4f77ee917e4b54388bc97a" }, - "null-ls.nvim": { "branch": "main", "commit": "ccd6cb05b176bff65819c85b8d29096b5e0750d4" }, + "neorg": { "branch": "main", "commit": "c2680e67a0aeeb9b0ef6f4d008228de63d14e46b" }, + "null-ls.nvim": { "branch": "main", "commit": "e172e1e3011e3d032dbeba6414644ba968570828" }, "nvim-autopairs": { "branch": "master", "commit": "e755f366721bc9e189ddecd39554559045ac0a18" }, "nvim-cmp": { "branch": "main", "commit": "feed47fd1da7a1bad2c7dca456ea19c8a5a9823a" }, "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, "nvim-dap": { "branch": "master", "commit": "73196075627a4f079c62b0dd4aff8ce0a1b7cf57" }, "nvim-dap-ui": { "branch": "master", "commit": "bdb94e3853d11b5ce98ec182e5a3719d5c0ef6fd" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "8db23ea51203b5f00ad107a0cef7e0b2d7a0476c" }, - "nvim-lspconfig": { "branch": "master", "commit": "2ba6e268d92934e14fe561fe446a49540803e57f" }, + "nvim-lspconfig": { "branch": "master", "commit": "4bb0f1845c5cc6465aecedc773fc2d619fcd8faf" }, "nvim-navic": { "branch": "master", "commit": "cdd24539bcf114a499827e9b32869fe74836efe7" }, - "nvim-surround": { "branch": "main", "commit": "e3d0cd0c70b7e96fd2f62c4979f1997d96c86673" }, + "nvim-surround": { "branch": "main", "commit": "177c95c12542cf20a422b19a87ba1ae80254445a" }, "nvim-tree.lua": { "branch": "master", "commit": "bbb6d4891009de7dab05ad8fc2d39f272d7a751c" }, - "nvim-treesitter": { "branch": "master", "commit": "fc1ca10bfbdee17e29374d0d1bac8ea030539dc3" }, + "nvim-treesitter": { "branch": "master", "commit": "11b2d430e6f501e29e6851aaf1bd6fa338072be6" }, "nvim-ts-autotag": { "branch": "main", "commit": "fdefe46c6807441460f11f11a167a2baf8e4534b" }, "nvim-ts-rainbow2": { "branch": "master", "commit": "6bcb1472c321a15eef5a7a015b4fefa8758e6513" }, "nvim-web-devicons": { "branch": "master", "commit": "4af94fec29f508159ceab5413383e5dedd6c24e3" }, @@ -50,10 +50,10 @@ "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "py_lsp.nvim": { "branch": "main", "commit": "5b2bd6433a2dbab76d54d58ccc1d1e89b220091c" }, "rust-tools.nvim": { "branch": "master", "commit": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f" }, - "schemastore.nvim": { "branch": "main", "commit": "42e12c5a76a9b7acf6694841a0c8fab07ce90926" }, + "schemastore.nvim": { "branch": "main", "commit": "083485d0ec106c46eb38b525342dc8e23a9921c9" }, "stabilize.nvim": { "branch": "master", "commit": "34069870a8e72632c5447188e638e1c6bfebc353" }, "telescope-asynctasks.nvim": { "branch": "main", "commit": "065300fb0a8ba6a1c81991da1873c73e136dcdc0" }, - "telescope-file-browser.nvim": { "branch": "master", "commit": "96095f922abce6e15f920aa2952c03eb95d5c57b" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "94fe37a1ea217dd2f90d91222bc1531521146ac3" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, "telescope-project.nvim": { "branch": "master", "commit": "8e8ee37b7210761502cdf2c3a82b5ba8fb5b2972" }, "telescope.nvim": { "branch": "master", "commit": "a3f17d3baf70df58b9d3544ea30abe52a7a832c2" }, @@ -64,7 +64,7 @@ "vim-dadbod": { "branch": "master", "commit": "389a2b0120f82b13d51ff7c07f5c13f9bc9f412f" }, "vim-dadbod-completion": { "branch": "master", "commit": "e71eb6140556c5ced80de6299a1fdfe22bd3c1b1" }, "vim-dadbod-ui": { "branch": "master", "commit": "caf45f54dad6150970331ac115e531524e418c7c" }, - "vim-fugitive": { "branch": "master", "commit": "82a9af133ce15afc232a9e754898a8ba252780e6" }, + "vim-fugitive": { "branch": "master", "commit": "5b52a0f395065d6cb7b65a00a5e17eaf9ebd64d5" }, "vim-gnupg": { "branch": "main", "commit": "f9b608f29003dfde6450931dc0f495a912973a88" }, "vim-helm": { "branch": "master", "commit": "c2e7b85711d410e1d73e64eb5df7b70b1c4c10eb" }, "vim-just": { "branch": "master", "commit": "838c9096d4c5d64d1000a6442a358746324c2123" }, diff --git a/home/apps/neovim/lua/binds.lua b/home/apps/neovim/lua/binds.lua index 13214ea..93c2e02 100644 --- a/home/apps/neovim/lua/binds.lua +++ b/home/apps/neovim/lua/binds.lua @@ -1,4 +1,4 @@ -function map(mode, shortcut, command, opt) +local map = function(mode, shortcut, command, opt) opt = opt or { noremap = true, silent = true } vim.keymap.set(mode, shortcut, command, opt) end diff --git a/home/apps/neovim/lua/plugins.lua b/home/apps/neovim/lua/plugins.lua index 0921056..f433549 100644 --- a/home/apps/neovim/lua/plugins.lua +++ b/home/apps/neovim/lua/plugins.lua @@ -17,16 +17,11 @@ local plugins = { "lewis6991/gitsigns.nvim", "lukas-reineke/indent-blankline.nvim", "akinsho/bufferline.nvim", - "feline-nvim/feline.nvim", { - "utilyre/barbecue.nvim", - name = "barbecue", + "nvim-lualine/lualine.nvim", dependencies = { - "SmiteshP/nvim-navic", "nvim-tree/nvim-web-devicons", - }, - opts = { - theme = "catppuccin", + "SmiteshP/nvim-navic", }, }, "luukvbaal/stabilize.nvim", @@ -135,8 +130,9 @@ local plugins = { "onsails/lspkind.nvim", "rafamadriz/friendly-snippets", "jose-elias-alvarez/null-ls.nvim", - "https://github.com/folke/trouble.nvim", - { "j-hui/fidget.nvim", opts = {} }, + "folke/trouble.nvim", + "nvim-lua/lsp-status.nvim", + "j-hui/fidget.nvim", "barreiroleo/ltex-extra.nvim", "b0o/schemastore.nvim", "hallerpatrick/py_lsp.nvim",