From 23c7fab3b49560915f0fa6bdf07b399b6d9b75d9 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Wed, 7 Jul 2021 21:57:36 -0400 Subject: more lazy load be careful --- lua/lv-barbar/init.lua | 27 +++++++++++++++++++++++++ lua/lv-galaxyline/init.lua | 50 +++++++++++++++++++++++++--------------------- lua/lv-utils/init.lua | 6 +++++- lua/lv-vimtex/init.lua | 10 ++++++++++ lua/lv-which-key/init.lua | 44 ++-------------------------------------- lua/plugins.lua | 26 +++++++++++++++--------- 6 files changed, 88 insertions(+), 75 deletions(-) create mode 100644 lua/lv-barbar/init.lua (limited to 'lua') diff --git a/lua/lv-barbar/init.lua b/lua/lv-barbar/init.lua new file mode 100644 index 00000000..5257de5b --- /dev/null +++ b/lua/lv-barbar/init.lua @@ -0,0 +1,27 @@ +vim.api.nvim_set_keymap("n", "", ":BufferNext", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "", ":BufferPrevious", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "", ":BufferClose", { noremap = true, silent = true }) + +O.user_which_key["b"] = { + name = "Buffers", + j = { "BufferPick", "jump to buffer" }, + f = { "Telescope buffers", "Find buffer" }, + w = { "BufferWipeout", "wipeout buffer" }, + e = { + "BufferCloseAllButCurrent", + "close all but current buffer", + }, + h = { "BufferCloseBuffersLeft", "close all buffers to the left" }, + l = { + "BufferCloseBuffersRight", + "close all BufferLines to the right", + }, + D = { + "BufferOrderByDirectory", + "sort BufferLines automatically by directory", + }, + L = { + "BufferOrderByLanguage", + "sort BufferLines automatically by language", + }, +} diff --git a/lua/lv-galaxyline/init.lua b/lua/lv-galaxyline/init.lua index 6bcf08f5..c7a8fa55 100644 --- a/lua/lv-galaxyline/init.lua +++ b/lua/lv-galaxyline/init.lua @@ -127,44 +127,48 @@ table.insert(gls.left, { }) -- get output from shell command function os.capture(cmd, raw) - local f = assert(io.popen(cmd, 'r')) - local s = assert(f:read('*a')) + 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]+', ' ') + 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 -function env_cleanup(venv) - if string.find(venv, "/") then - final_venv = venv - for w in venv:gmatch("([^/]+)") do final_venv=w end - venv = final_venv +local function env_cleanup(venv) + if string.find(venv, "/") then + local final_venv = venv + for w in venv:gmatch "([^/]+)" do + final_venv = w end - return venv + venv = final_venv + end + return venv end -local PythonEnv = function () - if vim.bo.filetype == 'python' then - venv = os.getenv('CONDA_DEFAULT_ENV') +local PythonEnv = function() + if vim.bo.filetype == "python" then + local venv = os.getenv "CONDA_DEFAULT_ENV" if venv ~= nil then - return "🅒 " .. env_cleanup(venv) + return "🅒 (" .. env_cleanup(venv) .. ")" end - venv = os.getenv('VIRTUAL_ENV') + venv = os.getenv "VIRTUAL_ENV" if venv ~= nil then - return "🐍 " .. env_cleanup(venv) + return "  (" .. env_cleanup(venv) .. ")" end - return '' + return "" end - return '' + return "" end table.insert(gls.left, { VirtualEnv = { provider = PythonEnv, - highlight = {colors.green, colors.bg}, - event = 'BufEnter' - } + highlight = "StatusLineTreeSitter", + event = "BufEnter", + }, }) table.insert(gls.right, { diff --git a/lua/lv-utils/init.lua b/lua/lv-utils/init.lua index f2a6b3cf..3546d13c 100644 --- a/lua/lv-utils/init.lua +++ b/lua/lv-utils/init.lua @@ -74,7 +74,11 @@ lv_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" }, }, -- _fterm_lazygit = { -- -- will cause esc key to exit lazy git diff --git a/lua/lv-vimtex/init.lua b/lua/lv-vimtex/init.lua index 11ed68bc..4d7b93bd 100644 --- a/lua/lv-vimtex/init.lua +++ b/lua/lv-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 = { "VimtexCompile", "Toggle Compilation Mode" }, + f = { "call vimtex#fzf#run()", "Fzf Find" }, + i = { "VimtexInfo", "Project Information" }, + s = { "VimtexStop", "Stop Project Compilation" }, + t = { "VimtexTocToggle", "Toggle Table Of Content" }, + v = { "VimtexView", "View PDF" }, +} + -- Compile on initialization, cleanup on quit vim.api.nvim_exec( [[ diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index b0014654..dbcbb9ae 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -101,29 +101,6 @@ local mappings = { ["f"] = "Find File", ["h"] = "No Highlight", [";"] = "Dashboard", - b = { - name = "Buffers", - j = { "BufferPick", "jump to buffer" }, - f = { "Telescope buffers", "Find buffer" }, - w = { "BufferWipeout", "wipeout buffer" }, - e = { - "BufferCloseAllButCurrent", - "close all but current buffer", - }, - h = { "BufferCloseBuffersLeft", "close all buffers to the left" }, - l = { - "BufferCloseBuffersRight", - "close all BufferLines to the right", - }, - D = { - "BufferOrderByDirectory", - "sort BufferLines automatically by directory", - }, - L = { - "BufferOrderByLanguage", - "sort BufferLines automatically by language", - }, - }, p = { name = "Packer", c = { "PackerCompile", "Compile" }, @@ -161,6 +138,7 @@ local mappings = { "Checkout commit(for current file)", }, }, + l = { name = "LSP", a = { "lua vim.lsp.buf.code_action()", "Code Action" }, @@ -187,6 +165,7 @@ local mappings = { "Workspace Symbols", }, }, + s = { name = "Search", b = { "Telescope git_branches", "Checkout branch" }, @@ -198,11 +177,6 @@ local mappings = { R = { "Telescope registers", "Registers" }, t = { "Telescope live_grep", "Text" }, }, - S = { - name = "Session", - s = { "SessionSave", "Save Session" }, - l = { "SessionLoad", "Load Session" }, - }, T = { name = "Treesitter", i = { ":TSConfigInfo", "Info" }, @@ -246,20 +220,6 @@ if O.plugin.telescope_project.active then mappings["P"] = "Projects" end --- [";"] = "Dashboard", - -if O.lang.latex.active then - mappings["L"] = { - name = "+Latex", - c = { "VimtexCompile", "Toggle Compilation Mode" }, - f = { "call vimtex#fzf#run()", "Fzf Find" }, - i = { "VimtexInfo", "Project Information" }, - s = { "VimtexStop", "Stop Project Compilation" }, - t = { "VimtexTocToggle", "Toggle Table Of Content" }, - v = { "VimtexView", "View PDF" }, - } -end - if O.lushmode then mappings["L"] = { name = "+Lush", diff --git a/lua/plugins.lua b/lua/plugins.lua index dae431a0..9f49e69d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -22,8 +22,6 @@ packer.init { }, } -vim.cmd "autocmd BufWritePost plugins.lua PackerCompile" - return require("packer").startup(function(use) -- Packer can manage itself as an optional plugin use "wbthomason/packer.nvim" @@ -57,7 +55,13 @@ return require("packer").startup(function(use) use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" } -- Neoformat - use { "sbdchd/neoformat" } + use { + "sbdchd/neoformat", + config = function() + require "lv-neoformat" + end, + event = "BufRead", + } use { "kyazdani42/nvim-tree.lua", @@ -118,16 +122,20 @@ return require("packer").startup(function(use) use { "kyazdani42/nvim-web-devicons" } -- Status Line and Bufferline - use { "glepnir/galaxyline.nvim" } + use { + "glepnir/galaxyline.nvim", + config = function() + require "lv-galaxyline" + end, + -- event = "VimEnter", + } use { "romgrk/barbar.nvim", config = function() - vim.api.nvim_set_keymap("n", "", ":BufferNext", { noremap = true, silent = true }) - vim.api.nvim_set_keymap("n", "", ":BufferPrevious", { noremap = true, silent = true }) - vim.api.nvim_set_keymap("n", "", ":BufferClose", { noremap = true, silent = true }) + require "lv-barbar" end, - -- event = "BufRead", + event = "BufWinEnter", } -- Builtins, these do not load by default @@ -156,7 +164,7 @@ return require("packer").startup(function(use) use { "norcalli/nvim-colorizer.lua", - event = "BufRead", + event = "BufWinEnter", config = function() require "lv-colorizer" -- vim.cmd "ColorizerReloadAllBuffers" -- cgit v1.2.3