diff --git a/ftplugin/c.lua b/ftplugin/c.lua new file mode 100644 index 0000000..0e4c436 --- /dev/null +++ b/ftplugin/c.lua @@ -0,0 +1 @@ +vim.opt.colorcolumn = "81" diff --git a/ftplugin/python.lua b/ftplugin/python.lua index 918114f..b51ccb3 100644 --- a/ftplugin/python.lua +++ b/ftplugin/python.lua @@ -1,3 +1,4 @@ setlocal tabstop = 4 setlocal softtabstop = 4 setlocal shiftwidth = 4 +vim.opt.colorcolumn="80" diff --git a/ftplugin/tex.lua b/ftplugin/tex.lua index 6262f2e..30b0cff 100644 --- a/ftplugin/tex.lua +++ b/ftplugin/tex.lua @@ -5,6 +5,7 @@ vim.api.nvim_buf_set_keymap(0, "i", "", " :exec 'w' :exec '!xelat vim.api.nvim_buf_set_keymap(0, "v", "", " :exec 'w' :exec '!xelatex %'", {}) -- Open PDF-Viewer from LaTeX-file +vim.api.nvim_buf_set_keymap(0, "n", "cz", ":silent !zathura --fork %:r.pdf& ", {}) vim.api.nvim_buf_set_keymap(0, "n", "", ":silent !zathura --fork %:r.pdf& ", {}) vim.api.nvim_buf_set_keymap(0, "i", "", " :silent !zathura --fork %:r.pdf& ", {}) vim.api.nvim_buf_set_keymap(0, "v", "", " :silent !zathura --fork %:r.pdf& ", {}) diff --git a/init.lua b/init.lua index 6c2aedb..3652a0e 100644 --- a/init.lua +++ b/init.lua @@ -22,8 +22,9 @@ require("lazy").setup({ border = "rounded", }, install = { - colorscheme = { "gruvbox-material" } + colorscheme = { "everforest" } }, + change_detection = { notify = false } }) diff --git a/lua/core/autocmd.lua b/lua/core/autocmd.lua index e7ba79f..08d5d93 100644 --- a/lua/core/autocmd.lua +++ b/lua/core/autocmd.lua @@ -7,7 +7,26 @@ vim.api.nvim_create_autocmd("Filetype", { command = "setlocal formatoptions-=c formatoptions-=r formatoptions-=o" }) -vim.api.nvim_create_autocmd("FocusLost", { - pattern = "*", - command = ":wa" +-- persistent folds +vim.api.nvim_create_autocmd({"BufWinLeave"}, { + pattern = {"*.*"}, + desc = "save view (folds), when closing file", + command = "mkview", +}) +vim.api.nvim_create_autocmd({"BufWinEnter"}, { + pattern = {"*.*"}, + desc = "load view (folds), when opening file", + command = "silent! loadview" +}) + +vim.api.nvim_create_autocmd("WinEnter", { + callback = function() + vim.wo.cursorline = true + end, +}) + +vim.api.nvim_create_autocmd("WinLeave", { + callback = function() + vim.wo.cursorline = false + end, }) diff --git a/lua/core/remap.lua b/lua/core/remap.lua index fdf942e..1d68274 100644 --- a/lua/core/remap.lua +++ b/lua/core/remap.lua @@ -18,10 +18,19 @@ vim.api.nvim_set_keymap("n", "", "l", {}) -- buffer operations vim.api.nvim_set_keymap("n", "", "", {}) -vim.api.nvim_set_keymap("n", "on", "w %bd e#", {}) vim.api.nvim_set_keymap("n", "bd", "bd", {}) -vim.api.nvim_set_keymap("n", "", "bprevious", {}) -vim.api.nvim_set_keymap("n", "", "bnext", {}) +vim.api.nvim_set_keymap("n", "bn", "bnext", {}) +vim.api.nvim_set_keymap("n", "bp", "bprevious", {}) + +-- quickfix and locationlist +vim.api.nvim_set_keymap("n", "", "cnextzz", {}) +vim.api.nvim_set_keymap("n", "", "cprevzz", {}) +vim.api.nvim_set_keymap("n", "h", "lnextzz", {}) +vim.api.nvim_set_keymap("n", "l", "lprevzz", {}) +vim.api.nvim_set_keymap("n", "L", "lcl", {}) +vim.api.nvim_set_keymap("n", "Q", "cw", {}) +vim.api.nvim_set_keymap("n", "q", "ccl", {}) + -- moving visual blocks vim.api.nvim_set_keymap("v", "J", ":m '>+1gv=gv", {}) @@ -31,21 +40,37 @@ vim.api.nvim_set_keymap("v", "K", ":m '<-2gv=gv", {}) vim.api.nvim_set_keymap("n", "d", "\"_d", {}) vim.api.nvim_set_keymap("v", "d", "\"_d", {}) +-- paste without yanking selected text +vim.api.nvim_set_keymap("x", "p", [["_dP]], {}) + -- copy to system clipboard vim.api.nvim_set_keymap("n", "y", "\"+y", {}) vim.api.nvim_set_keymap("v", "y", "\"+y", {}) vim.api.nvim_set_keymap("n", "Y", "\"+Y", {}) -- paste from system clipboard -vim.api.nvim_set_keymap("n", "p", "\"+p", {}) - --- opening explorer -vim.api.nvim_set_keymap("n", "E", ":20Lexplore", {}) +vim.api.nvim_set_keymap("n", "P", "\"+p", {}) -- make current file (un)executable vim.api.nvim_set_keymap("n", "mx", ":exec 'w' !chmod +x %", { silent = true }) vim.api.nvim_set_keymap("n", "mX", ":exec 'w' !chmod -x %", { silent = true }) --- mk- and loadview for view-persistance -vim.api.nvim_set_keymap("n", "vm", ":exec 'w' mkview ", {silent = true}) -vim.api.nvim_set_keymap("n", "vl", ":exec 'w' loadview ", {silent = true}) +-- for fast save +vim.api.nvim_set_keymap("n", "", ":exec 'w'", {silent = true}) + +-- r for redo +vim.api.nvim_set_keymap("n", "r", ":redo ", {silent = true}) + +-- better ZQ +vim.api.nvim_set_keymap("n", "zq", ":q!", {}) + +-- even better +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 ", {}) diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 2cc9847..18b9d69 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -1,7 +1,7 @@ -- Settings -- cursor -vim.api.nvim_set_option("guicursor","n-v-c-sm:hor20-Cursor,i-ci-ve:ver80-iCursor,r-cr-o:hor40,a:blinkwait700-blinkoff400-blinkon250") +vim.api.nvim_set_option("guicursor","n-v-c-sm:hor100-Cursor,i-ci-ve:ver100-iCursor,r-cr-o:hor40,a:blinkwait700-blinkoff400-blinkon250") -- disable mouse vim.api.nvim_set_option("mouse","") @@ -9,7 +9,7 @@ vim.api.nvim_set_option("mouse","") -- relative numbers vim.opt.nu = true vim.opt.rnu = true -vim.opt.signcolumn = 'yes' +vim.opt.signcolumn = 'yes:3' -- setting completion menu for autocompletion vim.opt.completeopt = 'menu,menuone,noselect' @@ -24,6 +24,12 @@ vim.opt.expandtab = true -- enable foldcolumn vim.wo.foldcolumn = "2" +-- enable wrap +vim.opt.wrap = true + +-- allow "@" in filenames +vim.opt.isfname:append("@-@") + -- smart indenting by vim vim.api.nvim_set_option("smartindent",true) @@ -39,7 +45,7 @@ vim.api.nvim_set_option("background", "dark") -- always center -- vim.api.nvim_set_option("scrolloff",999) -vim.api.nvim_set_option("scrolloff",15) +vim.opt.scrolloff = 10 -- spellchecking vim.wo.spell = true @@ -56,8 +62,19 @@ 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 + + -- undotree file management vim.opt.swapfile = false vim.opt.backup = false vim.opt.undodir = os.getenv("HOME") .. "/.local/share/nvim/undodir" vim.opt.undofile = true + +-- message options +vim.opt.shortmess = "aItTF" + +-- hide buffers instead of closing +vim.opt.hidden = true diff --git a/lua/core/statusline.lua b/lua/core/statusline.lua index 9672388..4852505 100644 --- a/lua/core/statusline.lua +++ b/lua/core/statusline.lua @@ -1,7 +1,7 @@ -- statusline -vim.api.nvim_set_option("laststatus", 2) +vim.api.nvim_set_option("laststatus", 3) vim.api.nvim_set_option("statusline", " ") -- tabline -- always show tabline (0 = never, 1 = only with at least 2 tabs, 2 = always) and colors -vim.api.nvim_set_option("showtabline", 2) +vim.api.nvim_set_option("showtabline", 1) diff --git a/lua/plugin/bin.lua b/lua/plugin/bin.lua new file mode 100644 index 0000000..26b7b0f --- /dev/null +++ b/lua/plugin/bin.lua @@ -0,0 +1,15 @@ +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/bufferline.lua b/lua/plugin/bufferline.lua deleted file mode 100644 index b13e1bc..0000000 --- a/lua/plugin/bufferline.lua +++ /dev/null @@ -1,27 +0,0 @@ -return { - { - "akinsho/bufferline.nvim", - config = function() - require("bufferline").setup({ - options = { - offsets = { - { - filetype = "netrw", - text = "File Explorer", - highlight = "Directory", - text_align = 'center', - separator = true - } - }, - show_buffer_close_icons = false, - }, - highlights = { - buffer_selected = { - fg = "#d8a657", - bg = "#141617", - }, - }, - }) - end, - } -} diff --git a/lua/plugin/everforest.lua b/lua/plugin/everforest.lua index 742b554..cb4134b 100644 --- a/lua/plugin/everforest.lua +++ b/lua/plugin/everforest.lua @@ -1,7 +1,7 @@ return { { "sainnhe/everforest", - lazy = true, + priority = 1000, config = function() -- Settings for colorscheme vim.api.nvim_set_var("everforest_background", "hard") @@ -16,8 +16,8 @@ return { -- 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, "TabLine", { bg = "#272e33", fg = "#dfa000" }) + vim.api.nvim_set_hl(0, "TabLineFil", { bg = "#374145" }) 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" }) @@ -25,22 +25,22 @@ return { -- 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" }) + vim.api.nvim_set_hl(0, "Cursorline", { bg = "#3a464c" }) + vim.api.nvim_set_hl(0, "CursorLineNr", { bold = true, fg = "#dbbc7f" }) -- 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" }) + vim.api.nvim_set_hl(0, "FloatBorder", { bg = none, fg = "#9da9a0" }) + vim.api.nvim_set_hl(0, "DiagnosticFloatingWarn", { bg = none, fg = "#dfa000" }) + vim.api.nvim_set_hl(0, "DiagnosticFloatingError", { bg = none, fg = "#f85552" }) + vim.api.nvim_set_hl(0, "DiagnosticFloatingHint", { bg = none, fg = "#35a77c" }) + vim.api.nvim_set_hl(0, "DiagnosticFloatingInfo", { bg = none, fg = "#8da101" }) -- autocommand for overrides vim.api.nvim_create_autocmd("ColorScheme", { pattern = "everforest", 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, "TabLine", { bg = "#272e33", fg = "#dfa000" }) + vim.api.nvim_set_hl(0, "TabLineFil", { bg = "#374145" }) 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" }) @@ -48,15 +48,15 @@ return { -- 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" }) + vim.api.nvim_set_hl(0, "Cursorline", { bg = "#3c464c" }) + vim.api.nvim_set_hl(0, "CursorLineNr", { bold = true, fg = "#dbbc7f" }) -- 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" }) + vim.api.nvim_set_hl(0, "FloatBorder", { bg = none, fg = "#9da9a0" }) + vim.api.nvim_set_hl(0, "DiagnosticFloatingWarn", { bg = none, fg = "#dfa000" }) + vim.api.nvim_set_hl(0, "DiagnosticFloatingError", { bg = none, fg = "#f85552" }) + vim.api.nvim_set_hl(0, "DiagnosticFloatingHint", { bg = none, fg = "#35a77c" }) + vim.api.nvim_set_hl(0, "DiagnosticFloatingInfo", { bg = none, fg = "#8da101" }) end, }) end, diff --git a/lua/plugin/fugitive.lua b/lua/plugin/fugitive.lua deleted file mode 100644 index cd5bdbb..0000000 --- a/lua/plugin/fugitive.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - { - 'tpope/vim-fugitive', - keys = { - { "GG", "Git ", desc = "git" }, - { "Gs", "Git status ", desc = "git status" }, - { "Gd", "Git diff ", desc = "git diff" }, - { "GD", "Git diff --staged ", desc = "git diff --staged" }, - { "Gl", "Git log --graph ", desc = "git log --graph" }, - { "Ga", "Git add --interactive ", desc = "git add" }, - { "GA", "Git add -A ", desc = "git add -A " }, - { "Gc", "Git commit ", desc = "git commit" }, - { "GC", "Git commit --amend ", desc = "git commit --amend " }, - { "Gp", "Git push ", desc = "git push" }, - { "GP", "Git pull ", desc = "git pull" }, - }, - } -} diff --git a/lua/plugin/gitsigns.lua b/lua/plugin/gitsigns.lua index 9b63384..de1c022 100644 --- a/lua/plugin/gitsigns.lua +++ b/lua/plugin/gitsigns.lua @@ -15,35 +15,12 @@ return { opts.buffer = bufnr vim.keymap.set(mode, l, r, opts) end - - -- Navigation - map('n', ']c', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '' - end, { expr = true }) - - map('n', '[c', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '' - end, { expr = true }) - - -- Actions - map({ 'n', 'v' }, 'hs', ':Gitsigns stage_hunk') - map({ 'n', 'v' }, 'hr', ':Gitsigns reset_hunk') - map('n', 'hS', gs.stage_buffer) - map('n', 'hu', gs.undo_stage_hunk) - map('n', 'hR', gs.reset_buffer) - map('n', 'hp', gs.preview_hunk) - map('n', 'hb', function() gs.blame_line { full = true } end) - map('n', 'tb', gs.toggle_current_line_blame) - map('n', 'hd', gs.diffthis) - map('n', 'hD', function() gs.diffthis('~') end) - map('n', 'td', gs.toggle_deleted) - - -- Text object - map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk') + map('n', 'gB', function() gs.blame_line { full = true } end) + map('n', 'gb', gs.toggle_current_line_blame) + map('n', 'gs', gs.stage_hunk) -- git stage this + map('v', 'gs', gs.stage_hunk) -- git stage this + map('n', 'gus', gs.undo_stage_hunk) -- git undo stage this + map('v', 'gus', gs.undo_stage_hunk) -- git undo stage this end }) end, diff --git a/lua/plugin/gruvbox-material.lua b/lua/plugin/gruvbox-material.lua index fb9148b..00b4076 100644 --- a/lua/plugin/gruvbox-material.lua +++ b/lua/plugin/gruvbox-material.lua @@ -1,7 +1,7 @@ return { { "sainnhe/gruvbox-material", - priority = 1000, + lazy = true, config = function() -- Settings for colorscheme vim.api.nvim_set_var("gruvbox_material_background", "hard") diff --git a/lua/plugin/harpoon.lua b/lua/plugin/harpoon.lua new file mode 100644 index 0000000..b7d297f --- /dev/null +++ b/lua/plugin/harpoon.lua @@ -0,0 +1,31 @@ +return { + { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { + "nvim-lua/plenary.nvim", + lazy = true, + }, + config = function() + local harpoon = require("harpoon") + harpoon:setup() + + vim.keymap.set("n", "a", function() harpoon:list():add() end) + vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) + + vim.keymap.set("n", "n", function() harpoon:list():select(1) end) + vim.keymap.set("n", "e", function() harpoon:list():select(2) end) + vim.keymap.set("n", "i", function() harpoon:list():select(3) end) + vim.keymap.set("n", "o", function() harpoon:list():select(4) end) + vim.keymap.set("n", "1", function() harpoon:list():select(1) end) + vim.keymap.set("n", "2", function() harpoon:list():select(2) end) + vim.keymap.set("n", "3", function() harpoon:list():select(3) end) + vim.keymap.set("n", "4", function() harpoon:list():select(4) end) + vim.keymap.set("n", "5", function() harpoon:list():select(5) end) + vim.keymap.set("n", "6", function() harpoon:list():select(6) end) + vim.keymap.set("n", "7", function() harpoon:list():select(7) end) + vim.keymap.set("n", "8", function() harpoon:list():select(8) end) + vim.keymap.set("n", "9", function() harpoon:list():select(9) end) + end + } +} diff --git a/lua/plugin/lsp.lua b/lua/plugin/lsp.lua new file mode 100644 index 0000000..90735cd --- /dev/null +++ b/lua/plugin/lsp.lua @@ -0,0 +1,342 @@ +return { + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/nvim-cmp", + "L3MON4D3/LuaSnip", + "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", + }, + config = function() + -- setup -- + + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities() + ) + + -- mason -- + + require("mason").setup({ + PATH = "append", + ui = { + border = "rounded", + icons = { + package_installed = "✔", + package_pending = "➜", + package_uninstalled = "✘" + } + } + }) + + -- mason lspconfig -- + + require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + "clangd", + "rust_analyzer", + }, + handlers = { + -- The first entry (without a key) will be the default handler + -- and will be called for each installed server that doesn't have + -- a dedicated handler. + function(server_name) -- default handler (optional) + require("lspconfig")[server_name].setup { + capabilities = capabilities + } + end, + clangd = function() + require("lspconfig").clangd.setup { + capabilities = capabilities, + on_attach = function(client) + client.server_capabilities.documentFormattingProvider = false + client.server_capabilities.documentRangeFormattingProvider = false + end, + } + end, + } + }) + + -- telescope ui for null-ls + + require("telescope").setup { + extensions = { + ["ui-select"] = { + -- require("telescope.themes").get_dropdown { + -- -- even more opts + -- } + } + } + } + require("telescope").load_extension("ui-select") + + + -- null-ls (none-ls) + + local null_ls = require('null-ls') + require("null-ls").setup({ + sources = { + null_ls.builtins.diagnostics.trail_space.with { + disabled_filetypes = { "lua" } + }, + null_ls.builtins.diagnostics.sqlfluff.with({ + extra_args = { "--dialect", "sqlite" }, + }), + null_ls.builtins.formatting.sqlfluff.with({ + extra_args = { "--dialect", "sqlite" }, + }), + null_ls.builtins.formatting.clang_format.with({ + extra_args = { "-style={BasedOnStyle: llvm, IndentWidth: 2, BreakBeforeBraces: Linux, ColumnLimit: 0}" } + }) + }, + }) + + require("mason-null-ls").setup({ + 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' }, + } + } + }) + + -- autocomplete -- + + local kind_icons = { + Text = "", + Method = "󰆧", + Function = "󰊕", + Constructor = "", + Field = "󰇽", + Variable = "󰂡", + Class = "󰠱", + Interface = "", + Module = "", + Property = "󰜢", + Unit = "", + Value = "󰎠", + Enum = "", + Keyword = "󰌋", + Snippet = "", + Color = "󰏘", + File = "󰈙", + Reference = "", + Folder = "󰉋", + EnumMember = "", + Constant = "󰏿", + Struct = "", + Event = "", + Operator = "󰆕", + TypeParameter = "󰅲" + } + + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and + vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + + local luasnip = require("luasnip") + local cmp = require("cmp") + cmp.setup({ + formatting = { + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + -- Source + vim_item.menu = ({ + buffer = "", + nvim_lsp = "", + luasnip = "", + nvim_lua = "", + latex_symbols = "", + })[entry.source.name] + return vim_item + end + }, + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.abort() + else + cmp.complete() + end + end), + [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, -- For luasnip users. + { + name = 'buffer', + option = { + get_bufnrs = function() + return vim.api.nvim_list_bufs() + end + }, + }, + }, { + }), + -- Set configuration for specific filetype. + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }), + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + }) + + -- config -- + + vim.diagnostic.config({ + update_in_insert = true, + signs = { text = { [vim.diagnostic.severity.ERROR] = "✘ ", [vim.diagnostic.severity.WARN] = " ", [vim.diagnostic.severity.HINT] = " ", [vim.diagnostic.severity.INFO] = " " } }, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + virtual_text = { + prefix = '●', -- Could be '●', '■', 'x', '▎', or anything else + }, + }) + + -- 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/lspconfig.lua b/lua/plugin/lspconfig.lua deleted file mode 100644 index d676f62..0000000 --- a/lua/plugin/lspconfig.lua +++ /dev/null @@ -1,117 +0,0 @@ -return { - { - "neovim/nvim-lspconfig", - -- event = "BufReadPre", - config = function() - require('lspconfig.ui.windows').default_options.border = 'rounded' - vim.api.nvim_set_hl(0, "LspInfoBorder", { bg = none, fg = "#d4be98" }) - local opts = { noremap = true, silent = true } - vim.keymap.set('n', 'cd', vim.diagnostic.open_float, opts) - vim.keymap.set('n', 'cl', "LspInfo", 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', 'q', vim.diagnostic.setloclist, opts) - - local on_attach = function(client, bufnr) - -- enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'k', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'gK', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'cw', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'cf', function() vim.lsp.buf.format { async = true } end, bufopts) - vim.keymap.set('v', 'cf', function() vim.lsp.buf.format { async = true } end, bufopts) - end - - local signs = { Error = "✘ ", Warn = " ", Hint = " ", Info = " " } - -- local signs = { Error = "✘ ", Warn = " ", Hint = " ", Info = " " } - -- local signs = { Error = "✘ ", Warn = "⚠ ", Hint = " ", Info = " " } -- Unicode - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl }) - end - - - local border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, - } - - vim.diagnostic.config({ - float = { border = border }, - virtual_text = { - prefix = '●', -- Could be '●', '■', 'x', '▎' - }, - update_in_insert = true - }) - - -- LSP settings (for overriding per client) - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signatureHelp, { border = border }) - end, - }, - - { - "williamboman/mason.nvim", - lazy = true, - cmd = "Mason", - config = function() - require("mason").setup({ - ui = { - border = "rounded", - icons = { - package_installed = "✔", - package_pending = "➜", - package_uninstalled = "✘" - } - } - }) - end, - }, - - { - "williamboman/mason-lspconfig.nvim", - -- event = "BufReadPre", - config = function() - require("mason-lspconfig").setup({ - ensure_installed = { - "lua_ls", - "clangd", - } - }) - - require("mason-lspconfig").setup_handlers { - -- The first entry (without a key) will be the default handler - -- and will be called for each installed server that doesn't have - -- a dedicated handler. - function(server_name) -- default handler (optional) - require("lspconfig")[server_name].setup { - on_attach = on_attach, - handlers = handlers, - } - end, - } - end, - }, -} diff --git a/lua/plugin/lualine.lua b/lua/plugin/lualine.lua index 96ff0d4..055ae24 100644 --- a/lua/plugin/lualine.lua +++ b/lua/plugin/lualine.lua @@ -1,152 +1,161 @@ return { - { - "nvim-lualine/lualine.nvim", - config = function() - vim.api.nvim_set_option("showmode", false) - local custom_gruvbox = require 'lualine.themes.gruvbox-material' - custom_gruvbox.normal.a.bg = '#89b482' - custom_gruvbox.normal.c.bg = '#141617' - custom_gruvbox.insert.a.bg = '#d8a657' - custom_gruvbox.visual.a.bg = '#a9b665' - custom_gruvbox.replace.a.bg = '#ea6962' - require('lualine').setup { - options = { - theme = custom_gruvbox, - component_separators = { left = '', right = '' }, - section_separators = { left = '', right = '' }, - disabled_filetypes = { 'netrw', 'Trouble' } - }, - sections = { - lualine_a = { - { - 'mode', - padding = 1, - } - }, - lualine_b = { - { - 'branch', - icon = '', - color = { fg = '#d8a657', bg = '#141617', gui = 'bold' }, - padding = 1, - } - }, - lualine_c = { - { - 'filename', - color = { gui = 'italic', fg = '#d3869b', bg = '#1d2021' }, - padding = 1, - path = 1, - } - }, - lualine_x = { - { - 'filetype', - color = { bg = '#1d2021', fg = '#d4be98', gui = 'italic' }, - padding = 1, - fmt = function(str) - return (str:gsub("^%l", string.upper)) - end, - }, - { - 'fileformat', - color = {gui = 'italic'}, - symbols = { - unix = '(unix)', - dos = '(dos)', - mac = '(mac)', - }, - } + { + "nvim-lualine/lualine.nvim", + config = function() + vim.api.nvim_set_option("showmode", false) + local custom_gruvbox = require 'lualine.themes.gruvbox-material' + custom_gruvbox.normal.a.bg = '#89b482' + custom_gruvbox.normal.c.bg = '' + custom_gruvbox.insert.a.bg = '#d8a657' + custom_gruvbox.visual.a.bg = '#a9b665' + custom_gruvbox.replace.a.bg = '#ea6962' - }, - lualine_y = { - { - 'diagnostics', - color = { gui = 'bold', bg = '#141617' }, - sections = { 'error', 'warn', 'info', 'hint' }, - symbols = { error = "✘ ", warn = " ", info = " ", hint = "󰌶 " }, - padding = 1, - update_in_insert = true - }, - { - 'diff', - icon = { ' ', color = { bg = '#141617', fg = '#d8a657', gui = 'bold' } }, - color = { gui = 'bold', bg = '#141617' }, - padding = 1, - } - }, - lualine_z = { - { - 'location', - padding = 1, - } - } - }, - inactive_sections = { - lualine_a = { - { - 'mode', - padding = 1, - } - }, - lualine_b = { - { - 'branch', - icon = '', - padding = 1, - } - }, - lualine_c = { - { - 'filename', - padding = 1, - path = 1, - } - }, - lualine_x = { - { - 'filetype', - color = { gui = 'italic' }, - padding = 1, - fmt = function(str) - return (str:gsub("^%l", string.upper)) - end, - }, - { - 'fileformat', - color = {gui = 'italic'}, - symbols = { - unix = 'Unix', - dos = 'Dos', - mac = 'Mac', - }, - }, - }, - lualine_y = { - { - 'diagnostics', - color = { gui = 'bold', bg = '#141617' }, - sections = { 'error', 'warn', 'info', 'hint' }, - symbols = { error = "✘ ", warn = " ", info = " ", hint = "󰌶 " }, - padding = 1, - update_in_insert = true - }, - { - 'diff', - icon = { ' ', color = { bg = '#141617', gui = 'bold' } }, - color = { gui = 'bold', bg = '#141617' }, - padding = 1, - } - }, - lualine_z = { - { - 'location', - padding = 1, - }, - } - }, - } - end, - }, + local function lspsaga() + return require('lspsaga.symbol.winbar').get_bar() + end + require('lualine').setup { + options = { + theme = custom_gruvbox, + globalstatus = true, + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + disabled_filetypes = { 'netrw', 'Trouble' }, + }, + sections = { + lualine_a = { + { + 'mode', + padding = 1, + } + }, + lualine_b = { + { + 'branch', + icon = '', + color = { fg = '#d8a657', bg = '#141617', gui = 'bold' }, + padding = 1, + }, + { + 'filename', + color = { gui = 'italic', fg = '#d3869b', bg = '#1d2021' }, + padding = 1, + path = 1, + }, + }, + lualine_c = { + { + lspsaga + } + }, + lualine_x = { + { + 'filetype', + color = { bg = '#1d2021', fg = '#d4be98', gui = 'italic' }, + padding = 1, + fmt = function(str) + return (str:gsub("^%l", string.upper)) + end, + }, + { + 'fileformat', + color = { gui = 'italic', bg = '#141617' }, + symbols = { + unix = '(unix)', + dos = '(dos)', + mac = '(mac)', + }, + } + + }, + lualine_y = { + { + 'diagnostics', + color = { gui = 'bold', bg = '#141617' }, + sections = { 'error', 'warn', 'info', 'hint' }, + symbols = { error = "✘ ", warn = " ", info = " ", hint = " " }, + padding = 1, + update_in_insert = true + }, + { + 'diff', + icon = { ' ', color = { bg = '#141617', fg = '#d8a657', gui = 'bold' } }, + color = { gui = 'bold', bg = '#141617' }, + padding = 1, + } + }, + lualine_z = { + { + 'location', + padding = 1, + } + } + }, + + inactive_sections = { + lualine_a = { + { + 'mode', + padding = 1, + } + }, + lualine_b = { + { + 'branch', + icon = '', + padding = 1, + }, + { + 'filename', + padding = 1, + path = 1, + } + }, + lualine_c = { + }, + lualine_x = { + { + 'filetype', + color = { gui = 'italic' }, + padding = 1, + fmt = function(str) + return (str:gsub("^%l", string.upper)) + end, + }, + { + 'fileformat', + color = { gui = 'italic' }, + symbols = { + unix = 'Unix', + dos = 'Dos', + mac = 'Mac', + }, + }, + }, + lualine_y = { + { + 'diagnostics', + color = { gui = 'bold', bg = '#141617' }, + sections = { 'error', 'warn', 'info', 'hint' }, + symbols = { error = "✘ ", warn = " ", info = " ", hint = "󰌶 " }, + padding = 1, + update_in_insert = true + }, + { + 'diff', + icon = { ' ', color = { bg = '#141617', gui = 'bold' } }, + color = { gui = 'bold', bg = '#141617' }, + padding = 1, + } + }, + lualine_z = { + { + 'location', + padding = 1, + }, + } + }, + } + end, + }, } diff --git a/lua/plugin/marks.lua b/lua/plugin/marks.lua new file mode 100644 index 0000000..bb23dc8 --- /dev/null +++ b/lua/plugin/marks.lua @@ -0,0 +1,12 @@ +return { + { + "chentoast/marks.nvim", + event = "VeryLazy", + opts = {}, + config = function() + require 'marks'.setup({ + sign_priority = 5, + }) + end, + } +} diff --git a/lua/plugin/none-ls.lua b/lua/plugin/none-ls.lua deleted file mode 100644 index 22443ff..0000000 --- a/lua/plugin/none-ls.lua +++ /dev/null @@ -1,59 +0,0 @@ -return { - { - "nvimtools/none-ls.nvim", - -- event = "BufReadPost", - dependencies = { - { - "nvim-telescope/telescope-ui-select.nvim", - lazy = true, - config = function() - -- This is your opts table - require("telescope").setup { - extensions = { - ["ui-select"] = { - -- require("telescope.themes").get_dropdown { - -- -- even more opts - -- } - } - } - } - require("telescope").load_extension("ui-select") - end, - }, - }, - opts = function() - local null_ls = require('null-ls') - return { - border = 'rounded', - on_attach = function(client, bufnr) - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'k', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'cw', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'cf', function() vim.lsp.buf.format { async = true } end, bufopts) - vim.keymap.set('v', 'cf', function() vim.lsp.buf.format { async = true } end, bufopts) - end, - sources = { - null_ls.builtins.diagnostics.trail_space.with { - disabled_filetypes = { "lua" } - }, - null_ls.builtins.diagnostics.shellcheck, - null_ls.builtins.code_actions.shellcheck, - null_ls.builtins.formatting.jq, - null_ls.builtins.code_actions.gitsigns, - null_ls.builtins.diagnostics.flake8, - null_ls.builtins.diagnostics.yamllint, - null_ls.builtins.formatting.yamlfmt, - null_ls.builtins.formatting.shfmt, - null_ls.builtins.formatting.shellharden, - null_ls.builtins.formatting.beautysh, - }, - } - end, - }, -} diff --git a/lua/plugin/nvim-cmp.lua b/lua/plugin/nvim-cmp.lua deleted file mode 100644 index 4f078f9..0000000 --- a/lua/plugin/nvim-cmp.lua +++ /dev/null @@ -1,196 +0,0 @@ -return { - - -- snippets - { - "L3MON4D3/LuaSnip", - lazy = true, - dependencies = { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - vim.api.nvim_set_hl(0, "PmenuSel", { fg = 'NONE', bg = '#141617' }) - vim.api.nvim_set_hl(0, "Pmenu", { fg = 'NONE', bg = '#1d2021' }) - vim.api.nvim_set_hl(0, "CmpItemMenu", { fg = 'NONE', bg = '#141617' }) - vim.api.nvim_set_hl(0, "CmpItemMenuDefault", { fg = 'NONE', bg = '#141617' }) - vim.api.nvim_set_hl(0, "CmpItemKindFunction", { fg = '#d3869b', bg = 'NONE', italic = true }) - vim.api.nvim_set_hl(0, "CmpItemKindSnippet", { fg = '#d8a657', bg = 'NONE', italic = true }) - vim.api.nvim_set_hl(0, "CmpItemKindText", { fg = '#ddc7a1', bg = 'NONE', italic = true }) - vim.api.nvim_set_hl(0, "CmpItemKindVariable", { fg = '#7daea3', bg = 'NONE', italic = true }) - end, - }, - }, - - -- completion - { - "hrsh7th/nvim-cmp", - version = false, - event = { - -- "InsertEnter", - -- "CmdlineEnter", - "BufWinEnter", - }, - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "saadparwaiz1/cmp_luasnip", - }, - opts = function() - -- Set up nvim-cmp with luasnip - local kind_icons = { - Text = "", - Method = "󰆧", - Function = "󰊕", - Constructor = "", - Field = "󰇽", - Variable = "󰂡", - Class = "󰠱", - Interface = "", - Module = "", - Property = "󰜢", - Unit = "", - Value = "󰎠", - Enum = "", - Keyword = "󰌋", - Snippet = "", - Color = "󰏘", - File = "󰈙", - Reference = "", - Folder = "󰉋", - EnumMember = "", - Constant = "󰏿", - Struct = "", - Event = "", - Operator = "󰆕", - TypeParameter = "󰅲" - } - - local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and - vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - local luasnip = require("luasnip") - local cmp = require("cmp") - - return { - formatting = { - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind - -- Source - vim_item.menu = ({ - -- buffer = "[Buffer]", - -- nvim_lsp = "[LSP]", - -- luasnip = "[LuaSnip]", - -- nvim_lua = "[Lua]", - -- latex_symbols = "[LaTeX]", - buffer = "", - nvim_lsp = "", - luasnip = "", - nvim_lua = "", - latex_symbols = "", - })[entry.source.name] - return vim_item - end - }, - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - -- require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. - end, - }, - -- completion = { - -- autocomplete = false, - -- }, - - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - -- [''] = cmp.mapping.complete(), - -- [''] = cmp.mapping.abort(), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.abort() - else - cmp.complete() - end - end), - [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() - -- they way you will only jump inside the snippet region - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - -- { name = 'vsnip' }, -- For vsnip users. - { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - -- { name = 'snippy' }, -- For snippy users. - { - name = 'buffer', - option = { - get_bufnrs = function() - return vim.api.nvim_list_bufs() - end - }, - }, - }, { - }), - -- Set configuration for specific filetype. - cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. - }, { - { name = 'buffer' }, - }) - }), - -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline({ '/', '?' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } - }), - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) - }), - } - end, - } -} diff --git a/lua/plugin/nvimtree.lua b/lua/plugin/nvimtree.lua new file mode 100644 index 0000000..e35d7b4 --- /dev/null +++ b/lua/plugin/nvimtree.lua @@ -0,0 +1,18 @@ +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/snippets.lua b/lua/plugin/snippets.lua new file mode 100644 index 0000000..273e250 --- /dev/null +++ b/lua/plugin/snippets.lua @@ -0,0 +1,20 @@ +return { + { + "L3MON4D3/LuaSnip", + lazy = true, + dependencies = { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + vim.api.nvim_set_hl(0, "PmenuSel", { fg = 'NONE', bg = '#272e33' }) + vim.api.nvim_set_hl(0, "Pmenu", { fg = 'NONE', bg = '#1e2326' }) + vim.api.nvim_set_hl(0, "CmpItemMenu", { fg = 'NONE', bg = '#272e33' }) + vim.api.nvim_set_hl(0, "CmpItemMenuDefault", { fg = 'NONE', bg = '#272e33' }) + vim.api.nvim_set_hl(0, "CmpItemKindFunction", { fg = '#d699b6', bg = 'NONE', italic = true }) + vim.api.nvim_set_hl(0, "CmpItemKindSnippet", { fg = '#dbbc7f', bg = 'NONE', italic = true }) + vim.api.nvim_set_hl(0, "CmpItemKindText", { fg = '#9da9a0', bg = 'NONE', italic = true }) + vim.api.nvim_set_hl(0, "CmpItemKindVariable", { fg = '#7fbbb3', bg = 'NONE', italic = true }) + end, + }, + } +} diff --git a/lua/plugin/surround.lua b/lua/plugin/surround.lua index 6bf538e..c54b65b 100644 --- a/lua/plugin/surround.lua +++ b/lua/plugin/surround.lua @@ -1,20 +1,24 @@ return { { - "echasnovski/mini.surround", + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features event = "VeryLazy", - opts = { - mappings = { - add = "sa", - delete = "sd", - find = "sf", - find_left = "sF", - highlight = "sh", - replace = "sr", - update_n_lines = "sn", - }, - }, - config = function(_, opts) - require("mini.surround").setup(opts) - end, + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end } } + +-- Old text Command New text +-- -------------------------------------------------------------------------------- +-- surround_words ysiw) (surround_words) +-- make strings ys$" "make strings" +-- [delete around me!] ds] delete around me! +-- remove HTML tags dst remove HTML tags +-- 'change quotes' cs'" "change quotes" +-- or tag types csth1

or tag types

+-- delete(function calls) dsf function calls + +-- :h nvim-surround.usage diff --git a/lua/plugin/telescope.lua b/lua/plugin/telescope.lua index 724261a..3f7a68c 100644 --- a/lua/plugin/telescope.lua +++ b/lua/plugin/telescope.lua @@ -4,6 +4,60 @@ return { 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" }, @@ -11,10 +65,10 @@ return { { "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 live_grep", desc = "Grep Content in Files" }, - { "fl", "Telescope grep_string", desc = "Grep currently hovered String" }, + { "/", "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 = "Find Git Files" }, + { "fk", "Telescope keymaps", desc = "List Keymaps" }, { "fr", "Telescope oldfiles", desc = "Find Recent Files" }, }, }, diff --git a/lua/plugin/todo-comments.lua b/lua/plugin/todo-comments.lua deleted file mode 100644 index 7e9149a..0000000 --- a/lua/plugin/todo-comments.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - { - "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - } - } -} diff --git a/lua/plugin/treesitter-context.lua b/lua/plugin/treesitter-context.lua index b1f1363..43d76d5 100644 --- a/lua/plugin/treesitter-context.lua +++ b/lua/plugin/treesitter-context.lua @@ -1,14 +1,14 @@ return { - { - "nvim-treesitter/nvim-treesitter-context", - event = "VeryLazy", - config = function () - require('treesitter-context').setup{ - enable = true, - max_lines = 0, - min_window_height = 0, - line_numbers = true, - } - end - } + { + "nvim-treesitter/nvim-treesitter-context", + event = "VeryLazy", + config = function() + require('treesitter-context').setup { + enable = true, + max_lines = 0, + min_window_height = 0, + line_numbers = true, + } + end + } } diff --git a/lua/plugin/treesitter-textobjects.lua b/lua/plugin/treesitter-textobjects.lua new file mode 100644 index 0000000..c43422f --- /dev/null +++ b/lua/plugin/treesitter-textobjects.lua @@ -0,0 +1,68 @@ +return { + { + "nvim-treesitter/nvim-treesitter-textobjects", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + opts = { + textobjects = { + select = { + enable = true, + + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + + keymaps = { + -- 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", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["ar"] = "@return.outer", + ["ir"] = "@return.inner", + ["ia"] = "@assignment.rhs", + ["aa"] = "@assignment.inner", + ["i?"] = "@conditional.inner", + ["a?"] = "@conditional.outer", + ["in"] = "@number.inner", + ["iC"] = "@class.inner", + ["aC"] = "@class.outer", + ["ig"] = "@call.inner", + ["ag"] = "@call.outer", + + -- You can also use captures from other query groups like `locals.scm` + ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" }, + }, + -- You can choose the select mode (default is charwise 'v') + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * method: eg 'v' or 'o' + -- and should return the mode ('v', 'V', or '') or a table + -- mapping query_strings to modes. + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + }, + -- If you set this to `true` (default is `false`) then any textobject is + -- extended to include preceding or succeeding whitespace. Succeeding + -- whitespace has priority in order to act similarly to eg the built-in + -- `ap`. + -- + -- Can also be a function which gets passed a table with the keys + -- * query_string: eg '@function.inner' + -- * selection_mode: eg 'v' + -- and should return true or false + include_surrounding_whitespace = false, + }, + }, + + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + } +} diff --git a/lua/plugin/trouble.lua b/lua/plugin/trouble.lua deleted file mode 100644 index 25ef1bd..0000000 --- a/lua/plugin/trouble.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = {}, - config = function() - vim.keymap.set("n", "xx", function() require("trouble").toggle() end) - vim.keymap.set("n", "xw", function() require("trouble").toggle("workspace_diagnostics") end) - vim.keymap.set("n", "xd", function() require("trouble").toggle("document_diagnostics") end) - vim.keymap.set("n", "xq", function() require("trouble").toggle("quickfix") end) - vim.keymap.set("n", "xl", function() require("trouble").toggle("loclist") end) - vim.keymap.set("n", "gr", function() require("trouble").open("lsp_references") end) - end -} diff --git a/lua/plugin/undotree.lua b/lua/plugin/undotree.lua index b7a7346..418a3fe 100644 --- a/lua/plugin/undotree.lua +++ b/lua/plugin/undotree.lua @@ -1,14 +1,13 @@ return { - { - "mbbill/undotree", - keys = { - { "u", "UndotreeToggle", desc = "toggle undotree" }, - }, - config = function() - vim.g.undotree_WindowLayout = 4 - vim.g.undotree_SplitWidth = 40 - vim.g.undotree_SetFocusWhenToggle = 1 - end - } + { + "mbbill/undotree", + keys = { + { "u", "UndotreeToggle", desc = "toggle undotree" }, + }, + config = function() + vim.g.undotree_WindowLayout = 4 + vim.g.undotree_SplitWidth = 40 + vim.g.undotree_SetFocusWhenToggle = 1 + end + } } - diff --git a/lua/plugin/zen.lua b/lua/plugin/zen.lua new file mode 100644 index 0000000..67281a8 --- /dev/null +++ b/lua/plugin/zen.lua @@ -0,0 +1,20 @@ +return { + { + "folke/zen-mode.nvim", + opts = { + window = { + backdrop = 1, + width = 120, + }, + plugins = { + options = { + enabled = true, + showcmd = true, + laststatus = 3, + }, + gitsigns = { enabled = false } + }, + vim.keymap.set("n", "zz", function() require("zen-mode").toggle() end), + }, + } +}