diff --git a/lua/core/autocmd.lua b/lua/core/autocmd.lua index 08d5d93..fff2370 100644 --- a/lua/core/autocmd.lua +++ b/lua/core/autocmd.lua @@ -2,31 +2,69 @@ -- Disable autocommenting on new lines under commented ones -vim.api.nvim_create_autocmd("Filetype", { - pattern = "*", - command = "setlocal formatoptions-=c formatoptions-=r formatoptions-=o" +local augroup = vim.api.nvim_create_augroup +local autocmd = vim.api.nvim_create_autocmd + +local custom_augroup = augroup('custom_augroup', {}) + +autocmd("Filetype", { + pattern = "*", + command = "setlocal formatoptions-=c formatoptions-=r formatoptions-=o" }) -- persistent folds -vim.api.nvim_create_autocmd({"BufWinLeave"}, { - pattern = {"*.*"}, +autocmd({ "BufWinLeave" }, { + group = custom_augroup, + pattern = { "*.*" }, desc = "save view (folds), when closing file", command = "mkview", }) -vim.api.nvim_create_autocmd({"BufWinEnter"}, { - pattern = {"*.*"}, +autocmd({ "BufWinEnter" }, { + group = custom_augroup, + pattern = { "*.*" }, desc = "load view (folds), when opening file", command = "silent! loadview" }) -vim.api.nvim_create_autocmd("WinEnter", { - callback = function() - vim.wo.cursorline = true - end, +autocmd("WinEnter", { + group = custom_augroup, + callback = function() + vim.wo.cursorline = true + end, }) -vim.api.nvim_create_autocmd("WinLeave", { - callback = function() - vim.wo.cursorline = false - end, +autocmd("WinLeave", { + group = custom_augroup, + callback = function() + vim.wo.cursorline = false + end, +}) + +-- remove trailing whitespace +autocmd({"BufWritePre"}, { + group = custom_augroup, + pattern = "*", + command = [[%s/\s\+$//e]], +}) + +autocmd("LspAttach", { + group = custom_augroup, + + callback = function(e) + -- keymaps -- + local opts = { buffer = e.buf } + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', function() vim.lsp.buf.hover { border = "rounded" } end, opts) + vim.keymap.set('n', 'cl', "LspInfo", opts) + vim.keymap.set('n', 'cd', vim.diagnostic.open_float, opts) + vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) + vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'cf', function() vim.lsp.buf.format { async = true } end, opts) + vim.keymap.set('v', 'cf', function() vim.lsp.buf.format { async = true } end, opts) + vim.keymap.set("n", "ws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help { border = "rounded" } end, opts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "cw", function() vim.lsp.buf.rename() end, opts) + end, }) diff --git a/lua/core/remap.lua b/lua/core/remap.lua index 51b6888..e928142 100644 --- a/lua/core/remap.lua +++ b/lua/core/remap.lua @@ -22,6 +22,10 @@ vim.api.nvim_set_keymap("n", "bd", "bd", {}) vim.api.nvim_set_keymap("n", "bn", "bnext", {}) vim.api.nvim_set_keymap("n", "bp", "bprevious", {}) +-- quickfix operations +vim.api.nvim_set_keymap("n", "qc", "ccl", {}) +vim.api.nvim_set_keymap("n", "qw", "cw", {}) + -- moving visual blocks vim.api.nvim_set_keymap("v", "J", ":m '>+1gv=gv", {}) vim.api.nvim_set_keymap("v", "K", ":m '<-2gv=gv", {}) @@ -55,11 +59,15 @@ vim.api.nvim_set_keymap("n", "XX", ":qa!", {}) vim.api.nvim_set_keymap("n", "XZZ", ":wqa!", {}) vim.api.nvim_set_keymap("n", "x", ":q", {}) --- fast editing -vim.api.nvim_set_keymap("n", "E", ":e ", {}) - -- vertical resize vim.api.nvim_set_keymap("n", "vr", ":vertical-resize ", {}) --- fast Todo and way to notes -vim.api.nvim_set_keymap("n", "N", ":e ~/notes/Todo.md", {}) +vim.cmd([[ +function! CenterPane() + lefta vnew + wincmd w + exec 'vertical resize '. string(&columns * 0.75) + endfunction +]]) + +vim.api.nvim_set_keymap("n", "C", ":call CenterPane()", {}) diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 7185950..f56c498 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -61,11 +61,8 @@ vim.api.nvim_set_option("splitright",true) -- disable Netrw-Banner vim.g.netrw_banner = 0 - --- disable Netrw for Filetree Plugin -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 - +vim.g.netrw_browse_split = 0 +vim.g.netrw_winsize = 25 -- undotree file management vim.opt.swapfile = false diff --git a/lua/plugin/bin.lua b/lua/plugin/bin.lua deleted file mode 100644 index 26b7b0f..0000000 --- a/lua/plugin/bin.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - { - "matze/wastebin.nvim", - config = function() - require("wastebin").setup({ - url = "https://bin.xesc.de", - open_cmd = "xdg-open" - }) - end, - opts = { - vim.keymap.set("n", "wp", "WastePaste", { silent = true }), - vim.keymap.set("v", "wp", "WastePaste", { silent = true }), - }, - } -} diff --git a/lua/plugin/commenting.lua b/lua/plugin/commenting.lua index d21d817..8d96cc0 100644 --- a/lua/plugin/commenting.lua +++ b/lua/plugin/commenting.lua @@ -1,8 +1,5 @@ return { - { - "echasnovski/mini.comment", - config = function() - require("mini.comment").setup() - end, - }, + { + 'tpope/vim-commentary' + }, } diff --git a/lua/plugin/gruvbox-material.lua b/lua/plugin/gruvbox-material.lua deleted file mode 100644 index 00b4076..0000000 --- a/lua/plugin/gruvbox-material.lua +++ /dev/null @@ -1,64 +0,0 @@ -return { - { - "sainnhe/gruvbox-material", - lazy = true, - config = function() - -- Settings for colorscheme - vim.api.nvim_set_var("gruvbox_material_background", "hard") - vim.api.nvim_set_var("gruvbox_material_transparent_background", "1") - vim.api.nvim_set_var("gruvbox_material_ui_contrast", "low") - vim.api.nvim_set_var("gruvbox_material_show_eob", "0") - vim.api.nvim_set_var("gruvbox_material_enable_bold", "1") - vim.api.nvim_set_var("gruvbox_material_enable_italic", "1") - vim.api.nvim_set_var("gruvbox_material_better_performance", "1") - vim.cmd([[colo gruvbox-material]]) - - -- Settings to override colorscheme - -- vim.api.nvim_set_hl(0, "ModeMsg", { bold = true, fg = "#d8a657"}) - -- colors of tabline - vim.api.nvim_set_hl(0, "TabLine", { bg = "#3c3836", fg = "#89b482" }) - vim.api.nvim_set_hl(0, "TabLineFil", { bg = "#1d2021" }) - vim.api.nvim_set_hl(0, "TabLineSel", { bold = true, bg = "none", fg = "#d8a657" }) - -- color of statusline - vim.api.nvim_set_hl(0, "StatusLine", { bold = false, bg = "#1d2021", fg = "#89b482" }) - vim.api.nvim_set_hl(0, "StatusLineNC", { bg = "#1d2021", fg = "#5b534d" }) - -- color of vertical split line - vim.api.nvim_set_hl(0, "VertSplit", { bg = "#141617", fg = "#141617" }) - -- color of the cursorline and cursorlinenumber - vim.api.nvim_set_hl(0, "Cursorline", { bg = "#141617" }) - vim.api.nvim_set_hl(0, "CursorLineNr", { bold = true, bg = "#141617", fg = "#d8a657" }) - -- color of Floats and FloatBorders - vim.api.nvim_set_hl(0, "NormalFloat", { bg = none, fg = none }) - vim.api.nvim_set_hl(0, "FloatBorder", { bg = none, fg = "#d4be98" }) - vim.api.nvim_set_hl(0, "DiagnosticFloatingWarn", { bg = none, fg = "#d8a657" }) - vim.api.nvim_set_hl(0, "DiagnosticFloatingError", { bg = none, fg = "#ea6962" }) - vim.api.nvim_set_hl(0, "DiagnosticFloatingHint", { bg = none, fg = "#a9b665" }) - vim.api.nvim_set_hl(0, "DiagnosticFloatingInfo", { bg = none, fg = "#d4be98" }) - - -- autocommand for overrides - vim.api.nvim_create_autocmd("ColorScheme", { - pattern = "gruvbox-material", - callback = function() - vim.api.nvim_set_hl(0, "TabLine", { bg = "#3c3836", fg = "#89b482" }) - vim.api.nvim_set_hl(0, "TabLineFil", { bg = "#1d2021" }) - vim.api.nvim_set_hl(0, "TabLineSel", { bold = true, bg = "none", fg = "#d8a657" }) - -- color of statusline - vim.api.nvim_set_hl(0, "StatusLine", { bold = false, bg = "#1d2021", fg = "#89b482" }) - vim.api.nvim_set_hl(0, "StatusLineNC", { bg = "#1d2021", fg = "#5b534d" }) - -- color of vertical split line - vim.api.nvim_set_hl(0, "VertSplit", { bg = "#141617", fg = "#141617" }) - -- color of the cursorline and cursorlinenumber - vim.api.nvim_set_hl(0, "Cursorline", { bg = "#141617" }) - vim.api.nvim_set_hl(0, "CursorLineNr", { bold = true, bg = "#141617", fg = "#d8a657" }) - -- color of Floats and FloatBorders - vim.api.nvim_set_hl(0, "NormalFloat", { bg = none, fg = none }) - vim.api.nvim_set_hl(0, "FloatBorder", { bg = none, fg = "#d4be98" }) - vim.api.nvim_set_hl(0, "DiagnosticFloatingWarn", { bg = none, fg = "#d8a657" }) - vim.api.nvim_set_hl(0, "DiagnosticFloatingError", { bg = none, fg = "#ea6962" }) - vim.api.nvim_set_hl(0, "DiagnosticFloatingHint", { bg = none, fg = "#a9b665" }) - vim.api.nvim_set_hl(0, "DiagnosticFloatingInfo", { bg = none, fg = "#d4be98" }) - end, - }) - end, - }, -} diff --git a/lua/plugin/lsp.lua b/lua/plugin/lsp.lua index 0a8f8d1..cad49a6 100644 --- a/lua/plugin/lsp.lua +++ b/lua/plugin/lsp.lua @@ -13,7 +13,6 @@ return { "saadparwaiz1/cmp_luasnip", "nvim-telescope/telescope-ui-select.nvim", "nvimtools/none-ls.nvim", - "nvimdev/lspsaga.nvim", 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons', "jay-babu/mason-null-ls.nvim", @@ -209,9 +208,6 @@ return { require("telescope").setup { extensions = { ["ui-select"] = { - -- require("telescope.themes").get_dropdown { - -- -- even more opts - -- } } } } @@ -242,64 +238,6 @@ return { ensure_installed = { "clang_format", "shellharden", "shfmt" } }) - - -- lspsaga (pretty lsp-windows) - - require('lspsaga').setup({ - symbol_in_winbar = { - enable = false, - show_file = false - }, - finder = { - keys = { - toggle_or_open = "", - quit = { '', 'q' } - } - }, - outline = { - win_position = 'right', - win_width = 32, - auto_preview = true, - }, - lightbulb = { - enable = false - }, - ui = { - code_action = '', - title = true, - border = 'rounded', - }, - rename = { - in_select = false, - keys = { - quit = { '', 'q' }, - select = '' - } - }, - hover_doc = { - open_cmd = '!firefox' - }, - code_action = { - keys = { - quit = { '', 'q' } - }, - extend_gitsigns = false, - }, - definition = { - keys = { - quit = { '', 'q' }, - }, - }, - diagnostic = { - border_follow = true, - extend_relatedInformation = true, - keys = { - quit = { '', 'q' }, - quit_in_show = { '', 'q' }, - } - } - }) - -- config -- vim.diagnostic.config({ @@ -318,29 +256,6 @@ return { }, }) - -- keymaps -- - - local opts = { noremap = true, silent = true } - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'K', function() vim.lsp.buf.hover { border = "rounded" } end, opts) - vim.keymap.set('n', 'k', function() vim.lsp.buf.hover { border = "rounded" } end, opts) - vim.keymap.set('n', 'cl', "LspInfo", opts) - vim.keymap.set('n', 'cd', vim.diagnostic.open_float, opts) - vim.keymap.set('n', '[n', vim.diagnostic.goto_prev, opts) - vim.keymap.set('n', ']n', vim.diagnostic.goto_next, opts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) - vim.keymap.set('n', 'cf', function() vim.lsp.buf.format { async = true } end, opts) - vim.keymap.set('v', 'cf', function() vim.lsp.buf.format { async = true } end, opts) - vim.keymap.set("n", "fws", function() vim.lsp.buf.workspace_symbol() end, opts) - vim.keymap.set("i", "", function() vim.lsp.buf.signature_help { border = "rounded" } end, opts) - vim.keymap.set('n', '', "Lspsaga term_toggle", opts) - vim.keymap.set('t', '', "Lspsaga term_toggle", opts) - vim.keymap.set('n', 'so', 'Lspsaga outline', opts) - vim.keymap.set('n', 'sf', 'Lspsaga finder', opts) - vim.keymap.set('n', 'sd', 'Lspsaga peek_definition', opts) - vim.keymap.set('n', 'cw', "Lspsaga rename mode=n", opts) - vim.keymap.set('n', 'cA', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'ca', 'Lspsaga code_action', opts) end, } } diff --git a/lua/plugin/nvimtree.lua b/lua/plugin/nvimtree.lua deleted file mode 100644 index e35d7b4..0000000 --- a/lua/plugin/nvimtree.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - "nvim-tree/nvim-tree.lua", - version = "*", - lazy = false, - dependencies = { - "nvim-tree/nvim-web-devicons", - }, - keys = { - { "F", "NvimTreeFindFileToggle", desc = "Toggle Filetree" }, - }, - config = function() - require("nvim-tree").setup({ - view = { - width = 56, - }, - }) - end, -} diff --git a/lua/plugin/telescope.lua b/lua/plugin/telescope.lua index 3f7a68c..22cd74d 100644 --- a/lua/plugin/telescope.lua +++ b/lua/plugin/telescope.lua @@ -1,75 +1,60 @@ return { - { - "nvim-telescope/telescope.nvim", - lazy = true, - cmd = "Telescope", - version = false, - config = function() - require('telescope').setup({ - pickers = { - find_files = { - layout_config = { - prompt_position = 'top', - }, - sorting_strategy = 'ascending', - }, - live_grep = { - layout_config = { - prompt_position = 'top', - }, - sorting_strategy = 'ascending', - }, - current_buffer_fuzzy_find = { - layout_config = { - prompt_position = 'top', - }, - sorting_strategy = 'ascending', - }, - grep_string = { - layout_config = { - prompt_position = 'top', - }, - sorting_strategy = 'ascending', - }, - git_files = { - layout_config = { - prompt_position = 'top', - }, - sorting_strategy = 'ascending', - }, - keymaps = { - layout_config = { - prompt_position = 'top', - }, - sorting_strategy = 'ascending', - }, - oldfiles = { - layout_config = { - prompt_position = 'top', - }, - sorting_strategy = 'ascending', - }, - command_history = { - layout_config = { - prompt_position = 'top', - }, - sorting_strategy = 'ascending', - }, - }, - }) - end, - keys = { - { ":", "Telescope command_history", desc = "Command History" }, - { ",", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, - -- find - { "ff", "Telescope find_files", desc = "Find Files" }, - { "fb", "Telescope current_buffer_fuzzy_find", desc = "Find Strings in current Buffer" }, - { "fg", "Telescope live_grep", desc = "Grep Content in Files" }, - { "/", "Telescope current_buffer_fuzzy_find", desc = "Find Strings in current Buffer" }, - { "fh", "Telescope grep_string", desc = "Grep currently hovered String" }, - { "fG", "Telescope git_files", desc = "Find Git Files" }, - { "fk", "Telescope keymaps", desc = "List Keymaps" }, - { "fr", "Telescope oldfiles", desc = "Find Recent Files" }, + { + "nvim-telescope/telescope.nvim", + lazy = true, + cmd = "Telescope", + version = false, + config = function() + require('telescope').setup({ + pickers = { + find_files = { + layout_config = { + prompt_position = 'top', + }, + sorting_strategy = 'ascending', + }, + live_grep = { + layout_config = { + prompt_position = 'top', + }, + sorting_strategy = 'ascending', + }, + current_buffer_fuzzy_find = { + layout_config = { + prompt_position = 'top', + }, + sorting_strategy = 'ascending', + }, + grep_string = { + layout_config = { + prompt_position = 'top', + }, + sorting_strategy = 'ascending', + }, + git_files = { + layout_config = { + prompt_position = 'top', + }, + sorting_strategy = 'ascending', + }, + keymaps = { + layout_config = { + prompt_position = 'top', + }, + sorting_strategy = 'ascending', + }, }, + }) + end, + keys = { + { ",", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, + { "ff", "Telescope find_files", desc = "Find Files" }, + { "fb", "Telescope current_buffer_fuzzy_find", desc = "Find Strings in current Buffer" }, + { "fg", "Telescope live_grep", desc = "Grep Content in Files" }, + { "/", "Telescope current_buffer_fuzzy_find", desc = "Find Strings in current Buffer" }, + { "fh", "Telescope grep_string", desc = "Grep currently hovered String" }, + { "fG", "Telescope git_files", desc = "Find Git Files" }, + { "fk", "Telescope keymaps", desc = "List Keymaps" }, }, + }, } diff --git a/lua/plugin/treesitter-textobjects.lua b/lua/plugin/treesitter-textobjects.lua index c43422f..31dc854 100644 --- a/lua/plugin/treesitter-textobjects.lua +++ b/lua/plugin/treesitter-textobjects.lua @@ -14,8 +14,6 @@ return { -- You can use the capture groups defined in textobjects.scm ["af"] = "@function.outer", ["if"] = "@function.inner", - ["ap"] = "@parameter.outer", - ["ip"] = "@parameter.inner", ["ac"] = "@comment.outer", ["aS"] = "@statement.outer", ["ae"] = "@block.outer",