From b216bc031e4a709813857781aadd85239e01f6e2 Mon Sep 17 00:00:00 2001 From: Dominik Madarasz Date: Sat, 15 Jul 2023 18:26:16 +0200 Subject: [PATCH] update keymap --- lua/zak/configs/telescope.lua | 48 ++++++++++++++++++++ lua/zak/init.lua | 8 ++-- lua/zak/keymap.lua | 82 +++++++++++++---------------------- lua/zak/options.lua | 24 +++++++--- 4 files changed, 103 insertions(+), 59 deletions(-) create mode 100644 lua/zak/configs/telescope.lua diff --git a/lua/zak/configs/telescope.lua b/lua/zak/configs/telescope.lua new file mode 100644 index 0000000..7700940 --- /dev/null +++ b/lua/zak/configs/telescope.lua @@ -0,0 +1,48 @@ +-- [[ Configure Telescope ]] +-- See `:help telescope` and `:help telescope.setup()` +require('telescope').setup { + defaults = { + file_ignore_patterns = { + "node_modules", + "tags", + "art", + "bin", + "dlls", + "__pycache__" + }, + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, +} + +-- Enable telescope fzf native, if installed +pcall(require('telescope').load_extension, 'fzf') + +-- See `:help telescope.builtin` +local builtin = require('telescope.builtin') +vim.keymap.set('n', '?', builtin.oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '', builtin.find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) +end, { desc = '[/] Fuzzily search in current buffer' }) + +vim.keymap.set('n', '', builtin.git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', 'ff', builtin.buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) +vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', 'ps', function () + builtin.grep_string({ search = vim.fn.input("Grep > ") }) +end) diff --git a/lua/zak/init.lua b/lua/zak/init.lua index 3162a70..78421dd 100644 --- a/lua/zak/init.lua +++ b/lua/zak/init.lua @@ -1,7 +1,5 @@ --- load options +-- load lazy package manager require('configs.lazy') -require('options') -require('keymap') -- load configs local config_path = vim.fn.stdpath("config") .. "/lua/zak/configs" @@ -10,3 +8,7 @@ for _, file in ipairs(vim.fn.readdir(config_path, [[v:val =~ '\.lua$']])) do require("configs."..file:gsub("%.lua$", "")) end end + +-- load options +require('options') +require('keymap') diff --git a/lua/zak/keymap.lua b/lua/zak/keymap.lua index 3a63299..fdc311c 100644 --- a/lua/zak/keymap.lua +++ b/lua/zak/keymap.lua @@ -19,30 +19,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { pattern = '*', }) --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - file_ignore_patterns = { - "node_modules", - "tags", - "art", - "bin", - "dlls", - "__pycache__" - }, - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, -} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - -- other maps vim.keymap.set('n', 'mm', vim.cmd.Ex) @@ -55,36 +31,40 @@ vim.keymap.set('n', '', ':!./build.sh') vim.keymap.set('n', '', ':!./build.sh') -- scroll keymap -vim.keymap.set('n', '', '') -vim.keymap.set('n', '', '') - --- See `:help telescope.builtin` -local builtin = require('telescope.builtin') -vim.keymap.set('n', '?', builtin.oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', builtin.find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -vim.keymap.set('n', '', builtin.git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'ff', builtin.buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) -vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'ps', function () - builtin.grep_string({ search = vim.fn.input("Grep > ") }) -end) +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) + +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- greatest remap ever +vim.keymap.set("x", "p", [["_dP]]) + +-- next greatest remap ever : asbjornHaland +vim.keymap.set({ "n", "v" }, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +vim.keymap.set({ "n", "v" }, "d", [["_d]]) + +-- This is going to get me cancelled +vim.keymap.set("i", "", "") + +vim.keymap.set("n", "Q", "") +vim.keymap.set("n", "f", vim.lsp.buf.format) + +vim.keymap.set("n", "", "cnextzz") +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz") +vim.keymap.set("n", "j", "lprevzz") + +vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) diff --git a/lua/zak/options.lua b/lua/zak/options.lua index 17084d2..316d28f 100644 --- a/lua/zak/options.lua +++ b/lua/zak/options.lua @@ -3,22 +3,30 @@ -- Set highlight on search vim.o.hlsearch = false +vim.o.incsearch = true -- Make line numbers default vim.wo.number = true +vim.o.guicursor = "" +vim.o.nu = true +vim.o.relativenumber = true -- Enable mouse mode vim.o.mouse = 'a' -- Sync clipboard between OS and Neovim. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` vim.o.clipboard = 'unnamedplus' -- Enable break indent vim.o.breakindent = true +-- disable text wrap +vim.o.wrap = false + -- Save undo history +vim.o.swapfile = false +vim.o.backup = false +vim.o.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.o.undofile = true -- Case insensitive searching UNLESS /C or capital in search @@ -28,8 +36,8 @@ vim.o.smartcase = true -- Keep signcolumn on by default vim.wo.signcolumn = 'yes' --- Decrease update time -vim.o.updatetime = 250 +-- Set update time +vim.o.updatetime = 50 vim.o.timeout = true vim.o.timeoutlen = 300 @@ -39,9 +47,15 @@ vim.o.completeopt = 'menuone,noselect' -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true +vim.o.scrolloff = 8 +vim.o.signcolumn = "yes" +vim.opt.isfname:append("@-@") +vim.o.colorcolumn = "80" + -- indent setup -vim.opt.list = false +vim.o.list = false vim.opt.listchars:append "eol: " +vim.o.smartindent = true vim.cmd([[ set shellcmdflag=-c ]])