diff --git a/init.lua b/init.lua index 5672525..7ca9ad2 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,6 @@ -vim.cmd("let mapleader = ' '") - require('preferences') require('keymaps') +require('remaps') local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' if not (vim.uv or vim.loop).fs_stat(lazypath) then diff --git a/lazy-lock.json b/lazy-lock.json index c698ae8..7622429 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,19 +1,33 @@ { "LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" }, + "barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "codeium.vim": { "branch": "main", "commit": "0b74f274b82c00eaad4b5b5cd8b2e76f872d19f1" }, + "dashboard-nvim": { "branch": "master", "commit": "fabf5feec96185817c732d47d363f34034212685" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" }, "none-ls.nvim": { "branch": "main", "commit": "cfa65d86e21eeb60544d5e823f6db43941322a53" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, + "nvim": { "branch": "main", "commit": "18bab5ec4c782cdf7d7525dbe89c60bfa02fc195" }, "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, "nvim-lspconfig": { "branch": "master", "commit": "ff97d376b1d22b2eaf9274605531babf0cd0cf21" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, + "nvim-treesitter": { "branch": "master", "commit": "e5a05ba5e298cc1e1dad8eb8095b8d4d89a7f793" }, "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, + "oil.nvim": { "branch": "master", "commit": "fcca212c2e966fc3dec1d4baf888e670631d25d1" }, "onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "1420fb9e07b1d80cc6d87e7d90827fb2c1109cb3" } + "toggleterm.nvim": { "branch": "main", "commit": "137d06fb103952a0fb567882bb8527e2f92d327d" }, + "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "1420fb9e07b1d80cc6d87e7d90827fb2c1109cb3" }, + "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" } } diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 13157f3..f4d05d0 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -1,10 +1,104 @@ -vim.keymap.set('n', '', ':Neotree filesystem reveal left toggle') +-- File Explorer +vim.keymap.set('n', 'n', ':Neotree filesystem reveal left toggle') +-- Telescope vim.keymap.set('n', 'ff', ':Telescope find_files') vim.keymap.set('n', 'tc', ':Telescope colorscheme') vim.keymap.set('n', 'of', ':Telescope oldfiles') vim.keymap.set('n', 'tl', ':Telescope live_grep') vim.keymap.set('n', 'km', ':Telescope keymaps') +vim.keymap.set('n', 'tf', function() + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown({ + previewer = false, + })) +end) +-- formatter vim.keymap.set('n', 'ft', vim.lsp.buf.format, {}) +-- buffer +vim.keymap.set('n', '', ':BufferNext') +vim.keymap.set('n', '', ':BufferPrevious') +vim.keymap.set('n', 'q', ':BufferClose') + +-- comment +vim.keymap.set('n', '/', 'gcc', { remap = true }) + +-- terminal +vim.keymap.set('n', 'tr', ':ToggleTerm') + +-- File Explorer +vim.keymap.set('n', 'e', function() + require('oil').toggle_float() +end) + +-- Clear search, diff update and redraw +vim.keymap.set({ 'i', 'n' }, '', 'noh', { desc = 'Escape and clear hlsearch' }) + +-- Move 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 }) + +-- Move with shift-arrows +vim.keymap.set('n', '', '', { + desc = 'Move window to the left', +}) +vim.keymap.set('n', '', '', { + desc = 'Move window down', +}) +vim.keymap.set('n', '', '', { + desc = 'Move window up', +}) +vim.keymap.set('n', '', '', { + desc = 'Move window to the right', +}) + +-- Resize window using arrow keys +vim.keymap.set('n', '', 'resize +2', { desc = 'Increase Window Height' }) +vim.keymap.set('n', '', 'resize -2', { desc = 'Decrease Window Height' }) +vim.keymap.set('n', '', 'vertical resize -2', { desc = 'Decrease Window Width' }) +vim.keymap.set('n', '', 'vertical resize +2', { desc = 'Increase Window Width' }) + +-- clear notification +vim.keymap.set('n', 'mu', function() + require('notify').dismiss({ silent = true, pending = true }) +end, { desc = 'Dismiss All Notifications' }) + +-- Harpoon Keybinds +-- Open harpoon ui +vim.keymap.set('n', 'ho', function() + harpoon_ui.toggle_quick_menu() +end) + +-- Add current file to harpoon +vim.keymap.set('n', 'ha', function() + harpoon.mark.add_file() +end) + +-- Remove current file from harpoon +vim.keymap.set('n', 'hr', function() + harpoon.mark.rm_file() +end) + +-- Quickly jump to harpooned files +vim.keymap.set('n', '1', function() + harpoon.ui.nav_file(1) +end) + +vim.keymap.set('n', '2', function() + harpoon.ui.nav_file(2) +end) + +vim.keymap.set('n', '3', function() + harpoon.ui.nav_file(3) +end) + +vim.keymap.set('n', '4', function() + harpoon.ui.nav_file(4) +end) + +vim.keymap.set('n', '5', function() + harpoon.ui.nav_file(5) +end) diff --git a/lua/plugins/auto-pairs.lua b/lua/plugins/auto-pairs.lua index 4b256c2..4a30ea8 100644 --- a/lua/plugins/auto-pairs.lua +++ b/lua/plugins/auto-pairs.lua @@ -1,8 +1,6 @@ return { - 'altermo/ultimate-autopair.nvim', - event = { 'InsertEnter', 'CmdlineEnter' }, - branch = 'v0.6', --recommended as each new version will have breaking changes - opts = { - --Config goes here - }, + 'altermo/ultimate-autopair.nvim', + event = { 'InsertEnter', 'CmdlineEnter' }, + branch = 'v0.6', + opts = {}, } diff --git a/lua/plugins/barbar.lua b/lua/plugins/barbar.lua new file mode 100644 index 0000000..598eba3 --- /dev/null +++ b/lua/plugins/barbar.lua @@ -0,0 +1,3 @@ +return { + "romgrk/barbar.nvim", +} diff --git a/lua/plugins/codeium.lua b/lua/plugins/codeium.lua new file mode 100644 index 0000000..6ebd18b --- /dev/null +++ b/lua/plugins/codeium.lua @@ -0,0 +1,25 @@ +return { + 'Exafunction/codeium.vim', + event = 'BufEnter', + cmd = 'Codeium', + build = 'Codeium Auth:', + dependencies = { + 'nvim-lua/plenary.nvim', + 'hrsh7th/nvim-cmp', + }, + + config = function() + vim.keymap.set('i', '', function() + return vim.fn['codeium#Accept']() + end, { expr = true, silent = true }) + vim.keymap.set('i', '', function() + return vim.fn['codeium#CycleCompletions'](1) + end, { expr = true, silent = true }) + vim.keymap.set('i', '', function() + return vim.fn['codeium#CycleCompletions'](-1) + end, { expr = true, silent = true }) + vim.keymap.set('i', '', function() + return vim.fn['codeium#Clear']() + end, { expr = true, silent = true }) + end, +} diff --git a/lua/plugins/colorschemes.lua b/lua/plugins/colorschemes.lua index 3b137c9..23bfb0c 100644 --- a/lua/plugins/colorschemes.lua +++ b/lua/plugins/colorschemes.lua @@ -1,27 +1,27 @@ return { - 'navarasu/onedark.nvim', + 'navarasu/onedark.nvim', - config = function() - require('onedark').setup({ - style = 'deep', - transparent = true, - term_colors = false, - ending_tildes = false, - cmp_itemkind_reverse = false, - -- toggle_style_key = 'ot', - -- toggle_style_list = { 'dark', 'darker', 'cool', 'warm', 'warmer', 'deep', 'light' }, + config = function() + require('onedark').setup({ + style = 'deep', + transparent = true, + term_colors = false, + ending_tildes = false, + cmp_itemkind_reverse = false, + -- toggle_style_key = 'ot', + -- toggle_style_list = { 'dark', 'darker', 'cool', 'warm', 'warmer', 'deep', 'light' }, - -- Options are italic, bold, underline, none and combos 'italic,bold' - code_style = { - comments = 'italic', - keywords = 'none', - functions = 'none', - strings = 'none', - variables = 'none', - }, + -- Options are italic, bold, underline, none and combos 'italic,bold' + code_style = { + comments = 'italic', + keywords = 'none', + functions = 'none', + strings = 'none', + variables = 'none', + }, - lualine = { transparent = true }, - diagnostics = { darker = true, undercurl = true, background = false }, - }) - end, + lualine = { transparent = true }, + diagnostics = { darker = true, undercurl = true, background = false }, + }) + end, } diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index 6f7b0a1..094d769 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -37,16 +37,17 @@ return { sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'luasnip' }, -- For luasnip users. + { name = 'codeium' }, }, { { name = 'buffer' }, }), formatting = { format = lspkind.cmp_format({ mode = 'symbol', -- show only symbol annotations - maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) -- can also be a function to dynamically calculate max width such as -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, - ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) show_labelDetails = true, -- show labelDetails in menu. Disabled by default -- The function below will be called before any actual modifications from lspkind diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua new file mode 100644 index 0000000..1059a66 --- /dev/null +++ b/lua/plugins/dashboard.lua @@ -0,0 +1,10 @@ +return { + 'nvimdev/dashboard-nvim', + event = 'VimEnter', + config = function() + require('dashboard').setup({ + -- config + }) + end, + dependencies = { { 'nvim-tree/nvim-web-devicons' } }, +} diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua new file mode 100644 index 0000000..e8e10be --- /dev/null +++ b/lua/plugins/harpoon.lua @@ -0,0 +1,6 @@ +return { + { + 'ThePrimeagen/harpoon', + lazy = true, + }, +} diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index ccc14a3..93b55b8 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -23,6 +23,23 @@ return { }, }, capabilities = capabilities, + handlers = handlers, + }) + + lspconfig.clangd.setup({ + capabilities = capabilities, + handlers = handlers, + }) + lspconfig.gdscript.setup({ + capabilities = capabilities, + }) + lspconfig.pyright.setup({ + capabilities = capabilities, + handlers = handlers, + }) + lspconfig.biome.setup({ + capabilities = capabilities, + handlers = handlers, }) end, }, diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..ad65e37 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,7 @@ +return { + 'nvim-lualine/lualine.nvim', + + config = function() + require('lualine').setup() + end, +} diff --git a/lua/plugins/markdown.lua b/lua/plugins/markdown.lua new file mode 100644 index 0000000..98cd7ab --- /dev/null +++ b/lua/plugins/markdown.lua @@ -0,0 +1,12 @@ +return { + "iamcco/markdown-preview.nvim", + ft = "markdown", + build = function() + vim.fn["mkdp#util#install"]() + end, + cmd = { + "MarkdownPreviewToggle", + "MarkdownPreview", + "MarkdownPreviewStop", + }, +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index a8ab6fc..2f59b44 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -1,9 +1,9 @@ return { - 'nvim-neo-tree/neo-tree.nvim', - branch = 'v3.x', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', - 'MunifTanjim/nui.nvim', - }, + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + }, } diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index bd61589..f17fb80 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -1,13 +1,19 @@ return { - 'nvimtools/none-ls.nvim', + 'nvimtools/none-ls.nvim', - config = function() - local null_ls = require('null-ls') + config = function() + local null_ls = require('null-ls') - null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua, - }, - }) - end, + null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua, + null_ls.builtins.formatting.prettier, + null_ls.builtins.formatting.clang_format, + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.gdformat, + null_ls.builtins.formatting.djhtml, + null_ls.builtins.formatting.biome, + }, + }) + end, } diff --git a/lua/plugins/notify.lua b/lua/plugins/notify.lua new file mode 100644 index 0000000..e19eb04 --- /dev/null +++ b/lua/plugins/notify.lua @@ -0,0 +1,26 @@ +return { + 'rcarriga/nvim-notify', + + config = function() + vim.notify = require('notify') + + require('notify')('Welcome Back!') + require('notify').setup({ + background_colour = 'Normal', + fps = 30, + icons = { + DEBUG = ' ', + ERROR = ' ', + INFO = ' ', + TRACE = '✎', + WARN = ' ', + }, + level = 2, + minimum_width = 40, + maximum_width = 40, + render = 'wrapped-compact', + stages = 'slide', + timeout = 2000, + }) + end, +} diff --git a/lua/plugins/nvim-surround.lua b/lua/plugins/nvim-surround.lua new file mode 100644 index 0000000..d8014a7 --- /dev/null +++ b/lua/plugins/nvim-surround.lua @@ -0,0 +1,7 @@ +return { + "kylechui/nvim-surround", + + config = function() + require("nvim-surround").setup() + end, +} diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..75601ba --- /dev/null +++ b/lua/plugins/nvim-treesitter.lua @@ -0,0 +1,15 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + + config = function() + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { "c", "lua", "vim", "vimdoc", "python", "cpp", "html", "css", "javascript", "typescript", "json", "php" }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, +} diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua new file mode 100644 index 0000000..1c12961 --- /dev/null +++ b/lua/plugins/oil.lua @@ -0,0 +1,40 @@ +vim.api.nvim_create_autocmd('FileType', { + pattern = 'oil', + callback = function() + vim.opt_local.colorcolumn = '' + end, +}) + +return { + { + 'stevearc/oil.nvim', + opts = {}, + -- Optional dependencies + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('oil').setup({ + use_default_keymaps = false, + keymaps = { + ['g?'] = 'actions.show_help', + [''] = 'actions.select', + [''] = 'actions.select_split', + [''] = 'actions.select_vsplit', -- this is used to navigate left + [''] = 'actions.select_tab', + [''] = 'actions.preview', + [''] = 'actions.close', + [''] = 'actions.refresh', + ['-'] = 'actions.parent', + ['_'] = 'actions.open_cwd', + ['`'] = 'actions.cd', + ['~'] = 'actions.tcd', + ['gs'] = 'actions.change_sort', + ['gx'] = 'actions.open_external', + ['g.'] = 'actions.toggle_hidden', + }, + view_options = { + show_hidden = false, + }, + }) + end, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 1bbb767..1527a6e 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,13 +1,30 @@ return { 'nvim-telescope/telescope.nvim', tag = '0.1.8', - dependencies = { 'nvim-lua/plenary.nvim' }, + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', + cond = vim.fn.executable('cmake') == 1, + }, config = function() require('telescope').setup({ pickers = { - colorscheme = { enable_preview = true }, + colorscheme = { + enable_preview = true, + }, + }, + + defaults = { + layout_config = { + horizontal = { + preview_cutoff = 0, + }, + }, }, }) + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') end, } diff --git a/lua/plugins/toggle-term.lua b/lua/plugins/toggle-term.lua new file mode 100644 index 0000000..3714f51 --- /dev/null +++ b/lua/plugins/toggle-term.lua @@ -0,0 +1,9 @@ +return { + "akinsho/toggleterm.nvim", + + config = function () + require("toggleterm").setup({ + shade_terminals = false, + }) + end +} diff --git a/lua/plugins/wilder.lua b/lua/plugins/wilder.lua new file mode 100644 index 0000000..07aed5e --- /dev/null +++ b/lua/plugins/wilder.lua @@ -0,0 +1,42 @@ +return { + { + 'gelguy/wilder.nvim', + keys = { + ':', + '/', + '?', + }, + dependencies = { + 'catppuccin/nvim', + }, + config = function() + local wilder = require('wilder') + + -- Enable wilder when pressing :, / or ? + wilder.setup({ modes = { ':', '/', '?' } }) + + -- Enable fuzzy matching for commands and buffers + wilder.set_option('pipeline', { + wilder.branch( + wilder.cmdline_pipeline({ + fuzzy = 1, + }), + wilder.vim_search_pipeline({ + fuzzy = 1, + }) + ), + }) + + wilder.set_option( + 'renderer', + wilder.popupmenu_renderer(wilder.popupmenu_palette_theme({ + border = 'rounded', + max_height = '75%', + min_height = 0, + prompt_position = 'top', + reverse = 0, + })) + ) + end, + }, +} diff --git a/lua/preferences.lua b/lua/preferences.lua index 8799634..cf2c71a 100644 --- a/lua/preferences.lua +++ b/lua/preferences.lua @@ -1,8 +1,61 @@ -vim.cmd([[autocmd FileType * set formatoptions-=ro]]) +-- This file is automatically loaded by plugins.core +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' -vim.cmd('set number') -vim.cmd('set relativenumber') -vim.cmd('set noexpandtab') -vim.cmd('set tabstop=6') -vim.cmd('set shiftwidth=6') -vim.cmd('set nowrap') +local opt = vim.opt +opt.number = true +opt.relativenumber = true +opt.expandtab = false +opt.tabstop = 6 +opt.shiftwidth = 6 +opt.wrap = false + +-- netrw file explorer settings +vim.g.netrw_winsize = 20 +vim.g.netrw_banner = 0 +vim.g.netrw_liststyle = 1 + +opt.cursorline = true -- Enable highlighting of the current line +opt.expandtab = true -- Use spaces instead of tabs +opt.breakindent = true +opt.clipboard = 'unnamedplus' -- allows neovim to access the system clipboard +opt.cmdheight = 1 -- more space in the neovim command line for displaying messages +opt.conceallevel = 0 -- so that `` is visible in markdown files +opt.hlsearch = true -- highlight all matches on previous search pattern +opt.ignorecase = true -- ignore case in search patterns +opt.inccommand = 'split' -- preview incremental substitute +opt.mouse = 'a' -- allow the mouse to be used in neovim +opt.numberwidth = 4 -- set number column width to 2 {default 4} +opt.scrolloff = 10 +opt.shiftround = true -- round indent +opt.shiftwidth = 4 -- the number of spaces inserted for each indentation +opt.showcmd = false +opt.showmode = false -- we don't need to see things like -- INSERT -- anymore +opt.showtabline = 0 -- always show tabs +opt.signcolumn = 'yes' -- always show the sign column, otherwise it would shift the text each timeout +opt.smartcase = true -- smart case +opt.smartindent = true -- make indenting smarter again +opt.smarttab = true +opt.splitbelow = true -- force all horizontal splits to go below current window +opt.splitright = true -- force all vertical splits to go right of the current window +opt.swapfile = false -- creastes a swapfile +opt.tabstop = 4 -- insert 2 spaces for a tab +opt.undofile = true -- enable persistent undofile +opt.undolevels = 10000 +opt.updatetime = 50 -- faster completion (4000ms default) +opt.writebackup = false -- donot edit backups +opt.backup = false -- creates a backup file +opt.autowrite = true +opt.autoindent = true +opt.ai = true + +-- Fix markdown indentation settings +vim.g.markdown_recommended_style = 0 + +vim.opt.path:append({ '**' }) +vim.opt.shortmess:append({ W = true, I = true, c = true }) + +-- hides `~` at the end of buffer +vim.cmd([[set fillchars+=eob:\ ]]) + +vim.cmd([[autocmd FileType * set formatoptions-=ro]]) diff --git a/lua/remaps.lua b/lua/remaps.lua new file mode 100644 index 0000000..68300da --- /dev/null +++ b/lua/remaps.lua @@ -0,0 +1,278 @@ +local function map(mode, lhs, rhs, opts) + local options = { + noremap = true, + silent = true, + } + if opts then + options = vim.tbl_extend('force', options, opts) + end + vim.keymap.set(mode, lhs, rhs, options) +end + +-- Save File +map( + { + 'i', + 'v', + 'n', + 's', + }, + '', + 'w', + { + desc = 'Save file', + } +) + +map('i', '', '"+pa', { + desc = 'Paste from clipboard', +}) + +map('n', '', 'm`op``', { + desc = 'Paste below', +}) + +map('n', '', 'm`Op``', { + desc = 'Paste above', +}) + +map( + { + 'n', + 'x', + }, + '', + '"+y', + { + desc = 'Copy to clipboard', + } +) + +map( + { + 'n', + 'x', + }, + '', + '"+ydd', + { + desc = 'Cut to clipboard', + } +) + +-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933. +map('n', '', "printf('`[%s`]', getregtype()[0])", { + expr = true, + desc = 'reselect last pasted area', +}) + +map( + { + 'i', + 'v', + 'n', + 's', + }, + '', + 'wq!', + { + desc = 'Force Save file and quit', + } +) + +-- Select all text in the current buffer +map('n', '', ':keepjumps normal! ggyG', { + desc = 'Select all', +}) + +-- quit +map('n', '', 'wqa!', { + desc = 'Quit all', +}) + +-- go to beginning and end in insert mode +map('i', '', '^i', { + desc = 'Go to beginning of line', +}) +map('i', '', '', { + desc = 'Go to end of line', +}) + +-- Go to the beginning and end of current line in insert mode quickly +map('i', '', '') +map('i', '', '') + +-- insert semicolon in the end +map('i', '', 'miA;`ii', { + desc = 'insert semicolon in the end', +}) + +-- Turn the word under cursor to upper case +map('i', '', 'viwUea') +-- Turn the current word into lower case +map('i', '', 'b~lea') + +-- Undo +map('i', '', 'u') + +-- navigate within insert mode +map('i', '', '', { + desc = 'Move Left', +}) +map('i', '', '', { + desc = 'Move Right', +}) +map('i', '', '', { + desc = 'Move Down', +}) +map('i', '', '', { + desc = 'Move Up', +}) + +-- Copy whole buffer +map('n', '', '%y+', { + desc = 'Copy whole buffer', +}) + +-- Go to start or end of line easier +map( + { + 'n', + 'x', + }, + 'H', + '^', + { + desc = 'Go to beginning of line', + } +) +map( + { + 'n', + 'x', + }, + 'L', + 'g_', + { + desc = 'Go to end of line', + } +) + +-- Change text without putting it into the vim register, +map( + { + 'n', + 'x', + }, + 'c', + '"_c', + { + desc = 'Change without yanking', + } +) +map( + { + 'n', + 'x', + }, + 'C', + '"_C', + { + desc = 'Change without yanking', + } +) +map( + { + 'n', + 'x', + }, + 'cc', + '"_cc', + { + desc = 'Change without yanking', + } +) +map( + { + 'n', + 'x', + }, + 'x', + '"_x', + { + desc = 'delete without yanking', + } +) + +-- Better escape using jk in insert and terminal mode +map('i', 'jk', '') +map('i', 'kj', '') +map('i', 'jj', '') + +-- Terminal Mappings +map("t", "jk", "") +map("t", "kj", "") +map("t", "", "") + +-- Move with shift-arrows +map("n", "", "", { + desc = "Move window to the left" +}) +map("n", "", "", { + desc = "Move window down" +}) +map("n", "", "", { + desc = "Move window up" +}) +map("n", "", "", { + desc = "Move window to the right" +}) + +-- Search +map({ + "n", + "x" +}, "gw", "*N", { + desc = "Search word under cursor" +}) + +-- Some cool remaps +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") +map("n", "J", "mzJ`z") +map("n", "}", "}zzzv") +map("n", "{", "{zzzv") +map("n", "g,", "g,zvzz") +map("n", "g;", "g;zvzz") +map("n", "", "zz") +map("n", "", "zz") +map("n", "^", "g^") +map("n", "0", "g0") +-- Do not include white space characters when using $ in visual mode, +map("x", "$", "g_") +-- Always use very magic mode for searching +map("n", "/", [[/\v]]) + +-- Add undo break-points +map("i", "?", "?u") +map("i", "!", "!u") +map("i", ",", ",u") +map("i", ".", ".u") +map("i", ";", ";u") + +-- compromised backward search when comma is being used as localleader +map("n", "", ",") + +-- Better up/down +map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) + +-- Move text up and down +map("n", "", "m .+1==", { desc = "Move Down" }) +map("n", "", "m .-2==", { desc = "Move Up" }) +map("i", "", "m .+1==gi", { desc = "Move Down" }) +map("i", "", "m .-2==gi", { desc = "Move Up" }) +map("v", "", ":m '>+1gv=gv", { desc = "Move Down" }) +map("v", "", ":m '<-4gv=gv", { desc = "Move Up" })