diff --git a/lua/commands.lua b/lua/commands.lua index d45f03a..5c36849 100644 --- a/lua/commands.lua +++ b/lua/commands.lua @@ -7,3 +7,14 @@ vim.api.nvim_create_user_command('IPDB', 'norm oimport ipdb; ipdb.set_trace() # -- Format the document vim.api.nvim_create_user_command('Format', 'lua vim.lsp.buf.format()', {}) +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/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/configs/lspconfig.lua b/lua/configs/lspconfig.lua index ea26f18..c26b0ff 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 diff --git a/lua/configs/lualine.lua b/lua/configs/lualine.lua index 2796af1..d109b3c 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, @@ -117,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 }, @@ -153,6 +158,7 @@ function M.config() lualine_a = { { -- file name "filename", + path = 1, icon="", color = { fg = scolors.filename, gui = "bold" }, padding = { left = 1, right = 1 }, diff --git a/lua/configs/session-manager.lua b/lua/configs/session-manager.lua new file mode 100644 index 0000000..c467323 --- /dev/null +++ b/lua/configs/session-manager.lua @@ -0,0 +1,44 @@ +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' + 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 + 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 + diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 9ef78d0..3364db7 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) @@ -67,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 message since it doesn't update till the line changes +map("n", "s", "GitBlameToggleSummaryjkkj", opts) -- LSP (see configs/lsp-installer.lua) -- disable K in visual mode diff --git a/lua/plugins.lua b/lua/plugins.lua index 6e92939..fdf451a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -34,7 +34,11 @@ packer.startup { -- -- Colorscheme (See autocommands.lua) - use { 'lunarvim/darkplus.nvim' } + use { + 'lunarvim/darkplus.nvim', + commit = 'f20cba5d690bc34398a3a8372ee7bbbc7b6609fa', + -- tag = 'neovim-0.7', -- this has imperfect comment highlights + } --[[ use { '~/builds/darkplus.nvim' } ]] -- Buffer Line @@ -73,6 +77,18 @@ 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', + -- commit = '4005dac93f5cd1257792259ef4df6af0e3afc213', + -- config = function() require'configs.session-manager'.config() end + -- } + -- custom build of the above plugin + use { + '~/builds/neovim-session-manager', + config = function() require'configs.session-manager'.config() end + } + -- -- Treesitter -- @@ -178,9 +194,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 = {