From 731917422d912e853acef4d3d0fa4e4d576db0a7 Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Fri, 19 Aug 2022 18:29:54 +0930 Subject: [PATCH] general updates to nvim config --- .config/nvim/init.lua | 7 +- .config/nvim/lua/user/alpha.lua | 4 +- .config/nvim/lua/user/autocommands.lua | 34 +- .config/nvim/lua/user/colorscheme.lua | 2 +- .config/nvim/lua/user/icons.lua | 109 ----- .config/nvim/lua/user/keymaps.lua | 93 ++-- .config/nvim/lua/user/lualine.lua | 563 +++++-------------------- .config/nvim/lua/user/options.lua | 16 +- .config/nvim/lua/user/plugins.lua | 7 + .xmonad/xmonad.hs | 1 + 10 files changed, 199 insertions(+), 637 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index bd2a7e3..6415789 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -4,8 +4,8 @@ require("user.colorscheme") require("user.autocommands") require("user.cmp") require("user.navic") --- require("user.lsp-inlayhints") --- require("user.lsp") +require("user.lsp-inlayhints") +require("user.lsp") require("user.telescope") require("user.treesitter") require("user.autopairs") @@ -29,9 +29,11 @@ require("user.todo-comments") require("user.symbol-outline") require("user.notify") require("user.ts-context") +require("user.functions") require("user.illuminate") require("user.dap") require("user.lir") +require "user.winbar" require("user.options") require("user.nvim-webdev-icons") require("user.fidget") @@ -39,3 +41,4 @@ require("user.browse") require("user.surround") require("user.harpoon") require("user.vim-slash") +require("user.lualine") diff --git a/.config/nvim/lua/user/alpha.lua b/.config/nvim/lua/user/alpha.lua index ccbda35..2910959 100644 --- a/.config/nvim/lua/user/alpha.lua +++ b/.config/nvim/lua/user/alpha.lua @@ -27,8 +27,6 @@ dashboard.section.buttons.val = { button("p", icons.git.Repo .. " Find project", ":lua require('telescope').extensions.projects.projects()"), button("r", icons.ui.History .. " Recent files", ":Telescope oldfiles "), button("t", icons.ui.List .. " Find text", ":Telescope live_grep "), - -- dashboard.button("s", icons.ui.SignIn .. " Find Session", ":silent Autosession search "), - button("s", icons.ui.SignIn .. " Find Session", ":SearchSession"), button("c", icons.ui.Gear .. " Config", ":e ~/.config/nvim/init.lua "), button("u", icons.ui.CloudDownload .. " Update", ":PackerSync"), button("q", icons.ui.SignOut .. " Quit", ":qa"), @@ -39,7 +37,7 @@ local function footer() -- local fortune = handle:read("*a") -- handle:close() -- return fortune - return "chrisatmachine.com" + return "inkletblot.com" end dashboard.section.footer.val = footer() diff --git a/.config/nvim/lua/user/autocommands.lua b/.config/nvim/lua/user/autocommands.lua index 6c7112e..3e1a0cc 100644 --- a/.config/nvim/lua/user/autocommands.lua +++ b/.config/nvim/lua/user/autocommands.lua @@ -31,9 +31,9 @@ vim.api.nvim_create_autocmd({ "FileType" }, { }, callback = function() vim.cmd [[ - nnoremap q :close - nnoremap :close - set nobuflisted + nnoremap q :close + nnoremap :close + set nobuflisted ]] end, }) @@ -43,8 +43,8 @@ vim.api.nvim_create_autocmd({ "FileType" }, { callback = function() vim.cmd [[ nnoremap :close - " nnoremap - set nobuflisted + " nnoremap + set nobuflisted ]] end, }) @@ -55,10 +55,10 @@ vim.api.nvim_create_autocmd({ "BufEnter" }, { local buf_ft = vim.bo.filetype if buf_ft == "" or buf_ft == nil then vim.cmd [[ - nnoremap q :close - nnoremap j - nnoremap k - set nobuflisted + nnoremap q :close + nnoremap j + nnoremap k + set nobuflisted ]] end end, @@ -187,3 +187,19 @@ vim.api.nvim_create_autocmd({ "BufWritePost" }, { vim.lsp.buf.format { async = true } end, }) + +vim.cmd [[autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o]] + +vim.cmd [[autocmd BufRead,BufNewFile *.tex set filetype=tex]] + +vim.cmd [[ +autocmd BufWritePre * let currPos = getpos(".") +autocmd BufWritePre * %s/\s\+$//e +autocmd BufWritePre * %s/\n\+\%$//e +autocmd BufWritePre *.[ch] %s/\%$/\r/e +autocmd BufWritePre * cal cursor(currPos[1], currPos[2]) +]] + +vim.cmd [[autocmd BufWritePost ~/.xmonad/xmonad.hs,~/.config/xmobar/xmobar-main.hs,~/.config/xmobar/xmobar-sub.hs,~/.config/xmobar/xmobar-single.hs !xmonad --recompile && xmonad --restart]] + +vim.cmd [[autocmd VimLeave *.tex !texclear %]] diff --git a/.config/nvim/lua/user/colorscheme.lua b/.config/nvim/lua/user/colorscheme.lua index bd657c0..7c85054 100644 --- a/.config/nvim/lua/user/colorscheme.lua +++ b/.config/nvim/lua/user/colorscheme.lua @@ -1,4 +1,4 @@ -local colorscheme = "tokyonight" +local colorscheme = "gruvbox-material" local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) if not status_ok then diff --git a/.config/nvim/lua/user/icons.lua b/.config/nvim/lua/user/icons.lua index 380ebe7..230f020 100644 --- a/.config/nvim/lua/user/icons.lua +++ b/.config/nvim/lua/user/icons.lua @@ -2,9 +2,6 @@ -- go to the above and then enter u and the symbold should appear -- or go here and upload the font file: https://mathew-kurian.github.io/CharacterMap/ -- find more here: https://www.nerdfonts.com/cheat-sheet -vim.g.use_nerd_icons = false -if vim.fn.has "mac" == 1 or vim.g.use_nerd_icons then - -- elseif vim.fn.has "mac" == 1 then return { kind = { Text = "", @@ -114,109 +111,3 @@ if vim.fn.has "mac" == 1 or vim.g.use_nerd_icons then CircuitBoard = "", }, } -else - --   פּ ﯟ   蘒練 some other good icons - return { - kind = { - Text = " ", - Method = " ", - Function = " ", - Constructor = " ", - Field = " ", - Variable = " ", - Class = " ", - Interface = " ", - Module = " ", - Property = " ", - Unit = " ", - Value = " ", - Enum = " ", - Keyword = " ", - Snippet = " ", - Color = " ", - File = " ", - Reference = " ", - Folder = " ", - EnumMember = " ", - Constant = " ", - Struct = " ", - Event = " ", - Operator = " ", - TypeParameter = " ", - Misc = " ", - }, - type = { - Array = " ", - Number = " ", - String = " ", - Boolean = " ", - Object = " ", - }, - documents = { - File = " ", - Files = " ", - Folder = " ", - OpenFolder = " ", - }, - git = { - Add = " ", - Mod = " ", - Remove = " ", - Ignore = " ", - Rename = " ", - Diff = " ", - Repo = " ", - Octoface = " ", - }, - ui = { - ArrowClosed = "", - ArrowOpen = "", - Lock = " ", - Circle = " ", - BigCircle = " ", - BigUnfilledCircle = " ", - Close = " ", - NewFile = " ", - Search = " ", - Lightbulb = " ", - Project = " ", - Dashboard = " ", - History = " ", - Comment = " ", - Bug = " ", - Code = " ", - Telescope = " ", - Gear = " ", - Package = " ", - List = " ", - SignIn = " ", - SignOut = " ", - NoteBook = " ", - Check = " ", - Fire = " ", - Note = " ", - BookMark = " ", - Pencil = " ", - ChevronRight = "", - Table = " ", - Calendar = " ", - CloudDownload = " ", - }, - diagnostics = { - Error = " ", - Warning = " ", - Information = " ", - Question = " ", - Hint = " ", - }, - misc = { - Robot = " ", - Squirrel = " ", - Tag = " ", - Watch = " ", - Smiley = " ", - Package = " ", - CircuitBoard = " ", - }, - } -end diff --git a/.config/nvim/lua/user/keymaps.lua b/.config/nvim/lua/user/keymaps.lua index bf00f99..ae04369 100644 --- a/.config/nvim/lua/user/keymaps.lua +++ b/.config/nvim/lua/user/keymaps.lua @@ -1,90 +1,97 @@ local opts = { noremap = true, silent = true } - local term_opts = { silent = true } -- Shorten function name local keymap = vim.api.nvim_set_keymap --Remap space as leader key -keymap("n", "", "", opts) -vim.g.mapleader = " " -vim.g.maplocalleader = " " +keymap('n', '', '', opts) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' -- Modes --- normal_mode = "n", --- insert_mode = "i", --- visual_mode = "v", --- visual_block_mode = "x", --- term_mode = "t", --- command_mode = "c", +-- normal_mode = 'n', +-- insert_mode = 'i', +-- visual_mode = 'v', +-- visual_block_mode = 'x', +-- term_mode = 't', +-- command_mode = 'c', + +keymap('n', 'c', '"_c', opts) -- Normal -- -- Better window navigation -keymap("n", "", "h", opts) -keymap("n", "", "j", opts) -keymap("n", "", "k", opts) -keymap("n", "", "l", opts) +keymap('n', '', 'h', opts) +keymap('n', '', 'j', opts) +keymap('n', '', 'k', opts) +keymap('n', '', 'l', opts) -- Resize with arrows -keymap("n", "", ":resize -2", opts) -keymap("n", "", ":resize +2", opts) -keymap("n", "", ":vertical resize -2", opts) -keymap("n", "", ":vertical resize +2", opts) +keymap('n', '', ':resize -2', opts) +keymap('n', '', ':resize +2', opts) +keymap('n', '', ':vertical resize -2', opts) +keymap('n', '', ':vertical resize +2', opts) -- Naviagate buffers -keymap("n", "", ":bnext", opts) -keymap("n", "", ":bprevious", opts) +keymap('n', '', ':bnext', opts) +keymap('n', '', ':bprevious', opts) -- Move text up and down -keymap("n", "", ":m .+1==gi", opts) -keymap("n", "", ":m .-2==gi", opts) +keymap('n', '', ':m .+1==gi', opts) +keymap('n', '', ':m .-2==gi', opts) -- Insert -- -- Press jk fast to enter -keymap("i", "jk", "", opts) +keymap('i', 'jk', '', opts) -- Visual -- -- Stay in indent mode -keymap("v", "<", "", ">gv", opts) +keymap('v', '<', '', '>gv', opts) -- Move text up and down -keymap("v", "", ":m .+1==", opts) -keymap("v", "", ":m .-2==", opts) -keymap("v", "p", '"_dP', opts) -keymap("v", "P", '"_dP', opts) +keymap('v', '', ':m .+1==', opts) +keymap('v', '', ':m .-2==', opts) +keymap('v', 'p', '"_dP', opts) +keymap('v', 'P', '"_dP', opts) -- Visual Block -- -- Move text up and down -keymap("x", "J", ":move '>+1gv-gv", opts) -keymap("x", "K", ":move '<-2gv-gv", opts) -keymap("x", "", ":move '>+1gv-gv", opts) -keymap("x", "", ":move '<-2gv-gv", opts) +keymap('x', 'J', ':move ">+1gv-gv', opts) +keymap('x', 'K', ':move "<-2gv-gv', opts) +keymap('x', '', ':move ">+1gv-gv', opts) +keymap('x', '', ':move "<-2gv-gv', opts) -- My bit's an pieces currently unsorted -- Spellcheck -keymap("n", "o", ":setlocal spell! spelllang=en_us", opts) +keymap('n', 'o', ':setlocal spell! spelllang=en_us', opts) -- Tree -keymap("n", "n", ":NvimTreeToggle", opts) +keymap('n', 'n', ':NvimTreeToggle', opts) + +-- Goyo +keymap('n', 'f', ':Goyo', opts) -- Copy and Paste -keymap("n", "", "\"+y", opts) -keymap("n", "', '"+y', opts) +keymap('n', '", opts) +vim.cmd [[nnoremap S :%s//g]] +-- keymap('n', '', ':%s//g', opts) -- Compile the document with default compiler script -keymap("n", "c", ":w! | !compiler %", opts) +vim.cmd [[map c :w! \| !compiler "%"]] +-- keymap('n', 'c', ':w! | !compiler %', opts) -- Open compiled document -keymap("n", "p", ":!opout %", opts) +keymap('n', 'p', ':!opout %', opts) -- Attempt sudo for files that require it -keymap("n", "w!!", "execute 'silent! write !sudo tee % >/dev/null' edit!", opts) - - +keymap('n', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" edit!', opts) +keymap("n", "", "lua vim.lsp.buf.references()", opts) +keymap("n", "", "lua vim.lsp.buf.definition()", opts) +keymap("n", "", "ZenMode", opts) diff --git a/.config/nvim/lua/user/lualine.lua b/.config/nvim/lua/user/lualine.lua index be607a1..9f619bf 100644 --- a/.config/nvim/lua/user/lualine.lua +++ b/.config/nvim/lua/user/lualine.lua @@ -1,471 +1,124 @@ -M = {} -local status_ok, lualine = pcall(require, "lualine") -if not status_ok then - return +local colors = { + red = '#ca1243', + grey = '#a0a1a7', + black = '#383a42', + white = '#f3f3f3', + light_green = '#83a598', + orange = '#fe8019', + green = '#8ec07c', +} + +local theme = { + normal = { + a = { fg = colors.white, bg = colors.black }, + b = { fg = colors.white, bg = colors.grey }, + c = { fg = colors.black, bg = colors.white }, + z = { fg = colors.white, bg = colors.black }, + }, + insert = { a = { fg = colors.black, bg = colors.light_green } }, + visual = { a = { fg = colors.black, bg = colors.orange } }, + replace = { a = { fg = colors.black, bg = colors.green } }, +} + +local empty = require('lualine.component'):extend() +function empty:draw(default_highlight) + self.status = '' + self.applied_separator = '' + self:apply_highlights(default_highlight) + self:apply_section_separators() + return self.status end -local lualine_scheme = "darkplus_dark" --- local lualine_scheme = "onedarker_alt" - -local status_theme_ok, theme = pcall(require, "lualine.themes." .. lualine_scheme) -if not status_theme_ok then - return -end - --- check if value in table -local function contains(t, value) - for _, v in pairs(t) do - if v == value then - return true +-- Put proper separators and gaps between components in sections +local function process_sections(sections) + for name, section in pairs(sections) do + local left = name:sub(9, 10) < 'x' + for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do + table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } }) + end + for id, comp in ipairs(section) do + if type(comp) ~= 'table' then + comp = { comp } + section[id] = comp + end + comp.separator = left and { right = '' } or { left = '' } end end - return false + return sections end -local gray = "#32363e" -local dark_gray = "#282C34" -local dark_gray = "#282C34" -local red = "#D16969" -local blue = "#569CD6" -local green = "#6A9955" -local cyan = "#4EC9B0" -local orange = "#CE9178" -local indent = "#CE9178" -local yellow = "#DCDCAA" -local yellow_orange = "#D7BA7D" -local purple = "#C586C0" - -if lualine_scheme == "darkplus_dark" then - -- gray = "#3e3e3e" - gray = "#303030" - dark_gray = "#303030" - red = "#bf616a" - blue = "#5e81ac" - indent = "#A3BE8C" - green = "#A3BE8C" - cyan = "#88c0d0" - orange = "#C68A75" - yellow = "#DCDCAA" - yellow_orange = "#D7BA7D" - purple = "#B48EAD" +local function search_result() + if vim.v.hlsearch == 0 then + return '' + end + local last_search = vim.fn.getreg('/') + if not last_search or last_search == '' then + return '' + end + local searchcount = vim.fn.searchcount { maxcount = 9999 } + return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' end -local sl_hl = vim.api.nvim_get_hl_by_name("StatusLine", true) -local sl_hl_sep = vim.api.nvim_get_hl_by_name("StatusLineSeparator", true) - -vim.api.nvim_set_hl(0, "SLGitIcon", { fg = "#E8AB53", bg = dark_gray }) -vim.api.nvim_set_hl(0, "SLTermIcon", { fg = purple, bg = gray }) -vim.api.nvim_set_hl(0, "SLBranchName", { fg = "#abb2bf", bg = dark_gray, bold = false }) -vim.api.nvim_set_hl(0, "SLProgress", { fg = purple, bg = gray }) -vim.api.nvim_set_hl(0, "SLLocation", { fg = blue, bg = gray }) -vim.api.nvim_set_hl(0, "SLFT", { fg = cyan, bg = gray }) -vim.api.nvim_set_hl(0, "SLIndent", { fg = indent, bg = gray }) -vim.api.nvim_set_hl(0, "SLLSP", { fg = "#6b727f", bg = "NONE" }) -vim.api.nvim_set_hl(0, "SLSep", { fg = gray, bg = "NONE" }) -vim.api.nvim_set_hl(0, "SLFG", { fg = "#abb2bf", bg = "NONE" }) -vim.api.nvim_set_hl(0, "SLSeparator", { fg = "#6b727f", bg = "NONE", italic = true }) -vim.api.nvim_set_hl(0, "SLError", { fg = "#bf616a", bg = "NONE" }) -vim.api.nvim_set_hl(0, "SLWarning", { fg = "#D7BA7D", bg = "NONE" }) -vim.api.nvim_set_hl(0, "SLCopilot", { fg = "#6CC644", bg = "NONE" }) - -local hl_str = function(str, hl) - return "%#" .. hl .. "#" .. str .. "%*" +local function modified() + if vim.bo.modified then + return '+' + elseif vim.bo.modifiable == false or vim.bo.readonly == true then + return '-' + end + return '' end -local mode_color = { - n = blue, - i = orange, - v = "#b668cd", - [""] = "#b668cd", - V = "#b668cd", - -- c = '#B5CEA8', - -- c = '#D7BA7D', - c = "#46a6b2", - no = "#D16D9E", - s = green, - S = orange, - [""] = orange, - ic = red, - R = "#D16D9E", - Rv = red, - cv = blue, - ce = blue, - r = red, - rm = "#46a6b2", - ["r?"] = "#46a6b2", - ["!"] = "#46a6b2", - t = red, -} - -local left_pad = { - function() - return " " - end, - padding = 0, - color = function() - return { fg = gray } - end, -} - -local right_pad = { - function() - return " " - end, - padding = 0, - color = function() - return { fg = dark_gray } - end, -} - -local left_pad_alt = { - function() - return " " - end, - padding = 0, - color = function() - return { fg = gray } - end, -} - -local right_pad_alt = { - function() - return " " - end, - padding = 0, - color = function() - return { fg = gray } - end, -} - -local mode = { - -- mode component - function() - -- return "▊" - return " " - -- return "  " - end, - color = function() - -- auto change color according to neovims mode - return { fg = mode_color[vim.fn.mode()], bg = gray } - end, - padding = 0, -} - -local hide_in_width_60 = function() - return vim.o.columns > 60 -end - -local hide_in_width = function() - return vim.o.columns > 80 -end - -local hide_in_width_100 = function() - return vim.o.columns > 100 -end - -local icons = require "user.icons" - -local diagnostics = { - "diagnostics", - sources = { "nvim_diagnostic" }, - sections = { "error", "warn" }, - symbols = { - error = "%#SLError#" .. icons.diagnostics.Error .. "%*" .. " ", - warn = "%#SLWarning#" .. icons.diagnostics.Warning .. "%*" .. " ", - }, - colored = false, - update_in_insert = false, - always_visible = true, - padding = 0, -} - -local diff = { - "diff", - colored = false, - symbols = { added = icons.git.Add .. " ", modified = icons.git.Mod .. " ", removed = icons.git.Remove .. " " }, -- changes diff symbols - cond = hide_in_width_60, - separator = "%#SLSeparator#" .. "│ " .. "%*", -} - -local filetype = { - "filetype", - fmt = function(str) - local ui_filetypes = { - "help", - "packer", - "neogitstatus", - "NvimTree", - "Trouble", - "lir", - "Outline", - "spectre_panel", - "toggleterm", - "DressingSelect", - "", - "nil", - } - - local return_val = function(str) - return hl_str(" ", "SLSep") .. hl_str(str, "SLFT") .. hl_str("", "SLSep") - end - - if str == "TelescopePrompt" then - return return_val(icons.ui.Telescope) - end - - local function get_term_num() - local t_status_ok, toggle_num = pcall(vim.api.nvim_buf_get_var, 0, "toggle_number") - if not t_status_ok then - return "" - end - return toggle_num - end - - if str == "toggleterm" then - --  - local term = "%#SLTermIcon#" .. " " .. "%*" .. "%#SLFT#" .. get_term_num() .. "%*" - - return return_val(term) - end - - if contains(ui_filetypes, str) then - return "" - else - return return_val(str) - end - end, - icons_enabled = false, - padding = 0, -} - -local branch = { - "branch", - icons_enabled = true, - icon = "%#SLGitIcon#" .. " " .. "%*" .. "%#SLBranchName#", - -- color = "Constant", - colored = false, - padding = 0, - -- cond = hide_in_width_100, - fmt = function(str) - if str == "" or str == nil then - return "!=vcs" - end - - return str - end, -} - -local progress = { - "progress", - fmt = function(str) - -- return "▊" - return hl_str("", "SLSep") .. hl_str("%P/%L", "SLProgress") .. hl_str(" ", "SLSep") - -- return "  " - end, - -- color = "SLProgress", - padding = 0, -} - -local current_signature = { - function() - local buf_ft = vim.bo.filetype - - if buf_ft == "toggleterm" or buf_ft == "TelescopePrompt" then - return "" - end - if not pcall(require, "lsp_signature") then - return "" - end - local sig = require("lsp_signature").status_line(30) - local hint = sig.hint - - if not require("user.functions").isempty(hint) then - -- return "%#SLSeparator#│ : " .. hint .. "%*" - -- return "%#SLSeparator#│ " .. hint .. "%*" - return "%#SLSeparator# " .. hint .. "%*" - end - - return "" - end, - cond = hide_in_width_100, - padding = 0, -} - --- cool function for progress --- local progress = function() --- local current_line = vim.fn.line "." --- local total_lines = vim.fn.line "$" --- local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" } --- local line_ratio = current_line / total_lines --- local index = math.ceil(line_ratio * #chars) --- -- return chars[index] --- return "%#SLProgress#" .. chars[index] .. "%*" --- end - -local spaces = { - function() - local buf_ft = vim.bo.filetype - - local ui_filetypes = { - "help", - "packer", - "neogitstatus", - "NvimTree", - "Trouble", - "lir", - "Outline", - "spectre_panel", - "DressingSelect", - "", - } - local space = "" - - if contains(ui_filetypes, buf_ft) then - space = " " - end - - local shiftwidth = vim.api.nvim_buf_get_option(0, "shiftwidth") - - if shiftwidth == nil then - return "" - end - - -- TODO: update codicons and use their indent - return hl_str(" ", "SLSep") .. hl_str(" " .. shiftwidth .. space, "SLIndent") .. hl_str("", "SLSep") - end, - padding = 0, - -- separator = "%#SLSeparator#" .. " │" .. "%*", - -- cond = hide_in_width_100, -} - -local lanuage_server = { - function() - local buf_ft = vim.bo.filetype - local ui_filetypes = { - "help", - "packer", - "neogitstatus", - "NvimTree", - "Trouble", - "lir", - "Outline", - "spectre_panel", - "toggleterm", - "DressingSelect", - "TelescopePrompt", - "lspinfo", - "lsp-installer", - "", - } - - if contains(ui_filetypes, buf_ft) then - if M.language_servers == nil then - return "" - else - return M.language_servers - end - end - - local clients = vim.lsp.buf_get_clients() - local client_names = {} - local copilot_active = false - - -- add client - for _, client in pairs(clients) do - if client.name ~= "copilot" and client.name ~= "null-ls" then - table.insert(client_names, client.name) - end - if client.name == "copilot" then - copilot_active = true - end - end - - -- add formatter - local s = require "null-ls.sources" - local available_sources = s.get_available(buf_ft) - local registered = {} - for _, source in ipairs(available_sources) do - for method in pairs(source.methods) do - registered[method] = registered[method] or {} - table.insert(registered[method], source.name) - end - end - - local formatter = registered["NULL_LS_FORMATTING"] - local linter = registered["NULL_LS_DIAGNOSTICS"] - if formatter ~= nil then - vim.list_extend(client_names, formatter) - end - if linter ~= nil then - vim.list_extend(client_names, linter) - end - - -- join client names with commas - local client_names_str = table.concat(client_names, ", ") - - -- check client_names_str if empty - local language_servers = "" - local client_names_str_len = #client_names_str - if client_names_str_len ~= 0 then - language_servers = hl_str("", "SLSep") .. hl_str(client_names_str, "SLSeparator") .. hl_str("", "SLSep") - end - if copilot_active then - language_servers = language_servers .. "%#SLCopilot#" .. " " .. icons.git.Octoface .. "%*" - end - - if client_names_str_len == 0 and not copilot_active then - return "" - else - M.language_servers = language_servers - return language_servers:gsub(", anonymous source", "") - end - end, - padding = 0, - cond = hide_in_width, - -- separator = "%#SLSeparator#" .. " │" .. "%*", -} - -local location = { - "location", - fmt = function(str) - -- return "▊" - return hl_str(" ", "SLSep") .. hl_str(str, "SLLocation") .. hl_str(" ", "SLSep") - -- return "  " - end, - padding = 0, -} - -lualine.setup { +require('lualine').setup { options = { - globalstatus = true, - icons_enabled = true, - -- theme = "auto", - theme = theme, - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - disabled_filetypes = { "alpha", "dashboard" }, - always_divide_middle = true, + theme = 'gruvbox-material', + component_separators = '', + section_separators = { left = '', right = '' }, }, - sections = { - lualine_a = { left_pad, mode, branch, right_pad }, - lualine_b = { left_pad_alt, diagnostics, right_pad_alt }, - -- lualine_c = {}, - lualine_c = { current_signature }, - -- lualine_x = { diff, spaces, "encoding", filetype }, - -- lualine_x = { diff, lanuage_server, spaces, filetype }, - -- lualine_x = { lanuage_server, spaces, filetype }, - lualine_x = { lanuage_server, spaces, filetype }, - lualine_y = {}, - lualine_z = { location, progress }, + sections = process_sections { + lualine_a = { 'mode' }, + lualine_b = { + 'branch', + 'diff', + { + 'diagnostics', + source = { 'nvim' }, + sections = { 'error' }, + diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, + }, + { + 'diagnostics', + source = { 'nvim' }, + sections = { 'warn' }, + diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, + }, + { 'filename', file_status = false, path = 1 }, + { modified, color = { bg = colors.red } }, + { + '%w', + cond = function() + return vim.wo.previewwindow + end, + }, + { + '%r', + cond = function() + return vim.bo.readonly + end, + }, + { + '%q', + cond = function() + return vim.bo.buftype == 'quickfix' + end, + }, + }, + lualine_c = {}, + lualine_x = {}, + lualine_y = { search_result, 'filetype' }, + lualine_z = { '%l:%c', '%p%%/%L' }, }, inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {}, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, + lualine_c = { '%f %y %m' }, + lualine_x = {}, }, - tabline = {}, - extensions = {}, } diff --git a/.config/nvim/lua/user/options.lua b/.config/nvim/lua/user/options.lua index adf0b5c..3da19b3 100644 --- a/.config/nvim/lua/user/options.lua +++ b/.config/nvim/lua/user/options.lua @@ -32,7 +32,7 @@ local options = { relativenumber = true, -- set relative numbered lines numberwidth = 4, -- set number column width to 2 {default 4} signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time - wrap = false, -- display lines as one long line + wrap = true, -- display lines as one long line scrolloff = 8, -- is one of my fav sidescrolloff = 8, guifont = "monospace:h17", -- the font used in graphical neovim applications @@ -61,17 +61,3 @@ end vim.cmd "set whichwrap+=<,>,[,],h,l" vim.cmd [[set iskeyword+=-]] - --- I don't know enough yet to get these working so here's a work around -vim.api.nvim_command([[autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o]]) -vim.cmd [[autocmd BufRead,BufNewFile *.tex set filetype=tex]] -vim.api.nvim_command([[ -augroup TrimAndReset -autocmd BufWritePre * let currPos = getpos(".") -autocmd BufWritePre * %s/\s\+$//e -autocmd BufWritePre * %s/\n\+\%$//e -autocmd BufWritePre *.[ch] %s/\%$/\r/e -autocmd BufWritePre * cal cursor(currPos[1], currPos[2]) -augroup END -]]) -vim.cmd [[autocmd BufWritePost ~/.xmonad/xmonad.hs,~/.config/xmobar/xmobar-main.hs,~/.config/xmobar/xmobar-sub.hs,~/.config/xmobar/xmobar-single.hs !xmonad --recompile && xmonad --restart]] diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/user/plugins.lua index a6281cf..9728c3a 100644 --- a/.config/nvim/lua/user/plugins.lua +++ b/.config/nvim/lua/user/plugins.lua @@ -61,6 +61,7 @@ return packer.startup(function(use) use "simrat39/symbols-outline.nvim" use "RRethy/vim-illuminate" use "j-hui/fidget.nvim" + use "lvimuser/lsp-inlayhints.nvim" -- Completion use "hrsh7th/nvim-cmp" @@ -97,6 +98,8 @@ return packer.startup(function(use) -- Colorschemes use "folke/tokyonight.nvim" + use "sainnhe/gruvbox-material" + use 'RRethy/nvim-base16' -- Utility use "rcarriga/nvim-notify" @@ -105,6 +108,8 @@ return packer.startup(function(use) use "moll/vim-bbye" use "lewis6991/impatient.nvim" use "lalitmee/browse.nvim" + use 'junegunn/goyo.vim' + use 'junegunn/limelight.vim' -- Icon use "kyazdani42/nvim-web-devicons" @@ -160,8 +165,10 @@ return packer.startup(function(use) use "nacro90/numb.nvim" use "andymass/vim-matchup" use "folke/zen-mode.nvim" + use "fgheng/winbar.nvim" use "karb94/neoscroll.nvim" use "junegunn/vim-slash" + use 'vimwiki/vimwiki' -- Motion use "phaazon/hop.nvim" diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs index d0ad471..9726f31 100644 --- a/.xmonad/xmonad.hs +++ b/.xmonad/xmonad.hs @@ -69,6 +69,7 @@ import XMonad.Util.Run (runProcessWithInput, safeSpawn, spawnPipe) import XMonad.Util.SpawnOnce -- A simple way to switch between desktop and laptop related things +-- Don't forget this exists, I have previously confused myself by doing so. isLaptop :: Bool isLaptop = True