diff options
-rw-r--r-- | init.lua | 5 | ||||
-rw-r--r-- | lua/lv-barbar/init.lua | 27 | ||||
-rw-r--r-- | lua/lv-galaxyline/init.lua | 50 | ||||
-rw-r--r-- | lua/lv-utils/init.lua | 6 | ||||
-rw-r--r-- | lua/lv-vimtex/init.lua | 10 | ||||
-rw-r--r-- | lua/lv-which-key/init.lua | 44 | ||||
-rw-r--r-- | lua/plugins.lua | 26 |
7 files changed, 89 insertions, 79 deletions
@@ -4,9 +4,7 @@ vim.cmd("luafile " .. CONFIG_PATH .. "/lv-config.lua") require "settings" require "plugins" require "lv-utils" -require "lv-galaxyline" require "lv-treesitter" -require "lv-neoformat" if O.plugin.dashboard.active then require("lv-dashboard").config() end @@ -16,5 +14,4 @@ end -- require "lsp.emmet-ls" -- end -- if O.lang.tailwindcss.active then --- require "lsp.tailwindcss-ls" --- end +-- require "lsp.tailwind 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", "<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/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 = { "<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/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 = { "<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" }, @@ -161,6 +138,7 @@ local mappings = { "Checkout commit(for current file)", }, }, + l = { name = "LSP", a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" }, @@ -187,6 +165,7 @@ local mappings = { "Workspace Symbols", }, }, + s = { name = "Search", b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" }, @@ -198,11 +177,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" }, @@ -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 = { "<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", 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", "<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 }) + 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" |