diff --git a/lua/rayandrew/autocmds.lua b/lua/rayandrew/autocmds.lua index f8dbf81..c9ef1fb 100644 --- a/lua/rayandrew/autocmds.lua +++ b/lua/rayandrew/autocmds.lua @@ -1,9 +1,7 @@ -- Taken from -- https://github.com/LazyVim/LazyVim/blob/566049aa4a26a86219dd1ad1624f9a1bf18831b6/lua/lazyvim/config/autocmds.lua -local function augroup(name) - return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true }) -end +local augroup = require("rayandrew.util").augroup local autocmd = vim.api.nvim_create_autocmd diff --git a/lua/rayandrew/init.lua b/lua/rayandrew/init.lua index b0729fb..7c02aa7 100644 --- a/lua/rayandrew/init.lua +++ b/lua/rayandrew/init.lua @@ -6,6 +6,7 @@ function M.setup() require("rayandrew.autocmds") require("rayandrew.remap") require("rayandrew.theme").setup() + require("rayandrew.statusline").setup() end return M diff --git a/lua/rayandrew/plugins.lua b/lua/rayandrew/plugins.lua index cc49ab4..123470b 100644 --- a/lua/rayandrew/plugins.lua +++ b/lua/rayandrew/plugins.lua @@ -295,75 +295,75 @@ return { ------------------------------ -- User Interface ------------------------------ - { - "folke/noice.nvim", - event = "VeryLazy", - opts = { - lsp = { - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - hover = { - enabled = false, - }, - signature = { - enabled = false, - }, - }, - cmdline = { - enabled = true, - view = "cmdline", - }, - routes = { - { - filter = { - event = "msg_show", - any = { - { find = "%d+L, %d+B" }, - { find = "; after #%d+" }, - { find = "; before #%d+" }, - }, - }, - view = "mini", - }, - }, - presets = { - bottom_search = true, - command_palette = true, - long_message_to_split = true, - inc_rename = true, - }, - }, - -- stylua: ignore - keys = { - { "", function() require("noice").redirect(vim.fn.getcmdline()) end, mode = "c", desc = "Redirect Cmdline" }, - { "snl", function() require("noice").cmd("last") end, desc = "Noice Last Message" }, - { "snh", function() require("noice").cmd("history") end, desc = "Noice History" }, - { "sna", function() require("noice").cmd("all") end, desc = "Noice All" }, - { "snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" }, - { "", function() if not require("noice.lsp").scroll(4) then return "" end end, silent = true, expr = true, desc = "Scroll forward", mode = {"i", "n", "s"} }, - { "", function() if not require("noice.lsp").scroll(-4) then return "" end end, silent = true, expr = true, desc = "Scroll backward", mode = {"i", "n", "s"}}, - }, - }, + -- { + -- "folke/noice.nvim", + -- event = "VeryLazy", + -- opts = { + -- lsp = { + -- override = { + -- ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + -- ["vim.lsp.util.stylize_markdown"] = true, + -- ["cmp.entry.get_documentation"] = true, + -- }, + -- hover = { + -- enabled = false, + -- }, + -- signature = { + -- enabled = false, + -- }, + -- }, + -- cmdline = { + -- enabled = true, + -- view = "cmdline", + -- }, + -- routes = { + -- { + -- filter = { + -- event = "msg_show", + -- any = { + -- { find = "%d+L, %d+B" }, + -- { find = "; after #%d+" }, + -- { find = "; before #%d+" }, + -- }, + -- }, + -- view = "mini", + -- }, + -- }, + -- presets = { + -- bottom_search = true, + -- command_palette = true, + -- long_message_to_split = true, + -- inc_rename = true, + -- }, + -- }, + -- -- stylua: ignore + -- keys = { + -- { "", function() require("noice").redirect(vim.fn.getcmdline()) end, mode = "c", desc = "Redirect Cmdline" }, + -- { "snl", function() require("noice").cmd("last") end, desc = "Noice Last Message" }, + -- { "snh", function() require("noice").cmd("history") end, desc = "Noice History" }, + -- { "sna", function() require("noice").cmd("all") end, desc = "Noice All" }, + -- { "snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" }, + -- { "", function() if not require("noice.lsp").scroll(4) then return "" end end, silent = true, expr = true, desc = "Scroll forward", mode = {"i", "n", "s"} }, + -- { "", function() if not require("noice.lsp").scroll(-4) then return "" end end, silent = true, expr = true, desc = "Scroll backward", mode = {"i", "n", "s"}}, + -- }, + -- }, - { - "stevearc/dressing.nvim", - lazy = true, - init = function() - ---@diagnostic disable-next-line: duplicate-set-field - vim.ui.select = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.select(...) - end - ---@diagnostic disable-next-line: duplicate-set-field - vim.ui.input = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.input(...) - end - end, - }, + -- { + -- "stevearc/dressing.nvim", + -- lazy = true, + -- init = function() + -- ---@diagnostic disable-next-line: duplicate-set-field + -- vim.ui.select = function(...) + -- require("lazy").load({ plugins = { "dressing.nvim" } }) + -- return vim.ui.select(...) + -- end + -- ---@diagnostic disable-next-line: duplicate-set-field + -- vim.ui.input = function(...) + -- require("lazy").load({ plugins = { "dressing.nvim" } }) + -- return vim.ui.input(...) + -- end + -- end, + -- }, { "lukas-reineke/indent-blankline.nvim", diff --git a/lua/rayandrew/set.lua b/lua/rayandrew/set.lua index 3b2023c..24ef96c 100644 --- a/lua/rayandrew/set.lua +++ b/lua/rayandrew/set.lua @@ -24,7 +24,7 @@ opt.hlsearch = false opt.ignorecase = true -- Ignore case opt.incsearch = true opt.inccommand = "nosplit" -- preview incremental substitute -opt.laststatus = 0 +opt.laststatus = 2 opt.list = true -- Show some invisible characters (tabs... opt.mouse = "a" -- Enable mouse mode opt.nu = true @@ -32,6 +32,7 @@ opt.number = true -- Print line number opt.pumblend = 10 -- Popup blend opt.pumheight = 10 -- Maximum number of entries in a popup opt.relativenumber = true -- Relative line numbers +opt.ruler = false -- Disable ruler opt.scrolloff = 4 -- Lines of context opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } opt.shiftround = true -- Round indent diff --git a/lua/rayandrew/statusline.lua b/lua/rayandrew/statusline.lua new file mode 100644 index 0000000..c5ce57f --- /dev/null +++ b/lua/rayandrew/statusline.lua @@ -0,0 +1,99 @@ +local M = {} + +local modes = { + ["n"] = "NORMAL", + ["no"] = "NORMAL", + ["v"] = "VISUAL", + ["V"] = "VISUAL LINE", + [""] = "VISUAL BLOCK", + ["s"] = "SELECT", + ["S"] = "SELECT LINE", + [""] = "SELECT BLOCK", + ["i"] = "INSERT", + ["ic"] = "INSERT", + ["R"] = "REPLACE", + ["Rv"] = "VISUAL REPLACE", + ["c"] = "COMMAND", + ["cv"] = "VIM EX", + ["ce"] = "EX", + ["r"] = "PROMPT", + ["rm"] = "MOAR", + ["r?"] = "CONFIRM", + ["!"] = "SHELL", + ["t"] = "TERMINAL", +} + +local function mode() + local current_mode = vim.api.nvim_get_mode().mode + return string.format(" %s ", modes[current_mode]):upper() +end + +local function filepath() + local fpath = vim.fn.fnamemodify(vim.fn.expand("%"), ":~:.:h") + if fpath == "" or fpath == "." then + return " " + end + + return string.format(" %%<%s/", fpath) +end + +local function update_mode_colors() + local current_mode = vim.api.nvim_get_mode().mode + local mode_color = "%#StatusLineAccent#" + if current_mode == "n" then + mode_color = "%#StatuslineAccent#" + elseif current_mode == "i" or current_mode == "ic" then + mode_color = "%#StatuslineInsertAccent#" + elseif current_mode == "v" or current_mode == "V" or current_mode == "" then + mode_color = "%#StatuslineVisualAccent#" + elseif current_mode == "R" then + mode_color = "%#StatuslineReplaceAccent#" + elseif current_mode == "c" then + mode_color = "%#StatuslineCmdLineAccent#" + elseif current_mode == "t" then + mode_color = "%#StatuslineTerminalAccent#" + end + return mode_color +end + +local function filename() + local fname = vim.fn.expand("%:t") + if fname == "" then + return "" + end + return fname .. " " +end + +function M.render() + local parts = { + "%#Statusline#", + update_mode_colors(), + mode(), + "%#Normal# ", + "%=%#StatusLineExtra#", + filepath(), + filename(), + } + + local statusline = table.concat(parts, "") + + return statusline +end + +function M.setup() + local augroup = require("rayandrew.util").augroup + local autocmd = vim.api.nvim_create_autocmd + + -- Statusline + autocmd({ "BufEnter", "BufWinEnter", "WinEnter" }, { + group = augroup("statusline"), + pattern = "*", + callback = function() + -- vim.opt_local.statusline = "%!v:lua.require('rayandrew.util').statusline()" + vim.opt_local.statusline = M.render() + end, + -- command = [[lua require("rayandrew.util").render()]], + }) +end + +return M diff --git a/lua/rayandrew/util.lua b/lua/rayandrew/util.lua index 61f8bb5..bb5532e 100644 --- a/lua/rayandrew/util.lua +++ b/lua/rayandrew/util.lua @@ -3,6 +3,10 @@ local M = {} +function M.augroup(name) + return vim.api.nvim_create_augroup("rayandrew_" .. name, { clear = true }) +end + ---@param on_attach fun(client, buffer) function M.on_attach(on_attach) vim.api.nvim_create_autocmd("LspAttach", {