Skip to content

Commit

Permalink
Merge pull request #21 from fabmorais/add-autosession-plugin
Browse files Browse the repository at this point in the history
add auto session plugin / few changes to mapping
  • Loading branch information
fabmorais authored Jun 15, 2024
2 parents bf3ecca + a16ed05 commit ef0f0ea
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 111 deletions.
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require("autopairs-config")
require("diffview-config")
require("notify-config")
require("tint-config")
require("autosession-config")
-- require("chatgpt-config")
require("debugger-config")
require("debugger-config.rust")
Expand Down
14 changes: 14 additions & 0 deletions lua/autosession-config/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require("auto-session").setup({
log_level = "error",
auto_session_suppress_dirs = { "~/", "~/Projects", "~/Downloads", "/" },
session_lens = {
buftypes_to_ignore = {},
load_on_setup = true,
theme_conf = { border = true },
previewer = false,
},
})

vim.keymap.set("n", "<C-s>", require("auto-session.session-lens").search_session, {
noremap = true,
})
2 changes: 1 addition & 1 deletion lua/mappings/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ map("n", "<C-k>", "<C-w>k", { noremap = true, silent = false })
map("v", "<", "<gv", { noremap = true, silent = false })
map("v", ">", "<gv", { noremap = true, silent = false })
map("n", "gv", ":norm ggVG <CR>", opts)
map("i", "<C-J>", 'copilot#Accept("<CR>")', { silent = true, expr = true })
-- map("i", "<C-J>", 'copilot#Accept("<CR>")', { silent = true, expr = true })
map("n", "<C-d>", "<C-d>zz", { noremap = true, silent = false })
map("n", "<C-u>", "<C-u>zz", { noremap = true, silent = false })

Expand Down
8 changes: 8 additions & 0 deletions lua/packer-config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,12 @@ return require("packer").startup(function(use)
require("lspsaga").setup({})
end,
})

--> Auto Session
use({
"rmagatti/auto-session",
config = function()
require("auto-session").setup()
end,
})
end)
221 changes: 111 additions & 110 deletions lua/which-config/init.lua
Original file line number Diff line number Diff line change
@@ -1,126 +1,127 @@
local wk = require("which-key")
wk.setup({
plugins = {
marks = false,
registers = false,
spelling = { enabled = false, suggestions = 20 },
presets = {
operators = false,
motions = false,
text_objects = false,
windows = false,
nav = false,
z = false,
g = false,
},
},
plugins = {
marks = false,
registers = false,
spelling = { enabled = false, suggestions = 20 },
presets = {
operators = false,
motions = false,
text_objects = false,
windows = false,
nav = false,
z = false,
g = false,
},
},
})

local Terminal = require("toggleterm.terminal").Terminal

local toggle_float = function()
local float = Terminal:new({ direction = "float" })
return float:toggle()
local float = Terminal:new({ direction = "float" })
return float:toggle()
end

local toggle_lazygit = function()
local lazygit = Terminal:new({ cmd = "lazygit", direction = "float" })
return lazygit:toggle()
local lazygit = Terminal:new({ cmd = "lazygit", direction = "float" })
return lazygit:toggle()
end

local mappings = {
["/"] = { ":CommentToggle<cr>", "Toggle Comment" },
c = { ":67,69CommentToggle<cr>", "Range Toggle Comment" },
q = { ":q<cr>", "Quit" },
Q = { ":wq<cr>", "Save & Quit" },
w = { ":w<cr>", "Save" },
x = { ":bdelete<cr>", "Close" },
-- d = { ":Dashboard<cr>", "Dashboard" },
E = { ":e ~/.config/nvim/init.lua<cr>", "Edit config" },
f = {
name = "Telescope",
f = { ":Telescope find_files<cr>", "Telescope Find Files" },
g = { ":Telescope live_grep<cr>", "Telescope Live Grep" },
o = { ":Telescope oldfiles<cr>", "Telescope Old Files" },
h = { ":Telescope keymaps<cr>", "Telescope Keymaps" },
b = { ":Telescope buffers<cr>", "Telescope Buffers" },
},
g = {
name = "ChatGPT",
c = { "<cmd>ChatGPT<CR>", "ChatGPT" },
e = { "<cmd>ChatGPTEditWithInstruction<CR>", "Edit with instruction", mode = { "n", "v" } },
g = { "<cmd>ChatGPTRun grammar_correction<CR>", "Grammar Correction", mode = { "n", "v" } },
t = { "<cmd>ChatGPTRun translate<CR>", "Translate", mode = { "n", "v" } },
k = { "<cmd>ChatGPTRun keywords<CR>", "Keywords", mode = { "n", "v" } },
d = { "<cmd>ChatGPTRun docstring<CR>", "Docstring", mode = { "n", "v" } },
a = { "<cmd>ChatGPTRun add_tests<CR>", "Add Tests", mode = { "n", "v" } },
o = { "<cmd>ChatGPTRun optimize_code<CR>", "Optimize Code", mode = { "n", "v" } },
s = { "<cmd>ChatGPTRun summarize<CR>", "Summarize", mode = { "n", "v" } },
f = { "<cmd>ChatGPTRun fix_bugs<CR>", "Fix Bugs", mode = { "n", "v" } },
x = { "<cmd>ChatGPTRun explain_code<CR>", "Explain Code", mode = { "n", "v" } },
r = { "<cmd>ChatGPTRun roxygen_edit<CR>", "Roxygen Edit", mode = { "n", "v" } },
l = { "<cmd>ChatGPTRun code_readability_analysis<CR>", "Code Readability Analysis", mode = { "n", "v" } },
},
b = {
name = "Telescope Bookmarks",
m = { ":Telescope marks<cr>", "Bookmarks" },
},
t = {
name = "Terminal",
t = { ":ToggleTerm<cr>", "Split Below" },
f = { toggle_float, "Floating Terminal" },
l = { toggle_lazygit, "LazyGit" },
},
l = {
name = "LSP",
i = { ":LspInfo<cr>", "Connected Language Servers" },
k = { "<cmd>lua vim.lsp.buf.signature_help()<cr>", "Signature Help" },
K = { "<cmd>Lspsaga hover_doc<cr>", "Hover Commands" },
w = { "<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>", "Add Workspace Folder" },
W = { "<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>", "Remove Workspace Folder" },
l = {
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>",
"List Workspace Folders",
},
t = { "<cmd>lua vim.lsp.buf.type_definition()<cr>", "Type Definition" },
d = { "<cmd>lua vim.lsp.buf.definition()<cr>", "Go To Definition" },
D = { "<cmd>lua vim.lsp.buf.declaration()<cr>", "Go To Declaration" },
r = { "<cmd>lua vim.lsp.buf.references()<cr>", "References" },
R = { "<cmd>Lspsaga rename<cr>", "Rename" },
a = { "<cmd>Lspsaga code_action<cr>", "Code Action" },
e = { "<cmd>Lspsaga show_line_diagnostics<cr>", "Show Line Diagnostics" },
n = { "<cmd>Lspsaga diagnostic_jump_next<cr>", "Go To Next Diagnostic" },
N = { "<cmd>Lspsaga diagnostic_jump_prev<cr>", "Go To Previous Diagnostic" },
},
p = {
name = "Packer",
r = { ":PackerClean<cr>", "Remove Unused Plugins" },
c = { ":PackerCompile profile=true<cr>", "Recompile Plugins" },
i = { ":PackerInstall<cr>", "Install Plugins" },
p = { ":PackerProfile<cr>", "Packer Profile" },
s = { ":PackerSync<cr>", "Sync Plugins" },
S = { ":PackerStatus<cr>", "Packer Status" },
u = { ":PackerUpdate<cr>", "Update Plugins" },
},
-- debugger mappings --
d = {
name = "Debugger",
c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
O = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },
s = {
"<cmd>lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<cr>",
"Set Breakpoint condition",
},
B = {
"<cmd>lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<cr>",
"Set Breakpoint log message",
},
n = { "<cmd>lua require'dap'.repl.open()<cr>", "Open" },
l = { "<cmd>lua require'dap'.run_last()<cr>", "Run Last" },
},
["/"] = { ":CommentToggle<cr>", "Toggle Comment" },
c = { ":67,69CommentToggle<cr>", "Range Toggle Comment" },
q = { ":q<cr>", "Quit" },
Q = { ":wq<cr>", "Save & Quit" },
w = { ":w<cr>", "Save" },
x = { ":bdelete<cr>", "Close" },
-- d = { ":Dashboard<cr>", "Dashboard" },
E = { ":e ~/.config/nvim/init.lua<cr>", "Edit config" },
f = {
name = "Telescope",
f = { ":Telescope find_files<cr>", "Telescope Find Files" },
g = { ":Telescope live_grep<cr>", "Telescope Live Grep" },
o = { ":Telescope oldfiles<cr>", "Telescope Old Files" },
h = { ":Telescope keymaps<cr>", "Telescope Keymaps" },
b = { ":Telescope buffers<cr>", "Telescope Buffers" },
},
g = {
name = "ChatGPT",
c = { "<cmd>ChatGPT<CR>", "ChatGPT" },
b = { "<cmd>ChatGPTCompleteCode<CR>", "ChatGPTCompleteCode" },
e = { "<cmd>ChatGPTEditWithInstruction<CR>", "Edit with instruction", mode = { "n", "v" } },
g = { "<cmd>ChatGPTRun grammar_correction<CR>", "Grammar Correction", mode = { "n", "v" } },
t = { "<cmd>ChatGPTRun translate<CR>", "Translate", mode = { "n", "v" } },
k = { "<cmd>ChatGPTRun keywords<CR>", "Keywords", mode = { "n", "v" } },
d = { "<cmd>ChatGPTRun docstring<CR>", "Docstring", mode = { "n", "v" } },
a = { "<cmd>ChatGPTRun add_tests<CR>", "Add Tests", mode = { "n", "v" } },
o = { "<cmd>ChatGPTRun optimize_code<CR>", "Optimize Code", mode = { "n", "v" } },
s = { "<cmd>ChatGPTRun summarize<CR>", "Summarize", mode = { "n", "v" } },
f = { "<cmd>ChatGPTRun fix_bugs<CR>", "Fix Bugs", mode = { "n", "v" } },
x = { "<cmd>ChatGPTRun explain_code<CR>", "Explain Code", mode = { "n", "v" } },
r = { "<cmd>ChatGPTRun roxygen_edit<CR>", "Roxygen Edit", mode = { "n", "v" } },
l = { "<cmd>ChatGPTRun code_readability_analysis<CR>", "Code Readability Analysis", mode = { "n", "v" } },
},
b = {
name = "Telescope Bookmarks",
m = { ":Telescope marks<cr>", "Bookmarks" },
},
t = {
name = "Terminal",
t = { ":ToggleTerm<cr>", "Split Below" },
f = { toggle_float, "Floating Terminal" },
l = { toggle_lazygit, "LazyGit" },
},
l = {
name = "LSP",
i = { ":LspInfo<cr>", "Connected Language Servers" },
k = { "<cmd>lua vim.lsp.buf.signature_help()<cr>", "Signature Help" },
K = { "<cmd>Lspsaga hover_doc<cr>", "Hover Commands" },
w = { "<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>", "Add Workspace Folder" },
W = { "<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>", "Remove Workspace Folder" },
l = {
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>",
"List Workspace Folders",
},
t = { "<cmd>lua vim.lsp.buf.type_definition()<cr>", "Type Definition" },
d = { "<cmd>lua vim.lsp.buf.definition()<cr>", "Go To Definition" },
D = { "<cmd>lua vim.lsp.buf.declaration()<cr>", "Go To Declaration" },
r = { "<cmd>lua vim.lsp.buf.references()<cr>", "References" },
R = { "<cmd>Lspsaga rename<cr>", "Rename" },
a = { "<cmd>Lspsaga code_action<cr>", "Code Action" },
e = { "<cmd>Lspsaga show_line_diagnostics<cr>", "Show Line Diagnostics" },
n = { "<cmd>Lspsaga diagnostic_jump_next<cr>", "Go To Next Diagnostic" },
N = { "<cmd>Lspsaga diagnostic_jump_prev<cr>", "Go To Previous Diagnostic" },
},
p = {
name = "Packer",
r = { ":PackerClean<cr>", "Remove Unused Plugins" },
c = { ":PackerCompile profile=true<cr>", "Recompile Plugins" },
i = { ":PackerInstall<cr>", "Install Plugins" },
p = { ":PackerProfile<cr>", "Packer Profile" },
s = { ":PackerSync<cr>", "Sync Plugins" },
S = { ":PackerStatus<cr>", "Packer Status" },
u = { ":PackerUpdate<cr>", "Update Plugins" },
},
-- debugger mappings --
d = {
name = "Debugger",
c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
O = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },
s = {
"<cmd>lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<cr>",
"Set Breakpoint condition",
},
B = {
"<cmd>lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<cr>",
"Set Breakpoint log message",
},
n = { "<cmd>lua require'dap'.repl.open()<cr>", "Open" },
l = { "<cmd>lua require'dap'.run_last()<cr>", "Run Last" },
},
}

local opts = { prefix = "<leader>" }
Expand Down

0 comments on commit ef0f0ea

Please sign in to comment.