diff --git a/init.lua b/init.lua index cc67ad5c..04617bbb 100644 --- a/init.lua +++ b/init.lua @@ -981,6 +981,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. { import = 'custom.plugins' }, + -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! @@ -1103,9 +1104,6 @@ vim.g.vimtex_view_method = '' vim.g.vimtex_compiler_method = 'latexmk' vim.opt.guicursor = 'a:block' -vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move down' }) -vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move up' }) - vim.keymap.set('n', 'n', 'NerdIcons', { desc = 'Open NerdIcons' }) vim.keymap.set({ 'n', 'v' }, '', '"*p', { desc = 'Paste from selection clipboard' }) vim.keymap.set({ 'n', 'v' }, 'p', '"+p', { desc = 'Paste from system clipboard' }) @@ -1131,3 +1129,47 @@ vim.keymap.set({ 'n' }, 'o', function() print 'No file found. Make sure the buffer is saved.' end end, { desc = 'Open file ' }) + +-- NOTE: THESE ARE FROM https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua + +vim.keymap.set({ 'n', 'x' }, 'j', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true }) +vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gj' : 'j'", { desc = 'Down', expr = true, silent = true }) +vim.keymap.set({ 'n', 'x' }, 'k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true }) +vim.keymap.set({ 'n', 'x' }, '', "v:count == 0 ? 'gk' : 'k'", { desc = 'Up', expr = true, silent = true }) + +-- to window using the hjkl keys +vim.keymap.set('n', '', 'h', { desc = 'Go to Left Window', remap = true }) +vim.keymap.set('n', '', 'j', { desc = 'Go to Lower Window', remap = true }) +vim.keymap.set('n', '', 'k', { desc = 'Go to Upper Window', remap = true }) +vim.keymap.set('n', '', 'l', { desc = 'Go to Right Window', remap = true }) + +vim.keymap.set('n', '', "execute 'move .+' . v:count1==", { desc = 'Move Down' }) +vim.keymap.set('n', '', "execute 'move .-' . (v:count1 + 1)==", { desc = 'Move Up' }) +vim.keymap.set('i', '', 'm .+1==gi', { desc = 'Move Down' }) +vim.keymap.set('i', '', 'm .-2==gi', { desc = 'Move Up' }) +vim.keymap.set('v', '', ":execute \"'<,'>move '>+\" . v:count1gv=gv", { desc = 'Move Down' }) +vim.keymap.set('v', '', ":execute \"'<,'>move '<-\" . (v:count1 + 1)gv=gv", { desc = 'Move Up' }) + +-- better indenting +vim.keymap.set('v', '<', '', '>gv') + +-- commenting +vim.keymap.set('n', 'gco', 'oVcxnormal gccfxa', { desc = 'Add Comment Below' }) +vim.keymap.set('n', 'gcO', 'OVcxnormal gccfxa', { desc = 'Add Comment Above' }) + +-- windows +vim.keymap.set('n', 'w', '', { desc = 'Windows', remap = true }) +vim.keymap.set('n', '-', 's', { desc = 'Split Window Below', remap = true }) +vim.keymap.set('n', '|', 'v', { desc = 'Split Window Right', remap = true }) +vim.keymap.set('n', 'wd', 'c', { desc = 'Delete Window', remap = true }) + +-- native snippets +if vim.fn.has 'nvim-0.11' == 0 then + vim.keymap.set('s', '', function() + return vim.snippet.active { direction = 1 } and 'lua vim.snippet.jump(1)' or '' + end, { expr = true, desc = 'Jump Next' }) + vim.keymap.set({ 'i', 's' }, '', function() + return vim.snippet.active { direction = -1 } and 'lua vim.snippet.jump(-1)' or '' + end, { expr = true, desc = 'Jump Previous' }) +end diff --git a/lua/custom/keybinds/binds.lua b/lua/custom/keybinds/binds.lua new file mode 100644 index 00000000..e0a2ec96 --- /dev/null +++ b/lua/custom/keybinds/binds.lua @@ -0,0 +1,34 @@ +return { + vim.g.vimtex_view_method == '', + vim.g.vimtex_compiler_method == 'latexmk', + vim.opt.guicursor == 'a:block', + + vim.keymap.set('v', 'J', ":m '>+1gv=gv", { desc = 'Move down' }), + vim.keymap.set('v', 'K', ":m '<-2gv=gv", { desc = 'Move up' }), + + vim.keymap.set('n', 'n', 'NerdIcons', { desc = 'Open NerdIcons' }), + vim.keymap.set({ 'n', 'v' }, '', '"*p', { desc = 'Paste from selection clipboard' }), + vim.keymap.set({ 'n', 'v' }, 'p', '"+p', { desc = 'Paste from system clipboard' }), + vim.keymap.set({ 'v', 'n' }, 't', 'TSBufToggle highlight', { desc = 'Toggle Tree-sitter highlighting' }), + vim.keymap.set('n', 'z', ":!zathura =expand('%:r').pdf &", { desc = 'Open PDF' }), + + vim.keymap.set({ 'n' }, 'p', function() + local file_name = vim.fn.expand '%:t' + if file_name ~= '' then + -- Open Explorer in the current directory and select the file + vim.fn.system { 'explorer.exe', '/select,', file_name } + else + print 'No file name found. Save the buffer first.' + end + end, { desc = 'Open file location in Explorer' }), + + vim.keymap.set({ 'n' }, 'o', function() + local file_name = vim.fn.expand '%:t' + if file_name ~= '' then + -- Open Explorer in the current directory and select the file + vim.fn.system { 'explorer.exe', file_name } + else + print 'No file found. Make sure the buffer is saved.' + end + end, { desc = 'Open file ' }), +} diff --git a/lua/custom/plugins/snacks.lua b/lua/custom/plugins/snacks.lua index e84da36d..640c429c 100644 --- a/lua/custom/plugins/snacks.lua +++ b/lua/custom/plugins/snacks.lua @@ -5,7 +5,7 @@ return { ---@type snacks.Config opts = { bigfile = { enabled = true }, - dashboard = { enabled = true }, + dashboard = { enabled = false }, notifier = { enabled = true, timeout = 3000,