diff options
Diffstat (limited to 'nvim')
-rw-r--r-- | nvim/lazy-lock.json | 6 | ||||
-rw-r--r-- | nvim/lua/core/statusline.lua | 101 | ||||
-rw-r--r-- | nvim/lua/plugins/auto-pairs.lua | 3 | ||||
-rw-r--r-- | nvim/lua/plugins/comment.lua | 1 | ||||
-rw-r--r-- | nvim/lua/plugins/diffview.lua | 1 | ||||
-rw-r--r-- | nvim/lua/plugins/gitsigns.lua | 1 | ||||
-rw-r--r-- | nvim/lua/plugins/lsp.lua | 1 | ||||
-rw-r--r-- | nvim/lua/plugins/markdown-preview.lua | 1 | ||||
-rw-r--r-- | nvim/lua/plugins/telescope.lua | 1 | ||||
-rw-r--r-- | nvim/lua/plugins/todo-comments.lua | 1 | ||||
-rw-r--r-- | nvim/lua/plugins/treesitter.lua | 1 | ||||
-rw-r--r-- | nvim/lua/plugins/undotree.lua | 1 |
12 files changed, 78 insertions, 41 deletions
diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 6dabd45..d2a2d29 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -9,16 +9,16 @@ "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "gitsigns.nvim": { "branch": "main", "commit": "2eaa30537365f6889c850bd46ef6f18ddf8fac70" }, + "gitsigns.nvim": { "branch": "main", "commit": "68114837e81ca16d06514c3a997c9102d1b25c15" }, "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, "lsp-zero.nvim": { "branch": "v3.x", "commit": "ab2a3413646fedd77aa0eab4214a6473e62f6a64" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "97d9f1d3ad205dece6bcafd1d71cf1507608f3c7" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "nvim-autopairs": { "branch": "master", "commit": "d65a9678336c8b48753dba8bff49672cbeb7c892" }, + "nvim-autopairs": { "branch": "master", "commit": "d2f791ceeb26d04d87aa54343bc94e8ad8d7be1c" }, "nvim-cmp": { "branch": "main", "commit": "8c82d0bd31299dbff7f8e780f5e06d2283de9678" }, "nvim-lspconfig": { "branch": "master", "commit": "88157521e890fe7fdf18bee22438875edd6300a6" }, - "nvim-treesitter": { "branch": "master", "commit": "8ca76960ae75e0a3bb231402558eb50e79433161" }, + "nvim-treesitter": { "branch": "master", "commit": "306dd6e9dc806db1d79568d26e1c9b6c98b95fbc" }, "papercolor-theme": { "branch": "master", "commit": "0cfe64ffb24c21a6101b5f994ca342a74c977aef" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "telescope-undo.nvim": { "branch": "main", "commit": "2971cc9f193ec09e0c5de3563f99cbea16b63f10" }, diff --git a/nvim/lua/core/statusline.lua b/nvim/lua/core/statusline.lua index 45a2c42..cc4bd09 100644 --- a/nvim/lua/core/statusline.lua +++ b/nvim/lua/core/statusline.lua @@ -1,48 +1,75 @@ local M = {} -local function git_branch() - local git_dir = vim.fn.system("git rev-parse --git-dir 2>/dev/null") - if vim.v.shell_error ~= 0 then - return "" - end - local branch = vim.fn.system("git branch --show-current 2>/dev/null | tr -d '\n'") - return branch +local branch_cache = "" +local last_check = 0 +local check_interval = 1000 -- Check git branch every 1 second + +local function async_git_branch() + local check_time = vim.loop.now() + if check_time - last_check < check_interval then + return branch_cache + end + last_check = check_time + + local stdout = vim.loop.new_pipe(false) + local stderr = vim.loop.new_pipe(false) + + local handle + handle = vim.loop.spawn("git", { + args = { "branch", "--show-current" }, + stdio = { nil, stdout, stderr } + }, function(code, signal) + stdout:close() + stderr:close() + handle:close() + end) + + if handle then + stdout:read_start(vim.schedule_wrap(function(err, data) + if data then + branch_cache = data:gsub("\n", "") + end + end)) + end + + return branch_cache end function M.statusline_git() - local branch_name = git_branch() - return #branch_name > 0 and ' ' .. branch_name .. ' ' or '' + local branch_name = async_git_branch() + return #branch_name > 0 and ' ' .. branch_name .. ' ' or '' end +-- Rest of your statusline.lua remains exactly the same function M.setup() - vim.cmd('highlight clear StatusLine') - vim.cmd('highlight clear StatusLineNC') - - local highlights = { - StatusLineGit = { bg = "#161616", fg = "#D8DEE9" }, - StatusLineBuffer = { bg = "NONE", fg = "#D8DEE9" }, - StatusLine = { bg = "NONE", fg = "#D8DEE9" }, - StatusLineFiletype = { bg = "NONE", fg = "#D8DEE9" }, - StatusLinePath = { bg = "NONE", fg = "#D8DEE9" }, - StatusLineModified = { bg = "NONE", fg = "#D8DEE9" }, - } - - for name, colors in pairs(highlights) do - vim.api.nvim_set_hl(0, name, colors) - end - - vim.opt.statusline = table.concat({ - "%#StatusLineGit#%{v:lua.require'core.statusline'.statusline_git()}", - "%#StatusLineBuffer# %n ", - "%#StatusLine#%{&ff} ", - "%#StatusLineFiletype#%y", - "%#StatusLinePath# %<%{expand('%:p:h')}/%f", - "%#StatusLineModified#%m", - "%=", - "%#StatusLine#%5l", - "/%L:%v ", - "%{char2nr(getline('.')[col('.')-1])} " - }) + vim.cmd('highlight clear StatusLine') + vim.cmd('highlight clear StatusLineNC') + + local highlights = { + StatusLineGit = { bg = "#161616", fg = "#D8DEE9" }, + StatusLineBuffer = { bg = "NONE", fg = "#D8DEE9" }, + StatusLine = { bg = "NONE", fg = "#D8DEE9" }, + StatusLineFiletype = { bg = "NONE", fg = "#D8DEE9" }, + StatusLinePath = { bg = "NONE", fg = "#D8DEE9" }, + StatusLineModified = { bg = "NONE", fg = "#D8DEE9" }, + } + + for name, colors in pairs(highlights) do + vim.api.nvim_set_hl(0, name, colors) + end + + vim.opt.statusline = table.concat({ + "%#StatusLineGit#%{v:lua.require'core.statusline'.statusline_git()}", + "%#StatusLineBuffer# %n ", + "%#StatusLine#%{&ff} ", + "%#StatusLineFiletype#%y", + "%#StatusLinePath# %<%{expand('%:p:h')}/%f", + "%#StatusLineModified#%m", + "%=", + "%#StatusLine#%5l", + "/%L:%v ", + "%{char2nr(getline('.')[col('.')-1])} " + }) end vim.api.nvim_create_autocmd("ColorScheme", { diff --git a/nvim/lua/plugins/auto-pairs.lua b/nvim/lua/plugins/auto-pairs.lua index 7fdb560..1b9b728 100644 --- a/nvim/lua/plugins/auto-pairs.lua +++ b/nvim/lua/plugins/auto-pairs.lua @@ -2,6 +2,7 @@ return { { 'windwp/nvim-autopairs', event = "InsertEnter", - config = true + config = true, + lazy = false, }, } diff --git a/nvim/lua/plugins/comment.lua b/nvim/lua/plugins/comment.lua index e485b9b..f7fbda1 100644 --- a/nvim/lua/plugins/comment.lua +++ b/nvim/lua/plugins/comment.lua @@ -1,6 +1,7 @@ return { { "numToStr/Comment.nvim", + lazy = false, config = function() require('Comment').setup({ ---Add a space b/w comment and the line diff --git a/nvim/lua/plugins/diffview.lua b/nvim/lua/plugins/diffview.lua index ec440b1..fcd28c9 100644 --- a/nvim/lua/plugins/diffview.lua +++ b/nvim/lua/plugins/diffview.lua @@ -1,6 +1,7 @@ return { { "sindrets/diffview.nvim", + lazy = false, config = function() -- TODO: keymaps -- :DiffviewOpen diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua index 6ee0348..3f30f42 100644 --- a/nvim/lua/plugins/gitsigns.lua +++ b/nvim/lua/plugins/gitsigns.lua @@ -1,6 +1,7 @@ return { { "lewis6991/gitsigns.nvim", + lazy = false, config = function() require('gitsigns').setup { diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index e33925e..aa8b8df 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -1,6 +1,7 @@ return { 'VonHeikemen/lsp-zero.nvim', + lazy = false, branch = 'v3.x', dependencies = { -- LSP Support diff --git a/nvim/lua/plugins/markdown-preview.lua b/nvim/lua/plugins/markdown-preview.lua index b325fdd..1fd1ac3 100644 --- a/nvim/lua/plugins/markdown-preview.lua +++ b/nvim/lua/plugins/markdown-preview.lua @@ -3,6 +3,7 @@ return { "iamcco/markdown-preview.nvim", cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, build = "cd app && yarn install", + lazy = false, init = function() vim.g.mkdp_filetypes = { "markdown" } end, diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index bd26f0f..c2c4102 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -2,6 +2,7 @@ return { { 'nvim-telescope/telescope.nvim', tag = '0.1.8', dependencies = { 'nvim-lua/plenary.nvim' }, + lazy = false, config = function() local builtin = require('telescope.builtin') diff --git a/nvim/lua/plugins/todo-comments.lua b/nvim/lua/plugins/todo-comments.lua index b62212c..340dbcd 100644 --- a/nvim/lua/plugins/todo-comments.lua +++ b/nvim/lua/plugins/todo-comments.lua @@ -3,6 +3,7 @@ return { "folke/todo-comments.nvim", dependencies = { "nvim-lua/plenary.nvim" }, event = { "BufReadPost", "BufNewFile" }, + lazy = false, config = function() require("todo-comments").setup({ signs = true, diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index f3f4dd0..b7fe8fb 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -3,6 +3,7 @@ return { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", event = { "BufReadPost", "BufNewFile" }, + lazy = false, config = function() require("nvim-treesitter.configs").setup({ diff --git a/nvim/lua/plugins/undotree.lua b/nvim/lua/plugins/undotree.lua index e874811..16d437e 100644 --- a/nvim/lua/plugins/undotree.lua +++ b/nvim/lua/plugins/undotree.lua @@ -1,6 +1,7 @@ return { { "mbbill/undotree", + lazy = false, config = function() vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle) |