From 43537dde8656f82f8209d1415b3bf0aefd1e749a Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Wed, 26 Oct 2022 10:02:48 -0700 Subject: [PATCH 01/11] add sessions, remove checkbox --- lua/configs/alpha.lua | 1 + lua/plugins.lua | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/configs/alpha.lua b/lua/configs/alpha.lua index ea7390c..53d0c7c 100644 --- a/lua/configs/alpha.lua +++ b/lua/configs/alpha.lua @@ -14,6 +14,7 @@ function M.config() dashboard.button("w", "Find Word", ":Telescope live_grep"), dashboard.button("o", "Recent Files", ":Telescope oldfiles"), dashboard.button("e", "Open Tree", ":NvimTreeToggle"), + dashboard.button("s", "Load Session", ":SessionManager load_current_dir_session"), dashboard.button("q", "Quit", ":qa"), } diff --git a/lua/plugins.lua b/lua/plugins.lua index f9fe561..9f8b4ad 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -73,6 +73,9 @@ packer.startup { use { 'nvim-telescope/telescope.nvim', config = function() require'configs.telescope'.config() end } -- use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } + -- Sessions + use { 'Shatur/neovim-session-manager', config = function() require'configs.session-manager'.config() end } + -- -- Treesitter -- @@ -178,9 +181,6 @@ packer.startup { -- Formatting for python (:call Black()) use { 'averms/black-nvim', run = ':UpdateRemotePlugins' } - - -- Toggle checkboxes w/ we, delete w/ wx - use { 'gerardbm/vim-md-checkbox' } end, config = { display = { From 1dc94d58b81d43e9439ebdf126edfd76451fb819 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Wed, 26 Oct 2022 10:03:13 -0700 Subject: [PATCH 02/11] add session manager --- lua/configs/session-manager.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lua/configs/session-manager.lua diff --git a/lua/configs/session-manager.lua b/lua/configs/session-manager.lua new file mode 100644 index 0000000..f1e01ed --- /dev/null +++ b/lua/configs/session-manager.lua @@ -0,0 +1,18 @@ +local M = {} + +function M.config() + local status_ok, session_manager = pcall(require, "session_manager") + if not status_ok then + return + end + + local sm_config = require'session_manager.config' + + -- this plugin saves sessions for the working directory automatically + session_manager.setup({ + autoload_mode = sm_config.AutoloadMode.Disabled, -- do not auto-load the last session at startup + }) +end + +return M + From 662ad3503414b27f5c226f1e84e045ffbea89f54 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Wed, 26 Oct 2022 10:08:05 -0700 Subject: [PATCH 03/11] git navigation --- lua/keybinds.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 9ef78d0..e1c06b4 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -36,6 +36,10 @@ map("n", "[b", "BufferLineMovePrev", opts) map("n", "w", "Bdelete", opts) -- don't close if unsaved map("n", "c", "Bdelete!", opts) -- close it no matter what B) +-- Navigate Git Signs +map("n", "]g", "Gitsigns next_hunk", opts) +map("n", "[g", "Gitsigns prev_hunk", opts) + -- Toggle Diagnostics map("n", "de", "lua vim.diagnostic.enable()", opts) map("n", "dd", "lua vim.diagnostic.disable()", opts) From 86cfb979ec5c6e93c4e8ec11e0b4dc6b541eed93 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Wed, 26 Oct 2022 17:40:15 -0700 Subject: [PATCH 04/11] pyright tuning configuration --- lua/configs/lspconfig.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index b3f5e5d..94808db 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -135,6 +135,17 @@ function M.config() -- pip install pyright lspconfig.pyright.setup { on_attach = on_attach, + settings = { + -- https://github.com/microsoft/pyright/blob/main/docs/settings.md + python = { + autoSearchPaths = true, + autoImportCompletion = true, + diagnosticMode = 'openFilesOnly', -- workspace | openFilesOnly + useLibraryCodeForTypes = true, + -- typeCheckingMode = '...' -- off | basic | strict + -- venvPath = '...' + } + } } -- vscode-json-language-server From 873482af01b71a9b97eef4b53b753728c873baed Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Fri, 4 Nov 2022 14:12:42 -0700 Subject: [PATCH 05/11] add relative path and remove git branch --- lua/configs/lualine.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lua/configs/lualine.lua b/lua/configs/lualine.lua index 2796af1..0a3c7d5 100644 --- a/lua/configs/lualine.lua +++ b/lua/configs/lualine.lua @@ -75,16 +75,17 @@ function M.config() }, { -- file name "filename", + path = 1, icon="", color = { fg = scolors.filename, gui = "bold" }, padding = { left = 1, right = 1 }, }, - { -- git branch - "branch", - icon = "", - color = { fg = scolors.branch, gui = "bold" }, - padding = { left = 1, right = 1 }, - }, + -- { -- git branch + -- "branch", + -- icon = "", + -- color = { fg = scolors.branch, gui = "bold" }, + -- padding = { left = 1, right = 1 }, + -- }, { -- filetype "filetype", colored = false, @@ -153,6 +154,7 @@ function M.config() lualine_a = { { -- file name "filename", + path = 1, icon="", color = { fg = scolors.filename, gui = "bold" }, padding = { left = 1, right = 1 }, From ba7167d1188f1268d35b1767210220c2337ca0a8 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Fri, 4 Nov 2022 14:35:35 -0700 Subject: [PATCH 06/11] toggle summary in git blame with s --- lua/commands.lua | 12 ++++++++++++ lua/keybinds.lua | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lua/commands.lua b/lua/commands.lua index 1f552a4..a254fef 100644 --- a/lua/commands.lua +++ b/lua/commands.lua @@ -4,3 +4,15 @@ vim.api.nvim_create_user_command('Black', 'call Black()', {}) -- Insert IPDB statement vim.api.nvim_create_user_command('IPDB', 'norm oimport ipdb; ipdb.set_trace() # fmt:skip', {}) +local function gitblame_toggle_summary() + local normal = '' + local with_summary = '' + if vim.g.gitblame_message_template == normal then + vim.g.gitblame_message_template = with_summary + else + vim.g.gitblame_message_template = normal + end +end + +vim.api.nvim_create_user_command('GitBlameToggleSummary', gitblame_toggle_summary, {}) + diff --git a/lua/keybinds.lua b/lua/keybinds.lua index e1c06b4..5799406 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -71,7 +71,9 @@ map("n", "la", "Lspsaga code_action", opts) map("n", "", "lua require('lspsaga.action').smart_scroll_with_saga(-1)", opts) map("n", "", "lua require('lspsaga.action').smart_scroll_with_saga(1)", opts) -map("n", "b", "GitBlameToggle", opts) +-- Custom "toggle summary" function for blame +-- jkkj is a hack to refresh the git blame +map("n", "s", "GitBlameToggleSummaryjkkj", opts) -- LSP (see configs/lsp-installer.lua) -- disable K in visual mode From 485d2eee8d25ed415355c8439157afb422debce9 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Fri, 4 Nov 2022 14:44:43 -0700 Subject: [PATCH 07/11] add info about why the hack --- lua/keybinds.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 5799406..3364db7 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -72,7 +72,7 @@ map("n", "", "lua require('lspsaga.action').smart_scroll_with_saga(-1) map("n", "", "lua require('lspsaga.action').smart_scroll_with_saga(1)", opts) -- Custom "toggle summary" function for blame --- jkkj is a hack to refresh the git blame +-- jkkj is a hack to refresh the git blame message since it doesn't update till the line changes map("n", "s", "GitBlameToggleSummaryjkkj", opts) -- LSP (see configs/lsp-installer.lua) From 1085810459a0c7b0fc923fee66f0afa7523c2b38 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Fri, 4 Nov 2022 15:08:18 -0700 Subject: [PATCH 08/11] not committed instead of Not Committed Yet --- lua/configs/lspconfig.lua | 16 ++++++++-------- lua/configs/lualine.lua | 6 +++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 94808db..54807b6 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -135,17 +135,17 @@ function M.config() -- pip install pyright lspconfig.pyright.setup { on_attach = on_attach, - settings = { + -- settings = { -- https://github.com/microsoft/pyright/blob/main/docs/settings.md - python = { - autoSearchPaths = true, - autoImportCompletion = true, - diagnosticMode = 'openFilesOnly', -- workspace | openFilesOnly - useLibraryCodeForTypes = true, + -- python = { + -- autoSearchPaths = true, + -- autoImportCompletion = true, + -- diagnosticMode = 'openFilesOnly', -- workspace | openFilesOnly + -- useLibraryCodeForTypes = true, -- typeCheckingMode = '...' -- off | basic | strict -- venvPath = '...' - } - } + -- } + -- } } -- vscode-json-language-server diff --git a/lua/configs/lualine.lua b/lua/configs/lualine.lua index 0a3c7d5..d109b3c 100644 --- a/lua/configs/lualine.lua +++ b/lua/configs/lualine.lua @@ -118,7 +118,11 @@ function M.config() }, lualine_x = { { -- git blame - gitblame.get_current_blame_text, + function () + local blame_text = gitblame.get_current_blame_text() + blame_text = blame_text:gsub("Not Committed Yet", "not committed") + return blame_text + end, color = { fg = scolors.fg_wash }, cond = gitblame.is_blame_text_available, padding = { left = 0, right = 1 }, From 38d9552de69a4cbf67e5d7023b0af730769ac533 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Tue, 15 Nov 2022 14:39:01 -0800 Subject: [PATCH 09/11] pin session manager and darkplus for neovim 0.7 --- lua/plugins.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 58bd897..16af0bc 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -34,7 +34,7 @@ packer.startup { -- -- Colorscheme (See autocommands.lua) - use { 'lunarvim/darkplus.nvim' } + use { 'lunarvim/darkplus.nvim', tag = 'neovim-0.7' } --[[ use { '~/builds/darkplus.nvim' } ]] -- Buffer Line @@ -74,7 +74,11 @@ packer.startup { -- use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } -- Sessions - use { 'Shatur/neovim-session-manager', config = function() require'configs.session-manager'.config() end } + use { + 'Shatur/neovim-session-manager', + commit = '4005dac93f5cd1257792259ef4df6af0e3afc213', + config = function() require'configs.session-manager'.config() end + } -- -- Treesitter From 0e7ea8d99753b97c83b902e5a7f12bc9d17cef5d Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Tue, 15 Nov 2022 16:22:28 -0800 Subject: [PATCH 10/11] fix darkplus, nvim session manager custom fork --- lua/configs/session-manager.lua | 13 +++++++++++++ lua/plugins.lua | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lua/configs/session-manager.lua b/lua/configs/session-manager.lua index f1e01ed..c4c2ab4 100644 --- a/lua/configs/session-manager.lua +++ b/lua/configs/session-manager.lua @@ -11,6 +11,19 @@ function M.config() -- this plugin saves sessions for the working directory automatically session_manager.setup({ autoload_mode = sm_config.AutoloadMode.Disabled, -- do not auto-load the last session at startup + extras_generator = function(dir) + local handle = io.popen("git branch --show-current 2>/dev/null") + if (handle == nil) then + return nil + end + local branch = handle:read("l") + handle:close() + if (branch == nil) then + return nil + end + branch = branch:gsub("/", "++") + return branch + end, }) end diff --git a/lua/plugins.lua b/lua/plugins.lua index 16af0bc..5cea1ce 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -34,7 +34,11 @@ packer.startup { -- -- Colorscheme (See autocommands.lua) - use { 'lunarvim/darkplus.nvim', tag = 'neovim-0.7' } + use { + 'lunarvim/darkplus.nvim', + commit = 'f20cba5d690bc34398a3a8372ee7bbbc7b6609fa', + -- tag = 'neovim-0.7', -- this has imperfect comment highlights + } --[[ use { '~/builds/darkplus.nvim' } ]] -- Buffer Line @@ -74,9 +78,14 @@ packer.startup { -- use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } -- Sessions + -- use { + -- 'Shatur/neovim-session-manager', + -- commit = '4005dac93f5cd1257792259ef4df6af0e3afc213', + -- config = function() require'configs.session-manager'.config() end + -- } + -- custom build of the above plugin use { - 'Shatur/neovim-session-manager', - commit = '4005dac93f5cd1257792259ef4df6af0e3afc213', + '~/builds/neovim-session-manager', config = function() require'configs.session-manager'.config() end } From 910df166394574b3da8dd04ffe83d00af4e6eb47 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Fri, 18 Nov 2022 13:27:11 -0800 Subject: [PATCH 11/11] new sessionmanager config --- lua/configs/session-manager.lua | 49 +++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/lua/configs/session-manager.lua b/lua/configs/session-manager.lua index c4c2ab4..c467323 100644 --- a/lua/configs/session-manager.lua +++ b/lua/configs/session-manager.lua @@ -6,25 +6,38 @@ function M.config() return end - local sm_config = require'session_manager.config' + local sm_config = require'session_manager.config' + local function get_branch_name() + local handle = io.popen("git branch --show-current 2>/dev/null") + if (handle == nil) then + return nil + end + local branch = handle:read("l") + handle:close() + if (branch == nil) then + return nil + end + branch = branch:gsub("/", "--") + return branch + end - -- this plugin saves sessions for the working directory automatically - session_manager.setup({ - autoload_mode = sm_config.AutoloadMode.Disabled, -- do not auto-load the last session at startup - extras_generator = function(dir) - local handle = io.popen("git branch --show-current 2>/dev/null") - if (handle == nil) then - return nil - end - local branch = handle:read("l") - handle:close() - if (branch == nil) then - return nil - end - branch = branch:gsub("/", "++") - return branch - end, - }) + -- this plugin saves sessions for the working directory automatically + session_manager.setup({ + autoload_mode = sm_config.AutoloadMode.Disabled, -- do not auto-load the last session at startup + session_filename_to_dir = function(filename) + local filename_without_extra = filename:sub(0, filename:find("==")) + return sm_config.delimited_session_filename_to_dir(filename_without_extra) + end, + dir_to_session_filename = function(dir) + local filename = sm_config.dir_to_delimited_session_filename(dir) + local branch = get_branch_name() + if branch ~= nil then + return filename .. "==" .. branch + else + return filename + end + end, + }) end return M