diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-08 15:28:34 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-08 15:28:34 +0200 |
commit | 56e16603121f94b6ea4b7125c596a09540569841 (patch) | |
tree | 252afa6c8680f58095771f437f6ad516fda4fe13 /.config/nvim/lua/cfg | |
parent | 235a49fe4ab108abbecf43066a7a37133bb49bc9 (diff) |
Latest updates from LunarVim, new handrolled colorscheme
Diffstat (limited to '.config/nvim/lua/cfg')
-rw-r--r-- | .config/nvim/lua/cfg/barbar/init.lua | 27 | ||||
-rw-r--r-- | .config/nvim/lua/cfg/dashboard/init.lua | 11 | ||||
-rw-r--r-- | .config/nvim/lua/cfg/galaxyline/init.lua | 106 | ||||
-rw-r--r-- | .config/nvim/lua/cfg/neoformat/init.lua | 29 | ||||
-rw-r--r-- | .config/nvim/lua/cfg/telescope/init.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/cfg/themes/dark.lua (renamed from .config/nvim/lua/cfg/themes/spacegray.lua) | 68 | ||||
-rw-r--r-- | .config/nvim/lua/cfg/utils/init.lua | 20 | ||||
-rw-r--r-- | .config/nvim/lua/cfg/vimtex/init.lua | 10 | ||||
-rw-r--r-- | .config/nvim/lua/cfg/which-key/init.lua | 47 |
9 files changed, 197 insertions, 123 deletions
diff --git a/.config/nvim/lua/cfg/barbar/init.lua b/.config/nvim/lua/cfg/barbar/init.lua new file mode 100644 index 0000000..5257de5 --- /dev/null +++ b/.config/nvim/lua/cfg/barbar/init.lua @@ -0,0 +1,27 @@ +vim.api.nvim_set_keymap("n", "<TAB>", ":BufferNext<CR>", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "<S-TAB>", ":BufferPrevious<CR>", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "<S-x>", ":BufferClose<CR>", { noremap = true, silent = true }) + +O.user_which_key["b"] = { + name = "Buffers", + j = { "<cmd>BufferPick<cr>", "jump to buffer" }, + f = { "<cmd>Telescope buffers<cr>", "Find buffer" }, + w = { "<cmd>BufferWipeout<cr>", "wipeout buffer" }, + e = { + "<cmd>BufferCloseAllButCurrent<cr>", + "close all but current buffer", + }, + h = { "<cmd>BufferCloseBuffersLeft<cr>", "close all buffers to the left" }, + l = { + "<cmd>BufferCloseBuffersRight<cr>", + "close all BufferLines to the right", + }, + D = { + "<cmd>BufferOrderByDirectory<cr>", + "sort BufferLines automatically by directory", + }, + L = { + "<cmd>BufferOrderByLanguage<cr>", + "sort BufferLines automatically by language", + }, +} diff --git a/.config/nvim/lua/cfg/dashboard/init.lua b/.config/nvim/lua/cfg/dashboard/init.lua index bac9081..770bb5a 100644 --- a/.config/nvim/lua/cfg/dashboard/init.lua +++ b/.config/nvim/lua/cfg/dashboard/init.lua @@ -1,4 +1,3 @@ - local M = {} M.config = function() @@ -17,15 +16,15 @@ M.config = function() description = { " Recently Used Files" }, command = "Telescope oldfiles", }, + -- c = { + -- description = { " Load Last Session " }, + -- command = "SessionLoad", + -- }, c = { - description = { " Load Last Session " }, - command = "SessionLoad", - }, - d = { description = { " Find Word " }, command = "Telescope live_grep", }, - e = { + d = { description = { " Settings " }, command = ":e " .. CONFIG_PATH .. "/config.lua", }, diff --git a/.config/nvim/lua/cfg/galaxyline/init.lua b/.config/nvim/lua/cfg/galaxyline/init.lua index 536144d..c59d4f4 100644 --- a/.config/nvim/lua/cfg/galaxyline/init.lua +++ b/.config/nvim/lua/cfg/galaxyline/init.lua @@ -1,23 +1,30 @@ -local gl = require('galaxyline') +-- if not package.loaded['galaxyline'] then +-- return +-- end +local status_ok, gl = pcall(require, "galaxyline") +if not status_ok then + return +end -- get my theme in galaxyline repo +-- local colors = require('galaxyline.theme').default local colors = { - bg = '#080808', - yellow = '#DCDCAA', - dark_yellow = '#D7BA7D', - cyan = '#4EC9B0', - green = '#608B4E', - light_green = '#B5CEA8', - string_orange = '#CE9178', - orange = '#FF8800', - purple = '#C586C0', - magenta = '#D16D9E', - grey = '#858585', - blue = '#569CD6', - vivid_blue = '#4FC1FF', - light_blue = '#9CDCFE', - red = '#D16969', - error_red = '#F44747', - info_yellow = '#FFCC66' + bg = "#0A0A0A", + yellow = "#DCDCAA", + dark_yellow = "#D7BA7D", + cyan = "#4EC9B0", + green = "#608B4E", + light_green = "#B5CEA8", + string_orange = "#CE9178", + orange = "#FF8800", + purple = "#C586C0", + magenta = "#D16D9E", + grey = "#858585", + blue = "#569CD6", + vivid_blue = "#4FC1FF", + light_blue = "#9CDCFE", + red = "#D16969", + error_red = "#F44747", + info_yellow = "#FFCC66", } local condition = require "galaxyline.condition" @@ -51,8 +58,9 @@ table.insert(gls.left, { t = colors.blue, } vim.api.nvim_command("hi GalaxyViMode guifg=" .. mode_color[vim.fn.mode()]) - return "▎" + return "▊" end, + separator_highlight = "StatusLineSeparator", highlight = "StatusLineNC", }, }) @@ -108,6 +116,60 @@ table.insert(gls.left, { }, }) +table.insert(gls.left, { + Filler = { + provider = function() + return " " + end, + highlight = "StatusLineGitDelete", + }, +}) +-- get output from shell command +function os.capture(cmd, raw) + local f = assert(io.popen(cmd, "r")) + local s = assert(f:read "*a") + f:close() + if raw then + return s + end + s = string.gsub(s, "^%s+", "") + s = string.gsub(s, "%s+$", "") + s = string.gsub(s, "[\n\r]+", " ") + return s +end +-- cleanup virtual env +local function env_cleanup(venv) + if string.find(venv, "/") then + local final_venv = venv + for w in venv:gmatch "([^/]+)" do + final_venv = w + end + venv = final_venv + end + return venv +end +local PythonEnv = function() + if vim.bo.filetype == "python" then + local venv = os.getenv "CONDA_DEFAULT_ENV" + if venv ~= nil then + return "🅒 (" .. env_cleanup(venv) .. ")" + end + venv = os.getenv "VIRTUAL_ENV" + if venv ~= nil then + return " (" .. env_cleanup(venv) .. ")" + end + return "" + end + return "" +end +table.insert(gls.left, { + VirtualEnv = { + provider = PythonEnv, + highlight = "StatusLineTreeSitter", + event = "BufEnter", + }, +}) + table.insert(gls.right, { DiagnosticError = { provider = "DiagnosticError", @@ -157,7 +219,7 @@ table.insert(gls.right, { }) local get_lsp_client = function(msg) - msg = msg or "No Active LSP Client" + msg = msg or "LSP Inactive" local buf_ft = vim.api.nvim_buf_get_option(0, "filetype") local clients = vim.lsp.get_active_clients() if next(clients) == nil then @@ -173,7 +235,7 @@ local get_lsp_client = function(msg) lsps = client.name else lsps = lsps .. ", " .. client.name - -- print("more", lsps) + -- print("more", lsps) end end end @@ -277,3 +339,5 @@ table.insert(gls.short_line_left, { highlight = "StatusLineNC", }, }) + +--table.insert(gls.short_line_right[1] = {BufferIcon = {provider = 'BufferIcon', highlight = {colors.grey, colors.bg}}}) diff --git a/.config/nvim/lua/cfg/neoformat/init.lua b/.config/nvim/lua/cfg/neoformat/init.lua index eb9596e..9a5ac76 100644 --- a/.config/nvim/lua/cfg/neoformat/init.lua +++ b/.config/nvim/lua/cfg/neoformat/init.lua @@ -1,12 +1,23 @@ -- autoformat if O.format_on_save then - require("cfg.utils").define_augroups { - autoformat = { - { - "BufWritePre", - "*", - [[try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry]], - }, - }, - } + require("cfg.utils").define_augroups({ + autoformat = { + { + "BufWritePre", + "*", + [[try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry]], + }, + }, + }) +end + +vim.g.neoformat_run_all_formatters = 0 + +vim.g.neoformat_enabled_python = { "flake8", "black", "docformatter" } +vim.g.neoformat_enabled_javascript = { "prettier" } + +if not O.format_on_save then + vim.cmd([[if exists('#autoformat#BufWritePre') + :autocmd! autoformat + endif]]) end diff --git a/.config/nvim/lua/cfg/telescope/init.lua b/.config/nvim/lua/cfg/telescope/init.lua index 5411c32..9e0c45f 100644 --- a/.config/nvim/lua/cfg/telescope/init.lua +++ b/.config/nvim/lua/cfg/telescope/init.lua @@ -36,7 +36,7 @@ telescope.setup { file_sorter = require("telescope.sorters").get_fzy_sorter, file_ignore_patterns = {}, generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - shorten_path = true, + path_display = {"shorten"}, winblend = 0, border = {}, borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, diff --git a/.config/nvim/lua/cfg/themes/spacegray.lua b/.config/nvim/lua/cfg/themes/dark.lua index 0bb695c..fe2ff03 100644 --- a/.config/nvim/lua/cfg/themes/spacegray.lua +++ b/.config/nvim/lua/cfg/themes/dark.lua @@ -3,46 +3,40 @@ local hsl = lush.hsl local theme = lush(function() local c = { - bg = hsl "#212121", - bg1 = hsl "#2a2a2a", - -- bg2 = hsl("#3a3a3a"), - bg2 = hsl "#383d45", + bg = hsl "#0A0A0A", + bg1 = hsl "#0D0D0D", + bg2 = hsl "#202020", - white = hsl "#c8c9d1", + white = hsl "#f5f5f5", - gray = hsl "#858585", - light_gray = hsl "#c8c9c1", + gray = hsl "#505050", + light_gray = hsl "#D0D0D0", - error_red = hsl "#F44747", - warning_orange = hsl "#ff8800", - info_yellow = hsl "#ffcc66", - hint_blue = hsl "#4fc1ff", + error_red = hsl "#AC4142", + warning_orange = hsl "#F4BF75", + info_yellow = hsl "#F4BF75", + hint_blue = hsl "#A5D6FF", - red = hsl "#b04b57", + red = hsl "#AC4142", - blue = hsl "#5486c0", - gray_blue = hsl "#66899d", + blue = hsl "#A5D6FF", + gray_blue = hsl "#A5D6FF", - -- yellow = hsl("#ffcb6b"), - yellow = hsl "#eeba5a", + yellow = hsl "#F4BF75", - -- orange = hsl("#c98a75"), - orange = hsl "#c6735a", + orange = hsl "#FFA657", - green = hsl "#87b379", - light_green = hsl "#b2d77c", + green = hsl "#A1B56C", + light_green = hsl "#A1B56C", - -- aqua = hsl("#46b1d0"), - aqua = hsl "#65a7c5", + aqua = hsl "#A5D6FF", - purple = hsl "#bf83c1", - pale_purple = hsl "#7199ee", + purple = hsl "#AA759F", + pale_purple = hsl "#A5D6FF", - sign_add = hsl "#587C0C", - sign_change = hsl "#0C7D9D", - sign_delete = hsl "#94151B", - - test = hsl "#ff00ff", + sign_add = hsl "#A1B56C", + sign_change = hsl "#A5D6FF", + sign_delete = hsl "#AC4142", } return { Normal { bg = c.bg, fg = c.white, gui = "NONE" }, -- used for the columns set with 'colorcolumn' @@ -99,7 +93,7 @@ local theme = lush(function() EndOfBuffer { bg = "NONE", fg = c.bg, gui = "NONE" }, NonText { EndOfBuffer }, - String { fg = c.green }, + String { fg = c.blue }, Character { fg = c.light_green }, Constant { fg = c.orange }, Number { fg = c.red }, @@ -107,10 +101,10 @@ local theme = lush(function() Float { fg = c.red }, Identifier { fg = c.white }, - Function { fg = c.yellow }, - Operator { fg = c.gray_blue }, + Function { fg = c.orange }, + Operator { fg = c.orange }, - Type { fg = c.purple }, + Type { fg = c.blue }, StorageClass { Type }, Structure { Type }, Typedef { Type }, @@ -271,8 +265,8 @@ local theme = lush(function() -- BarBar TabLine { bg = c.bg1, fg = c.white, gui = "NONE" }, - TabLineFill { bg = c.bg1, fg = c.white, gui = "NONE" }, - TabLineSel { bg = c.blue, fg = c.bg1, gui = "NONE" }, + TabLineFill { bg = c.bg1, fg = c.gray, gui = "NONE" }, + TabLineSel { bg = c.white, fg = c.bg1, gui = "NONE" }, BufferCurrent { fg = c.fg, bg = c.bg }, BufferCurrentIndex { fg = c.aqua, bg = c.bg }, @@ -340,8 +334,8 @@ local theme = lush(function() TabLineHint { LspDiagnosticsSignHint }, TabLineInformation { LspDiagnosticsSignInformation }, -- which-key.nvim - WhichKey { fg = c.purple }, -- nvim-compe - WhichKeySeperator { fg = c.green }, -- nvim-compe + WhichKey { fg = c.white }, -- nvim-compe + WhichKeySeperator { fg = c.gray }, -- nvim-compe WhichKeyGroup { fg = c.blue }, -- nvim-compe WhichKeyDesc { fg = c.aqua }, -- nvim-compe WhichKeyFloat { bg = c.bg1 }, -- nvim-compe diff --git a/.config/nvim/lua/cfg/utils/init.lua b/.config/nvim/lua/cfg/utils/init.lua index f8ed082..2fe3331 100644 --- a/.config/nvim/lua/cfg/utils/init.lua +++ b/.config/nvim/lua/cfg/utils/init.lua @@ -3,7 +3,7 @@ local utils = {} function utils.reload_config() vim.cmd "source ~/.config/nvim/config.lua" vim.cmd "source ~/.config/nvim/lua/plugins.lua" - vim.cmd "source ~/.config/nvim/lua/neoformat/init.lua" + vim.cmd "source ~/.config/nvim/lua/cfg/neoformat/init.lua" vim.cmd ":PackerCompile" vim.cmd ":PackerInstall" end @@ -54,7 +54,7 @@ utils.define_augroups { "*", "setlocal formatoptions-=c formatoptions-=r formatoptions-=o", }, - { "BufWritePost", "config.lua", "lua require('utils').reload_config()" }, + { "BufWritePost", "config.lua", "lua require('cfg.utils').reload_config()" }, { "VimLeavePre", "*", "set title set titleold=" }, }, -- _solidity = { @@ -74,7 +74,11 @@ utils.define_augroups { }, _auto_resize = { -- will cause split windows to be resized evenly if main window is resized - { "VimResized ", "*", "wincmd =" }, + { "VimResized", "*", "wincmd =" }, + }, + _packer_compile = { + -- will cause split windows to be resized evenly if main window is resized + { "BufWritePost", "plugins.lua", "PackerCompile" }, }, -- _mode_switching = { -- -- will switch between absolute and relative line numbers depending on mode @@ -85,4 +89,14 @@ utils.define_augroups { -- }, } +vim.cmd [[ + function! QuickFixToggle() + if empty(filter(getwininfo(), 'v:val.quickfix')) + copen + else + cclose + endif +endfunction +]] + return utils diff --git a/.config/nvim/lua/cfg/vimtex/init.lua b/.config/nvim/lua/cfg/vimtex/init.lua index 11ed68b..4d7b93b 100644 --- a/.config/nvim/lua/cfg/vimtex/init.lua +++ b/.config/nvim/lua/cfg/vimtex/init.lua @@ -2,6 +2,16 @@ vim.g.vimtex_compiler_method = "latexmk" vim.g.vimtex_view_method = "zathura" vim.g.vimtex_fold_enabled = 0 +O.user_which_key["L"] = { + name = "+Latex", + c = { "<cmd>VimtexCompile<cr>", "Toggle Compilation Mode" }, + f = { "<cmd>call vimtex#fzf#run()<cr>", "Fzf Find" }, + i = { "<cmd>VimtexInfo<cr>", "Project Information" }, + s = { "<cmd>VimtexStop<cr>", "Stop Project Compilation" }, + t = { "<cmd>VimtexTocToggle<cr>", "Toggle Table Of Content" }, + v = { "<cmd>VimtexView<cr>", "View PDF" }, +} + -- Compile on initialization, cleanup on quit vim.api.nvim_exec( [[ diff --git a/.config/nvim/lua/cfg/which-key/init.lua b/.config/nvim/lua/cfg/which-key/init.lua index 2a22c9c..993018c 100644 --- a/.config/nvim/lua/cfg/which-key/init.lua +++ b/.config/nvim/lua/cfg/which-key/init.lua @@ -99,7 +99,7 @@ vim.api.nvim_set_keymap( local mappings = { - ["."] = "LunarConfig", + ["."] = "Config", ["k"] = "Comment", ["c"] = "Close Buffer", ["e"] = "Explorer", @@ -108,29 +108,6 @@ local mappings = { [";"] = "Dashboard", ["v"] = "Vertical Split", ["h"] = "Horizontal Split", - b = { - name = "Buffers", - j = { "<cmd>BufferPick<cr>", "jump to buffer" }, - f = { "<cmd>Telescope buffers<cr>", "Find buffer" }, - w = { "<cmd>BufferWipeout<cr>", "wipeout buffer" }, - e = { - "<cmd>BufferCloseAllButCurrent<cr>", - "close all but current buffer", - }, - h = { "<cmd>BufferCloseBuffersLeft<cr>", "close all buffers to the left" }, - l = { - "<cmd>BufferCloseBuffersRight<cr>", - "close all BufferLines to the right", - }, - D = { - "<cmd>BufferOrderByDirectory<cr>", - "sort BufferLines automatically by directory", - }, - L = { - "<cmd>BufferOrderByLanguage<cr>", - "sort BufferLines automatically by language", - }, - }, p = { name = "Packer", c = { "<cmd>PackerCompile<cr>", "Compile" }, @@ -198,11 +175,6 @@ local mappings = { R = { "<cmd>Telescope registers<cr>", "Registers" }, t = { "<cmd>Telescope live_grep<cr>", "Text" }, }, - S = { - name = "Session", - s = { "<cmd>SessionSave<cr>", "Save Session" }, - l = { "<cmd>SessionLoad<cr>", "Load Session" }, - }, T = { name = "Treesitter", i = { ":TSConfigInfo<cr>", "Info" }, @@ -235,18 +207,6 @@ if O.plugin.telescope_project.active then mappings["P"] = "Projects" end -if O.lang.latex.active then - mappings["L"] = { - name = "+Latex", - c = { "<cmd>VimtexCompile<cr>", "Toggle Compilation Mode" }, - f = { "<cmd>call vimtex#fzf#run()<cr>", "Fzf Find" }, - i = { "<cmd>VimtexInfo<cr>", "Project Information" }, - s = { "<cmd>VimtexStop<cr>", "Stop Project Compilation" }, - t = { "<cmd>VimtexTocToggle<cr>", "Toggle Table Of Content" }, - v = { "<cmd>VimtexView<cr>", "View PDF" }, - } -end - if O.lushmode then mappings["L"] = { name = "+Lush", @@ -257,13 +217,8 @@ if O.lushmode then } end --- for _, v in pairs(O.user_which_key) do --- end for k, v in pairs(O.user_which_key) do mappings[k] = v - -- table.insert(mappings, O.user_which_key[1]) - -- print(k) - -- print(v) end local wk = require "which-key" |