From b49026c12e7cb9dcf32f1ed03082a8c2ce93e1de Mon Sep 17 00:00:00 2001 From: Laily Date: Tue, 20 Feb 2024 21:19:43 +0800 Subject: [PATCH] feat: new config --- nvim/ftplugin/css.vim | 1 - nvim/ftplugin/go.lua | 1 - nvim/ftplugin/html.vim | 1 - nvim/ftplugin/javascript.vim | 1 - nvim/ftplugin/javascriptreact.vim | 1 - nvim/ftplugin/js.lua | 1 - nvim/ftplugin/lua.lua | 3 - nvim/ftplugin/sh.lua | 2 - nvim/ftplugin/ts.lua | 1 - nvim/ftplugin/typescript.lua | 2 - nvim/ftplugin/typescriptreact.lua | 2 - nvim/ftplugin/yaml.vim | 1 - nvim/init.lua | 56 ++--- nvim/lazy-lock.json | 56 +++++ nvim/lazyvim.json | 9 + nvim/lua/autocommands.lua | 76 ------- nvim/lua/config/autocmds.lua | 14 ++ nvim/lua/config/keymaps.lua | 256 ++++++++++++++++++++++ nvim/lua/config/lazy.lua | 46 ++++ nvim/lua/config/options.lua | 56 +++++ nvim/lua/keymappings.lua | 81 ------- nvim/lua/{lang => langgg}/bash.lua | 0 nvim/lua/{lang => langgg}/css-ls.lua | 0 nvim/lua/{lang => langgg}/docker-ls.lua | 0 nvim/lua/{lang => langgg}/emmet-ls.lua | 0 nvim/lua/{lang => langgg}/go.lua | 0 nvim/lua/{lang => langgg}/html-ls.lua | 0 nvim/lua/{lang => langgg}/js-ts.lua | 0 nvim/lua/{lang => langgg}/json-ls.lua | 0 nvim/lua/{lang => langgg}/latex-ls.lua | 0 nvim/lua/{lang => langgg}/lua.lua | 0 nvim/lua/{lang => langgg}/python.lua | 0 nvim/lua/{lang => langgg}/rust-ls.lua | 0 nvim/lua/{lang => langgg}/yaml-ls.lua | 0 nvim/lua/{plugins.lua => plugins.bak.lua} | 0 nvim/lua/plugins/editor.lua | 225 +++++++++++++++++++ nvim/lua/plugins/lsp.lua | 157 +++++++++++++ nvim/lua/plugins/treesitter.lua | 67 ++++++ nvim/lua/utils/debug.lua | 158 +++++++++++++ nvim/utils/bin/install-latest-neovim | 9 - nvim/utils/bin/java-linux-ls | 28 --- nvim/utils/bin/java-mac-ls | 29 --- nvim/utils/bin/nv | 2 - nvim/vimscript/functions.vim | 73 ------ nvim/vimscript/lv-vscode/init.vim | 84 ------- 45 files changed, 1072 insertions(+), 427 deletions(-) delete mode 100644 nvim/ftplugin/css.vim delete mode 100644 nvim/ftplugin/go.lua delete mode 100644 nvim/ftplugin/html.vim delete mode 100644 nvim/ftplugin/javascript.vim delete mode 100644 nvim/ftplugin/javascriptreact.vim delete mode 100644 nvim/ftplugin/js.lua delete mode 100644 nvim/ftplugin/lua.lua delete mode 100644 nvim/ftplugin/sh.lua delete mode 100644 nvim/ftplugin/ts.lua delete mode 100644 nvim/ftplugin/typescript.lua delete mode 100644 nvim/ftplugin/typescriptreact.lua delete mode 100644 nvim/ftplugin/yaml.vim create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lazyvim.json delete mode 100644 nvim/lua/autocommands.lua create mode 100644 nvim/lua/config/autocmds.lua create mode 100644 nvim/lua/config/keymaps.lua create mode 100644 nvim/lua/config/lazy.lua create mode 100644 nvim/lua/config/options.lua delete mode 100644 nvim/lua/keymappings.lua rename nvim/lua/{lang => langgg}/bash.lua (100%) rename nvim/lua/{lang => langgg}/css-ls.lua (100%) rename nvim/lua/{lang => langgg}/docker-ls.lua (100%) rename nvim/lua/{lang => langgg}/emmet-ls.lua (100%) rename nvim/lua/{lang => langgg}/go.lua (100%) rename nvim/lua/{lang => langgg}/html-ls.lua (100%) rename nvim/lua/{lang => langgg}/js-ts.lua (100%) rename nvim/lua/{lang => langgg}/json-ls.lua (100%) rename nvim/lua/{lang => langgg}/latex-ls.lua (100%) rename nvim/lua/{lang => langgg}/lua.lua (100%) rename nvim/lua/{lang => langgg}/python.lua (100%) rename nvim/lua/{lang => langgg}/rust-ls.lua (100%) rename nvim/lua/{lang => langgg}/yaml-ls.lua (100%) rename nvim/lua/{plugins.lua => plugins.bak.lua} (100%) create mode 100644 nvim/lua/plugins/editor.lua create mode 100644 nvim/lua/plugins/lsp.lua create mode 100644 nvim/lua/plugins/treesitter.lua create mode 100644 nvim/lua/utils/debug.lua delete mode 100755 nvim/utils/bin/install-latest-neovim delete mode 100755 nvim/utils/bin/java-linux-ls delete mode 100755 nvim/utils/bin/java-mac-ls delete mode 100755 nvim/utils/bin/nv delete mode 100644 nvim/vimscript/functions.vim delete mode 100644 nvim/vimscript/lv-vscode/init.vim diff --git a/nvim/ftplugin/css.vim b/nvim/ftplugin/css.vim deleted file mode 100644 index eadd3f5..0000000 --- a/nvim/ftplugin/css.vim +++ /dev/null @@ -1 +0,0 @@ -setl ts=2 sw=2 diff --git a/nvim/ftplugin/go.lua b/nvim/ftplugin/go.lua deleted file mode 100644 index 16e82c4..0000000 --- a/nvim/ftplugin/go.lua +++ /dev/null @@ -1 +0,0 @@ -require('lang.go') diff --git a/nvim/ftplugin/html.vim b/nvim/ftplugin/html.vim deleted file mode 100644 index eadd3f5..0000000 --- a/nvim/ftplugin/html.vim +++ /dev/null @@ -1 +0,0 @@ -setl ts=2 sw=2 diff --git a/nvim/ftplugin/javascript.vim b/nvim/ftplugin/javascript.vim deleted file mode 100644 index eadd3f5..0000000 --- a/nvim/ftplugin/javascript.vim +++ /dev/null @@ -1 +0,0 @@ -setl ts=2 sw=2 diff --git a/nvim/ftplugin/javascriptreact.vim b/nvim/ftplugin/javascriptreact.vim deleted file mode 100644 index 11332b5..0000000 --- a/nvim/ftplugin/javascriptreact.vim +++ /dev/null @@ -1 +0,0 @@ -setl commentstring={/*%s*/} ts=2 sw=2 diff --git a/nvim/ftplugin/js.lua b/nvim/ftplugin/js.lua deleted file mode 100644 index 3d2a993..0000000 --- a/nvim/ftplugin/js.lua +++ /dev/null @@ -1 +0,0 @@ -require('lang.js-ts') diff --git a/nvim/ftplugin/lua.lua b/nvim/ftplugin/lua.lua deleted file mode 100644 index d1495dd..0000000 --- a/nvim/ftplugin/lua.lua +++ /dev/null @@ -1,3 +0,0 @@ - vim.cmd('set ts=2') -- Insert 2 spaces for a tab - vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation -require('lang/lua') diff --git a/nvim/ftplugin/sh.lua b/nvim/ftplugin/sh.lua deleted file mode 100644 index 5b6328b..0000000 --- a/nvim/ftplugin/sh.lua +++ /dev/null @@ -1,2 +0,0 @@ -require('lang.bash') - diff --git a/nvim/ftplugin/ts.lua b/nvim/ftplugin/ts.lua deleted file mode 100644 index 3d2a993..0000000 --- a/nvim/ftplugin/ts.lua +++ /dev/null @@ -1 +0,0 @@ -require('lang.js-ts') diff --git a/nvim/ftplugin/typescript.lua b/nvim/ftplugin/typescript.lua deleted file mode 100644 index 2634b42..0000000 --- a/nvim/ftplugin/typescript.lua +++ /dev/null @@ -1,2 +0,0 @@ -vim.cmd('set ts=2') -- Insert 2 spaces for a tab -vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation diff --git a/nvim/ftplugin/typescriptreact.lua b/nvim/ftplugin/typescriptreact.lua deleted file mode 100644 index 2634b42..0000000 --- a/nvim/ftplugin/typescriptreact.lua +++ /dev/null @@ -1,2 +0,0 @@ -vim.cmd('set ts=2') -- Insert 2 spaces for a tab -vim.cmd('set sw=2') -- Change the number of space characters inserted for indentation diff --git a/nvim/ftplugin/yaml.vim b/nvim/ftplugin/yaml.vim deleted file mode 100644 index dcb1b03..0000000 --- a/nvim/ftplugin/yaml.vim +++ /dev/null @@ -1 +0,0 @@ -setl ts=2 sw=2 ts=2 ai et diff --git a/nvim/init.lua b/nvim/init.lua index 22cec6b..b0be348 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,33 +1,33 @@ -CONFIG_PATH = vim.fn.stdpath('config') -DATA_PATH = vim.fn.stdpath('data') -CACHE_PATH = vim.fn.stdpath('cache') -P = vim.inspect +if vim.loader then + vim.loader.enable() +end -require('lv-globals') -vim.cmd('luafile '..CONFIG_PATH..'/settings.lua') -require('settings') -require('plugins') -require('utils') -require('pluginconfig') -require('autocommands') -require('keymappings') -require('colorscheme') -- This plugin must be required somewhere after nvimtree. Placing it before will break navigation keymappings +_G.dd = function(...) + require("util.debug").dump(...) +end +vim.print = _G.dd --- TODO is there a way to do this without vimscript -vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim') +require("config.lazy") --- LSP -require('lsp') ---[[ -require('lsp.css-ls') -require('lsp.docker-ls') -require('lsp.emmet-ls') -require('lsp.html-ls') -require('lsp.json-ls') -require('lsp.latex-ls') -require('lsp.python-ls') -require('lsp.rust-ls') -require('lsp.yaml-ls') -]] +-- CONFIG_PATH = vim.fn.stdpath('config') +-- DATA_PATH = vim.fn.stdpath('data') +-- CACHE_PATH = vim.fn.stdpath('cache') +-- P = vim.inspect + +-- require('lv-globals') +-- vim.cmd('luafile '..CONFIG_PATH..'/settings.lua') +-- require('settings') +-- require('plugins') +-- require('utils') +-- require('pluginconfig') +-- require('autocommands') +-- require('keymappings') +-- require('colorscheme') -- This plugin must be required somewhere after nvimtree. Placing it before will break navigation keymappings + +-- -- TODO is there a way to do this without vimscript +-- vim.cmd('source '..CONFIG_PATH..'/vimscript/functions.vim') + +-- -- LSP +-- require('lsp') diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..b515815 --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,56 @@ +{ + "LazyVim": { "branch": "main", "commit": "a50f92f7550fb6e9f21c0852e6cb190e6fcd50f5" }, + "LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" }, + "bufferline.nvim": { "branch": "main", "commit": "b15c6daf5a64426c69732b31a951f4e438cb6590" }, + "catppuccin": { "branch": "main", "commit": "9703f227bfab20d04bcee62d2f08f1795723b4ae" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "00f50d4bb17b849bac62cb1b75368333c0a80c96" }, + "dashboard-nvim": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" }, + "dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" }, + "flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, + "friendly-snippets": { "branch": "main", "commit": "dbd45e9ba76d535e4cba88afa1b7aa43bb765336" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, + "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7897c45e8f0f7fefe3b3ee00d8e89dc67a113e25" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "mini.ai": { "branch": "main", "commit": "ee9446a17c160aba6a04ff22097389c41872c878" }, + "mini.bufremove": { "branch": "main", "commit": "931a3bb514147d9e812767275c4beba6b779b1d3" }, + "mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, + "mini.indentscope": { "branch": "main", "commit": "cf07f19e718ebb0bcc5b00999083ce11c37b8d40" }, + "mini.pairs": { "branch": "main", "commit": "04f58f2545ed80ac3b52dd4826e93f33e15b2af6" }, + "mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "f3941c57ec85d7bdb44fa53fd858fd80f159018f" }, + "neoconf.nvim": { "branch": "main", "commit": "4ef6c6c5882e7e16209173fb8c47414202843384" }, + "neodev.nvim": { "branch": "main", "commit": "bbe17de89345ce40725e721d347c596dc4a02b32" }, + "noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" }, + "nui.nvim": { "branch": "main", "commit": "c3c7fd618dcb5a89e443a2e1033e7d11fdb0596b" }, + "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-lint": { "branch": "master", "commit": "31be66c27214174a28fc092ffcf4bb3e8f6cfd43" }, + "nvim-lspconfig": { "branch": "master", "commit": "1699ce10c3aaf861cfa0c1303fcd19d2ed93e7ad" }, + "nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" }, + "nvim-spectre": { "branch": "master", "commit": "3712ff0cdf4f9f877d9ca708d835a877d9a0abaf" }, + "nvim-tree.lua": { "branch": "master", "commit": "030defdb6522f5f716d8201d20ca1a2baa57ca66" }, + "nvim-treesitter": { "branch": "master", "commit": "d87074a06b3dfef0f8ed6bbf5953fca96abd312a" }, + "nvim-treesitter-context": { "branch": "master", "commit": "fbeff2a60d073f73fef23a2c707e4f12c9c53359" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "7f00d94543f1fd37cab2afa2e9a6cd54e1c6b9ef" }, + "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, + "nvim-web-devicons": { "branch": "master", "commit": "14ac5887110b06b89a96881d534230dac3ed134d" }, + "persistence.nvim": { "branch": "main", "commit": "4982499c1636eac254b72923ab826ee7827b3084" }, + "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "48ffb8de688a22942940f50411d5928631368848" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "master", "commit": "b744cf59752aaa01561afb4223006de26f3836fd" }, + "todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" }, + "tokyonight.nvim": { "branch": "main", "commit": "610179f7f12db3d08540b6cc61434db2eaecbcff" }, + "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, + "vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" }, + "vim-startuptime": { "branch": "master", "commit": "308b0088a864c4711a96e45b6734cf9294074f65" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } +} \ No newline at end of file diff --git a/nvim/lazyvim.json b/nvim/lazyvim.json new file mode 100644 index 0000000..ff6a139 --- /dev/null +++ b/nvim/lazyvim.json @@ -0,0 +1,9 @@ +{ + "extras": [ + + ], + "news": { + "NEWS.md": "2123" + }, + "version": 2 +} \ No newline at end of file diff --git a/nvim/lua/autocommands.lua b/nvim/lua/autocommands.lua deleted file mode 100644 index afdfe55..0000000 --- a/nvim/lua/autocommands.lua +++ /dev/null @@ -1,76 +0,0 @@ -local utils = require('utils') - -local auto_formatters = { } - -local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.format({async=false})'} -if O.python.autoformat then table.insert(auto_formatters, python_autoformat) end - -local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.format({async=false})'} -local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.format({async=false})'} -local typescript_autoformat = {'BufWritePre', '*.ts', 'lua vim.lsp.buf.format({async=false})'} -local typescriptreact_autoformat = {'BufWritePre', '*.tsx', 'lua vim.lsp.buf.format({async=false})'} -if O.tsserver.autoformat then - table.insert(auto_formatters, javascript_autoformat) - table.insert(auto_formatters, javascriptreact_autoformat) - table.insert(auto_formatters, typescript_autoformat) - table.insert(auto_formatters, typescriptreact_autoformat) -end - -local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.format({async=false})'} -if O.lua.autoformat then table.insert(auto_formatters, lua_format) end - -local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.format({async=false})'} -if O.json.autoformat then table.insert(auto_formatters, json_format) end - -local ruby_format = {'BufWritePre', '*.rb', 'lua vim.lsp.buf.format({async=false})'} -if O.ruby.autoformat then table.insert(auto_formatters, ruby_format) end - -local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.format({async=false})'} -if O.go.autoformat then table.insert(auto_formatters, go_format) end - -utils.define_augroups({ - _general_settings = { - {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'}, - {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, - {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, - {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, - {'VimLeavePre', '*', 'set title set titleold='}, - {'FileType', 'qf', 'set nobuflisted'}, - - -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'}, - -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'}, - }, - _java = { - {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, - {'FileType', 'java', 'nnoremap ca lua require(\'jdtls\').code_action()'} - }, - _go = { - -- Go generally requires Tabs instead of spaces. - {'FileType', 'go', 'setlocal tabstop=4'}, - {'FileType', 'go', 'setlocal shiftwidth=4'}, - {'FileType', 'go', 'setlocal softtabstop=4'}, - {'FileType', 'go', 'setlocal noexpandtab'}, - }, - _dashboard = { - -- seems to be nobuflisted that makes my stuff disapear will do more testing - { - 'FileType', 'dashboard', - 'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= ' - }, {'FileType', 'dashboard', 'set showtabline=0 | autocmd BufLeave set showtabline=2'} - }, - _markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}}, - _solidity = { - {'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'}, - {'BufNewFile', '*.sol', 'setlocal filetype=solidity'} - }, - _gemini = { - {'BufWinEnter', '.gmi', 'setlocal filetype=markdown'}, {'BufRead', '*.gmi', 'setlocal filetype=markdown'}, - {'BufNewFile', '*.gmi', 'setlocal filetype=markdown'} - }, - _buffer_bindings = { - {'FileType', 'dashboard', 'nnoremap q :q'}, - {'FileType', 'lspinfo', 'nnoremap q :q'}, - {'FileType', 'floaterm', 'nnoremap q :q'}, - }, - _auto_formatters = auto_formatters -}) diff --git a/nvim/lua/config/autocmds.lua b/nvim/lua/config/autocmds.lua new file mode 100644 index 0000000..a9d3f98 --- /dev/null +++ b/nvim/lua/config/autocmds.lua @@ -0,0 +1,14 @@ +-- Turn off paste mode when leaving insert +vim.api.nvim_create_autocmd("InsertLeave", { + pattern = "*", + command = "set nopaste", +}) + +-- Disable the concealing in some file formats +-- The default conceallevel is 3 in LazyVim +vim.api.nvim_create_autocmd("FileType", { + pattern = { "json", "jsonc", "markdown" }, + callback = function() + vim.opt.conceallevel = 0 + end, +}) diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..1bad0fe --- /dev/null +++ b/nvim/lua/config/keymaps.lua @@ -0,0 +1,256 @@ + +local opts = { + mode = "n", -- NORMAL mode + prefix = "", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = false -- use `nowait` when creating keymaps +} + + + + + +local mappings = { + -- ["/"] = "Comment", + -- ["c"] = "Close Buffer", + ["e"] = "Explorer", + -- ["f"] = "Find File", + ["h"] = "No Highlight", + a = { + name = "+Action", + a = { "@:", "execute last command again" } + }, + b = { + name = "+Buffer", + n = { "BufferNext", "next buffer" }, + p = { "BufferPrevious", "previous buffer" }, + q = { "q", "quit" }, + s = { "w", "save" }, + r = { "e!", "reload" }, + d = { "BufferClose", "close buffer" }, + z = { "CommentToggle", "toggle comment" }, + }, + D = { + name = "+Diagnostics", + t = { "TroubleToggle", "trouble" }, + w = { "TroubleToggle lsp_workspace_diagnostics", "workspace" }, + d = { "TroubleToggle lsp_document_diagnostics", "document" }, + q = { "TroubleToggle quickfix", "quickfix" }, + l = { "TroubleToggle loclist", "loclist" }, + r = { "TroubleToggle lsp_references", "references" }, + }, + d = { + name = "+Debug", + -- b = {"DebugToggleBreakpoint", "Toggle Breakpoint"}, + -- c = {"DebugContinue", "Continue"}, + -- i = {"DebugStepInto", "Step Into"}, + -- o = {"DebugStepOver", "Step Over"}, + -- r = {"DebugToggleRepl", "Toggle Repl"}, + -- s = {"DebugStart", "Start"} + d = { "lua vim.lsp.diagnostic.show_line_diagnostics()", "show diagnostics" }, + + c = { "lua require'dap'.continue()", "continue" }, + b = { ':lua require"dap".toggle_breakpoint()', "Toggle Breadpoint" }, + j = { ':lua require"dap".step_over()', "step over" }, + k = { ':lua require"dap".step_out()', "step out" }, + l = { ':lua require"dap".step_into()', "step into" }, + --', ':lua require"dap".continue()') + u = { ':lua require"dap".up()', "up" }, + -- d = {':lua require"dap".down()', "down"}, + _ = { ':lua require"dap".disconnect();require"dap".stop();require"dap".run_last()', "disconnect" }, + --r = {':lua require"dap".repl.open({}, "vsplit")l', "repl open"}, + i = { ':lua require"dap.ui.variables".visual_hover()', "visual_hover" }, + --? = {':lua require"dap.ui.variables".scopes()',"scopes"}, + -- e = {':lua require"dap".set_exception_breakpoints({"all"})',"esception bp"}, + -- a = {':lua require"debugHelper".attach()',"attach"}, + -- A = {':lua require"debugHelper".attachToRemote()',"attach to remote"}, + s = { ':lua local widgets=require"dap.ui.widgets";widgets.centered_float(widgets.scopes)', "centered_float" }, + }, + f = { + name = "+File", + m = { "lua require'utils'.open_md()", "open a markdown file in vscode" }, + s = { "w", "save file" }, + t = { "NvimTreeToggle", "toggle nvim tree" }, + r = { "RnvimrToggle", "toggle rnvimr" }, + y = { "lua require'utils'.yank_filepath()", "copy the file path" }, + d = { "lua require'utils'.yank_file_dir()", "copy the file path" }, + l = { "NvimTreeFindFile", "find file" }, + -- T = {"let @+ = 'go test -v -run='+expand('')", "get current word in go test"}, + }, + g = { + name = "+Git", + m = {"Gvdiff master:%", "Diff with master"}, + j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, + k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, + l = { "lua require 'gitsigns'.blame_line()", "Blame" }, + p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, + r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, + R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, + s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, + S = { "lua require 'gitsigns'.stage_buffer()", "Stage Buffer" }, + u = { + "lua require 'gitsigns'.undo_stage_hunk()", + "Undo Stage Hunk", + }, + o = { "Telescope git_status", "Open changed file" }, + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope git_commits", "Checkout commit" }, + C = { + "Telescope git_bcommits", + "Checkout commit(for current file)", + }, + d = { + "Gitsigns diffthis HEAD", + "Git Diff", + }, + }, + l = { + name = "+Language", + a = { "Lspsaga code_action", "Code Action" }, + A = { "Lspsaga range_code_action", "Selected Action" }, + d = { "Telescope lsp_document_diagnostics", "Document Diagnostics" }, + D = { "Telescope lsp_workspace_diagnostics", "Workspace Diagnostics" }, + f = { "LspFormatting", "Format" }, + F = { "Lspsaga lsp_finder", "LSP Finder" }, + -- i = {"Telescope lsp_implementations", "implement"}, + i = { "lua vim.lsp.buf.implementation()", "implement" }, + l = { "lua vim.lsp.buf.hover()", "hover" }, + L = { "Lspsaga show_line_diagnostics", "Line Diagnostics" }, + k = { ": LspRestart", "restart lsp server" }, + n = { "lua vim.lsp.diagnostic.goto_next()", "next diagnostic" }, + o = { ": SymbolsOutline", "symbols outline" }, + p = { "lua vim.lsp.diagnostic.goto_prev()", "prev diagnostic" }, + P = { "Lspsaga preview_definition", "Preview Definition" }, + q = { "Telescope quickfix", "Quickfix" }, + r = { "lua vim.lsp.buf.references()", "references" }, + R = { "Lspsaga rename", "Rename" }, + t = { "LspTypeDefinition", "Type Definition" }, + x = { "cclose", "Close Quickfix" }, + s = { "Telescope lsp_document_symbols", "Document Symbols" }, + S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols" }, + z = { "LspInfo", "Info" }, + [","] = { "LspInstallInfo", "LSP servers" } + }, + p = { + name = "Packer", + c = { "PackerCompile", "Compile" }, + i = { "PackerInstall", "Install" }, + s = { "PackerSync", "Sync" }, + S = { "PackerStatus", "Status" }, + u = { "PackerUpdate", "Update" }, + }, + q = { + name = "quit", + q = { "qall", "quit" }, + }, + s = { + name = "+Search", + b = { "Telescope git_branches", "Checkout branch" }, + -- c = {"Telescope colorscheme", "Colorscheme"}, + c = { ":nohl", "no highlight" }, + d = { "Telescope lsp_document_diagnostics", "Document Diagnostics" }, + D = { "Telescope lsp_workspace_diagnostics", "Workspace Diagnostics" }, + f = { "Fzflua files", "Find File" }, + m = { "Telescope marks", "Marks" }, + M = { "Telescope man_pages", "Man Pages" }, + r = { "FzfLua oldfiles", "Open Recent File" }, + R = { "Telescope registers", "Registers" }, + t = { "FzfLua live_grep", "Text" }, + ["#"] = { "FzfLua grep_cword", "Search word under cursor" }, + }, + S = { + name = "+Session", + s = { "SessionSave", "Save Session" }, + l = { "SessionLoad", "Load Session" }, + }, + t = { + name = "+Test", + a = { "TestSuite -v -cover", "TestSuite" }, + t = { "lua require('neotest').run.run() ", "TestNearest" }, + f = { 'lua require("neotest").run.run(vim.fn.expand("%"))', "TestFile" }, + c = { "GoCover", "go coverage" }, + C = { "GoCoverClear", "go coverage clear" }, + b = { "lua require'dap'.toggle_breakpoint()", "set break point" }, + r = { "lua require'dap'.continue()", "continue" }, + }, + + -- extras + z = { + name = "+Zen", + s = { "TZBottom", "toggle status line" }, + t = { "TZTop", "toggle tab bar" }, + z = { "TZAtaraxis", "toggle zen" }, + } +} + +local wk = require("which-key") +wk.register(mappings, opts) + + +local keymap = vim.keymap +local opts = { noremap = true, silent = true } + +-- no hl +keymap.set('n', 'h', ':set hlsearch!', { noremap = true, silent = true }) + +-- explorer +keymap.set('n', 'e', ':NvimTreeToggle', { noremap = true, silent = true }) + +-- telescope +-- keymap.set('n', '', ":lua require'telescope.builtin'.find_files()", {noremap = true, silent = true}) +keymap.set('n', '', ":FzfLua files", { noremap = true, silent = true }) + +-- dashboard +keymap.set('n', ';', ':Dashboard', { noremap = true, silent = true }) + +-- Comments +keymap.set("n", "b/", ":CommentToggle", { noremap = true, silent = true }) +keymap.set("v", "b/", ":CommentToggle", { noremap = true, silent = true }) + +-- close buffer +keymap.set("n", "c", ":BufferClose", { noremap = true, silent = true }) + +keymap.set('n', '-', ':RnvimrToggle', opts ) + +-- better window movement +keymap.set('n', '', 'h', { silent = true }) +keymap.set('n', '', 'j', { silent = true }) +keymap.set('n', '', 'k', { silent = true }) +keymap.set('n', '', 'l', { silent = true }) + +-- better edit +keymap.set('n', 'Y', 'y$', {}) + +-- resize with arrows +keymap.set('n', '', ':resize -2', { silent = true }) +keymap.set('n', '', ':resize +2', { silent = true }) +keymap.set('n', '', ':vertical resize -2', { silent = true }) +keymap.set('n', '', ':vertical resize +2', { silent = true }) + +-- better indenting +keymap.set('v', '<', '', '>gv', { noremap = true, silent = true }) + +-- I hate escape +keymap.set('i', 'jk', '', { noremap = true, silent = true }) +keymap.set('i', 'kj', '', { noremap = true, silent = true }) +keymap.set('i', 'jj', '', { noremap = true, silent = true }) + +-- Tab switch buffer +keymap.set('n', '', ':bnext', { noremap = true, silent = true }) +keymap.set('n', '', ':bprevious', { noremap = true, silent = true }) + +-- Move selected line / block of text in visual mode +keymap.set('x', 'K', ':move \'<-2gv-gv', { noremap = true, silent = true }) +keymap.set('x', 'J', ':move \'>+1gv-gv', { noremap = true, silent = true }) + +keymap.set('', '', ':call QuickFixToggle()', { noremap = true, silent = true }) + +-- -- Better nav for omnicomplete +-- vim.cmd('inoremap (\"\\\")') +-- vim.cmd('inoremap (\"\\\")') + +-- vim.cmd('vnoremap p "0p') +-- vim.cmd('vnoremap P "0P') diff --git a/nvim/lua/config/lazy.lua b/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..56d3949 --- /dev/null +++ b/nvim/lua/config/lazy.lua @@ -0,0 +1,46 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + -- bootstrap lazy.nvim + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +require("lazy").setup({ + spec = { + -- add LazyVim and import its plugins + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + -- import any extras modules here + -- { import = "lazyvim.plugins.extras.lang.typescript" }, + -- { import = "lazyvim.plugins.extras.lang.json" }, + -- { import = "lazyvim.plugins.extras.ui.mini-animate" }, + -- import/override with your plugins + { import = "plugins" }, + }, + defaults = { + -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. + -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + lazy = false, + -- It's recommended to leave version=false for now, since a lot the plugin that support versioning, + -- have outdated releases, which may break your Neovim install. + version = false, -- always use the latest git commit + -- version = "*", -- try installing the latest stable version for plugins that support semver + }, + install = { colorscheme = { "tokyonight", "habamax" } }, + checker = { enabled = true }, -- automatically check for plugin updates + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) \ No newline at end of file diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua new file mode 100644 index 0000000..9c919ed --- /dev/null +++ b/nvim/lua/config/options.lua @@ -0,0 +1,56 @@ +vim.cmd('set iskeyword+=-') -- treat dash separated words as a word text object" +vim.cmd('set shortmess+=c') -- Don't pass messages to |ins-completion-menu|. +vim.cmd('set inccommand=split') -- Make substitution work in realtime +vim.o.hidden = true -- Required to keep multiple buffers open multiple buffers +vim.o.title = true +TERMINAL = vim.fn.expand('$TERMINAL') +vim.cmd('let &titleold="'..TERMINAL..'"') +vim.o.titlestring="%<%F%=%l/%L - nvim" +vim.wo.wrap = true -- Display long lines as just one line +vim.cmd('set whichwrap+=<,>,[,],h,l') -- move to next line with theses keys +vim.cmd('syntax on') -- syntax highlighting +vim.o.pumheight = 10 -- Makes popup menu smaller +vim.o.fileencoding = "utf-8" -- The encoding written to file +vim.o.cmdheight = 2 -- More space for displaying messages +vim.cmd('set colorcolumn=99999') -- fix indentline for now +vim.o.mouse = "a" -- Enable your mouse +vim.o.splitbelow = true -- Horizontal splits will automatically be below +vim.o.termguicolors = true -- set term gui colors most terminals support this +vim.o.splitright = true -- Vertical splits will automatically be to the right +-- vim.o.t_Co = "256" -- Support 256 colors +vim.o.conceallevel = 0 -- So that I can see `` in markdown files +-- vim.cmd('set ts=4') -- Insert 2 spaces for a tab +-- vim.cmd('set sw=4') -- Change the number of space characters inserted for indentation +-- vim.cmd('set expandtab') -- Converts tabs to spaces +vim.bo.smartindent = true -- Makes indenting smart +vim.wo.number = true -- set numbered lines +vim.wo.relativenumber = true -- set relative number +vim.wo.cursorline = true -- Enable highlighting of the current line +vim.o.showtabline = 2 -- Always show tabs +vim.o.showmode = false -- We don't need to see things like -- INSERT -- anymore +vim.o.backup = false -- This is recommended by coc +vim.o.writebackup = false -- This is recommended by coc +vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time +vim.o.updatetime = 300 -- Faster completion +vim.o.timeoutlen = 100 -- By default timeoutlen is 1000 ms +vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else +vim.cmd('filetype plugin on') -- filetype detection +-- vim.o.guifont = "JetBrainsMono\\ Nerd\\ Font\\ Mono:h18" +-- vim.o.guifont = "Hack\\ Nerd\\ Font\\ Mono" +-- vim.o.guifont = "SauceCodePro Nerd Font:h17" +vim.o.guifont = "FiraCode Nerd Font:h17" + +-- vim.o.guifont = "JetBrains\\ Mono\\ Regular\\ Nerd\\ Font\\ Complete" +vim.g.vim_markdown_folding_disabled = 1 + +vim.g.vimspector_enable_mappings = 'HUMAN' +vim.g['test#go#rspec#options'] = { nearest= '--v', suite= '--v' } + +-- git blame +vim.cmd('highlight default link gitblame SpecialComment') +vim.g.gitblame_enabled = 0 + +-- last position jump +vim.cmd([[ +autocmd BufReadPost * if line("'\"") >= 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif +]]) diff --git a/nvim/lua/keymappings.lua b/nvim/lua/keymappings.lua deleted file mode 100644 index cf71e18..0000000 --- a/nvim/lua/keymappings.lua +++ /dev/null @@ -1,81 +0,0 @@ -vim.api.nvim_set_keymap('n', '-', ':RnvimrToggle', { noremap = true, silent = true }) - --- better window movement -vim.api.nvim_set_keymap('n', '', 'h', { silent = true }) -vim.api.nvim_set_keymap('n', '', 'j', { silent = true }) -vim.api.nvim_set_keymap('n', '', 'k', { silent = true }) -vim.api.nvim_set_keymap('n', '', 'l', { silent = true }) - --- better edit -vim.api.nvim_set_keymap('n', 'Y', 'y$', {}) - --- TODO fix this --- Terminal window navigation --- vim.cmd([[ --- tnoremap h --- tnoremap j --- tnoremap k --- tnoremap l --- inoremap h --- inoremap j --- inoremap k --- inoremap l --- tnoremap --- ]]) - --- TODO fix this --- resize with arrows -vim.api.nvim_set_keymap('n', '', ':resize -2', { silent = true }) -vim.api.nvim_set_keymap('n', '', ':resize +2', { silent = true }) -vim.api.nvim_set_keymap('n', '', ':vertical resize -2', { silent = true }) -vim.api.nvim_set_keymap('n', '', ':vertical resize +2', { silent = true }) - --- better indenting -vim.api.nvim_set_keymap('v', '<', '', '>gv', { noremap = true, silent = true }) - --- I hate escape -vim.api.nvim_set_keymap('i', 'jk', '', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('i', 'kj', '', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('i', 'jj', '', { noremap = true, silent = true }) - --- Tab switch buffer -vim.api.nvim_set_keymap('n', '', ':bnext', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '', ':bprevious', { noremap = true, silent = true }) - --- Move selected line / block of text in visual mode -vim.api.nvim_set_keymap('x', 'K', ':move \'<-2gv-gv', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('x', 'J', ':move \'>+1gv-gv', { noremap = true, silent = true }) - --- Better nav for omnicomplete -vim.cmd('inoremap (\"\\\")') -vim.cmd('inoremap (\"\\\")') - -vim.cmd('vnoremap p "0p') -vim.cmd('vnoremap P "0P') --- vim.api.nvim_set_keymap('v', 'p', '"0p', {silent = true}) --- vim.api.nvim_set_keymap('v', 'P', '"0P', {silent = true}) - --- vim.cmd('inoremap (\"\\\")') --- vim.cmd('inoremap (\"\\\")') - --- vim.api.nvim_set_keymap('i', '', 'compe#complete()', {noremap = true, silent = true, expr = true}) - --- vim.cmd([[ --- map p (miniyank-autoput) --- map P (miniyank-autoPut) --- map n (miniyank-cycle) --- map N (miniyank-cycleback) --- ]]) - --- Toggle the QuickFix window -vim.api.nvim_set_keymap('', '', ':call QuickFixToggle()', { noremap = true, silent = true }) - - - --- nvim-compe key map --- vim.cmd('inoremap compe#complete()') --- vim.cmd("inoremap compe#confirm('')") --- vim.cmd("inoremap compe#close('')") --- vim.cmd("inoremap compe#scroll({ 'delta': +4 })") --- vim.cmd("inoremap compe#scroll({ 'delta': -4 })") diff --git a/nvim/lua/lang/bash.lua b/nvim/lua/langgg/bash.lua similarity index 100% rename from nvim/lua/lang/bash.lua rename to nvim/lua/langgg/bash.lua diff --git a/nvim/lua/lang/css-ls.lua b/nvim/lua/langgg/css-ls.lua similarity index 100% rename from nvim/lua/lang/css-ls.lua rename to nvim/lua/langgg/css-ls.lua diff --git a/nvim/lua/lang/docker-ls.lua b/nvim/lua/langgg/docker-ls.lua similarity index 100% rename from nvim/lua/lang/docker-ls.lua rename to nvim/lua/langgg/docker-ls.lua diff --git a/nvim/lua/lang/emmet-ls.lua b/nvim/lua/langgg/emmet-ls.lua similarity index 100% rename from nvim/lua/lang/emmet-ls.lua rename to nvim/lua/langgg/emmet-ls.lua diff --git a/nvim/lua/lang/go.lua b/nvim/lua/langgg/go.lua similarity index 100% rename from nvim/lua/lang/go.lua rename to nvim/lua/langgg/go.lua diff --git a/nvim/lua/lang/html-ls.lua b/nvim/lua/langgg/html-ls.lua similarity index 100% rename from nvim/lua/lang/html-ls.lua rename to nvim/lua/langgg/html-ls.lua diff --git a/nvim/lua/lang/js-ts.lua b/nvim/lua/langgg/js-ts.lua similarity index 100% rename from nvim/lua/lang/js-ts.lua rename to nvim/lua/langgg/js-ts.lua diff --git a/nvim/lua/lang/json-ls.lua b/nvim/lua/langgg/json-ls.lua similarity index 100% rename from nvim/lua/lang/json-ls.lua rename to nvim/lua/langgg/json-ls.lua diff --git a/nvim/lua/lang/latex-ls.lua b/nvim/lua/langgg/latex-ls.lua similarity index 100% rename from nvim/lua/lang/latex-ls.lua rename to nvim/lua/langgg/latex-ls.lua diff --git a/nvim/lua/lang/lua.lua b/nvim/lua/langgg/lua.lua similarity index 100% rename from nvim/lua/lang/lua.lua rename to nvim/lua/langgg/lua.lua diff --git a/nvim/lua/lang/python.lua b/nvim/lua/langgg/python.lua similarity index 100% rename from nvim/lua/lang/python.lua rename to nvim/lua/langgg/python.lua diff --git a/nvim/lua/lang/rust-ls.lua b/nvim/lua/langgg/rust-ls.lua similarity index 100% rename from nvim/lua/lang/rust-ls.lua rename to nvim/lua/langgg/rust-ls.lua diff --git a/nvim/lua/lang/yaml-ls.lua b/nvim/lua/langgg/yaml-ls.lua similarity index 100% rename from nvim/lua/lang/yaml-ls.lua rename to nvim/lua/langgg/yaml-ls.lua diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.bak.lua similarity index 100% rename from nvim/lua/plugins.lua rename to nvim/lua/plugins.bak.lua diff --git a/nvim/lua/plugins/editor.lua b/nvim/lua/plugins/editor.lua new file mode 100644 index 0000000..b924b95 --- /dev/null +++ b/nvim/lua/plugins/editor.lua @@ -0,0 +1,225 @@ +local function my_on_attach(bufnr) + local api = require "nvim-tree.api" + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- default mappings + api.config.mappings.default_on_attach(bufnr) + + -- custom mappings + vim.keymap.set('n', '', api.tree.change_root_to_parent, opts('Up')) + vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help')) + vim.keymap.set('n', 'l', api.node.open.edit, opts('Edit')) + vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Parent Close')) + vim.keymap.set('n', 's', api.node.open.horizontal, opts('Horizontal Split')) + vim.keymap.set('n', 'v', api.node.open.vertical, opts('Vertical Split')) +end + +vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent markers when folders are open +vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes. + +vim.g.nvim_tree_icons = { + default = '', + symlink = '', + git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""}, + folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""} +} + + +return { + { + 'nvim-tree/nvim-tree.lua', + dependencies = { + 'nvim-tree/nvim-web-devicons', -- optional + }, + opts = { + on_attach = my_on_attach, + disable_netrw = true, + hijack_netrw = true, + --auto_close = false, + filters = { + dotfiles = false, + custom = {} + }, + git = { + enable = true, + ignore = false, + timeout = 500, + }, + update_focused_file = { + -- enables the feature + enable = true, + -- update the root directory of the tree to the one of the folder containing the file if the file is not under the current root directory + -- only relevant when `update_focused_file.enable` is true + update_cwd = false, + -- list of buffer names / filetypes that will not update the cwd if the file isn't found under the current root directory + -- only relevant when `update_focused_file.update_cwd` is true and `update_focused_file.enable` is true + ignore_list = {} + }, + }, + }, + { + "telescope.nvim", + dependencies = { + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + }, + "nvim-telescope/telescope-file-browser.nvim", + }, + keys = { + { + "fP", + function() + require("telescope.builtin").find_files({ + cwd = require("lazy.core.config").options.root, + }) + end, + desc = "Find Plugin File", + }, + { + ";f", + function() + local builtin = require("telescope.builtin") + builtin.find_files({ + no_ignore = false, + hidden = true, + }) + end, + desc = "Lists files in your current working directory, respects .gitignore", + }, + { + ";r", + function() + local builtin = require("telescope.builtin") + builtin.live_grep({ + additional_args = { "--hidden" }, + }) + end, + desc = "Search for a string in your current working directory and get results live as you type, respects .gitignore", + }, + { + "\\\\", + function() + local builtin = require("telescope.builtin") + builtin.buffers() + end, + desc = "Lists open buffers", + }, + { + ";t", + function() + local builtin = require("telescope.builtin") + builtin.help_tags() + end, + desc = "Lists available help tags and opens a new window with the relevant help info on ", + }, + { + ";;", + function() + local builtin = require("telescope.builtin") + builtin.resume() + end, + desc = "Resume the previous telescope picker", + }, + { + ";e", + function() + local builtin = require("telescope.builtin") + builtin.diagnostics() + end, + desc = "Lists Diagnostics for all open buffers or a specific buffer", + }, + { + ";s", + function() + local builtin = require("telescope.builtin") + builtin.treesitter() + end, + desc = "Lists Function names, variables, from Treesitter", + }, + { + "sf", + function() + local telescope = require("telescope") + + local function telescope_buffer_dir() + return vim.fn.expand("%:p:h") + end + + telescope.extensions.file_browser.file_browser({ + path = "%:p:h", + cwd = telescope_buffer_dir(), + respect_gitignore = false, + hidden = true, + grouped = true, + previewer = false, + initial_mode = "normal", + layout_config = { height = 40 }, + }) + end, + desc = "Open File Browser with the path of the current buffer", + }, + }, + config = function(_, opts) + local telescope = require("telescope") + local actions = require("telescope.actions") + local fb_actions = require("telescope").extensions.file_browser.actions + + opts.defaults = vim.tbl_deep_extend("force", opts.defaults, { + wrap_results = true, + layout_strategy = "horizontal", + layout_config = { prompt_position = "top" }, + sorting_strategy = "ascending", + winblend = 0, + mappings = { + n = {}, + }, + }) + opts.pickers = { + diagnostics = { + theme = "ivy", + initial_mode = "normal", + layout_config = { + preview_cutoff = 9999, + }, + }, + } + opts.extensions = { + file_browser = { + theme = "dropdown", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + mappings = { + -- your custom insert mode mappings + ["n"] = { + -- your custom normal mode mappings + ["N"] = fb_actions.create, + ["h"] = fb_actions.goto_parent_dir, + ["/"] = function() + vim.cmd("startinsert") + end, + [""] = function(prompt_bufnr) + for i = 1, 10 do + actions.move_selection_previous(prompt_bufnr) + end + end, + [""] = function(prompt_bufnr) + for i = 1, 10 do + actions.move_selection_next(prompt_bufnr) + end + end, + [""] = actions.preview_scrolling_up, + [""] = actions.preview_scrolling_down, + }, + }, + }, + } + telescope.setup(opts) + require("telescope").load_extension("fzf") + require("telescope").load_extension("file_browser") + end, + }, +} \ No newline at end of file diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..51c5996 --- /dev/null +++ b/nvim/lua/plugins/lsp.lua @@ -0,0 +1,157 @@ +return { + -- tools + { + "williamboman/mason.nvim", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { + "stylua", + "selene", + "luacheck", + "shellcheck", + "shfmt", + "tailwindcss-language-server", + "typescript-language-server", + "css-lsp", + }) + end, + }, + + -- lsp servers + { + "neovim/nvim-lspconfig", + opts = { + inlay_hints = { enabled = false }, + ---@type lspconfig.options + servers = { + cssls = {}, + tailwindcss = { + root_dir = function(...) + return require("lspconfig.util").root_pattern(".git")(...) + end, + }, + tsserver = { + root_dir = function(...) + return require("lspconfig.util").root_pattern(".git")(...) + end, + single_file_support = false, + settings = { + typescript = { + inlayHints = { + includeInlayParameterNameHints = "literal", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = false, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + javascript = { + inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + }, + }, + html = {}, + yamlls = { + settings = { + yaml = { + keyOrdering = false, + }, + }, + }, + lua_ls = { + -- enabled = false, + single_file_support = true, + settings = { + Lua = { + workspace = { + checkThirdParty = false, + }, + completion = { + workspaceWord = true, + callSnippet = "Both", + }, + misc = { + parameters = { + -- "--log-level=trace", + }, + }, + hint = { + enable = true, + setType = false, + paramType = true, + paramName = "Disable", + semicolon = "Disable", + arrayIndex = "Disable", + }, + doc = { + privateName = { "^_" }, + }, + type = { + castNumberToInteger = true, + }, + diagnostics = { + disable = { "incomplete-signature-doc", "trailing-space" }, + -- enable = false, + groupSeverity = { + strong = "Warning", + strict = "Warning", + }, + groupFileStatus = { + ["ambiguity"] = "Opened", + ["await"] = "Opened", + ["codestyle"] = "None", + ["duplicate"] = "Opened", + ["global"] = "Opened", + ["luadoc"] = "Opened", + ["redefined"] = "Opened", + ["strict"] = "Opened", + ["strong"] = "Opened", + ["type-check"] = "Opened", + ["unbalanced"] = "Opened", + ["unused"] = "Opened", + }, + unusedLocalExclude = { "_*" }, + }, + format = { + enable = false, + defaultConfig = { + indent_style = "space", + indent_size = "2", + continuation_indent_size = "2", + }, + }, + }, + }, + }, + gopls = { + setup = { + cmd = { "gopls", "serve" }, -- use cmd in path, I can update it easily + settings = { + gopls = { + analyses = { + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + staticcheck = false + } + }, + root_dir = require 'lspconfig'.util.root_pattern(".git", "go.mod", "go.work"), + init_options = { usePlaceholders = true, completeUnimported = true }, + }, + }, + }, + setup = {}, + }, + }, +} diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..f3443d2 --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,67 @@ +return { + { "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" }, + + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "astro", + "cmake", + "cpp", + "css", + "fish", + "gitignore", + "go", + "graphql", + "http", + "java", + "php", + "rust", + "scss", + "sql", + "svelte", + }, + + -- matchup = { + -- enable = true, + -- }, + + -- https://github.com/nvim-treesitter/playground#query-linter + query_linter = { + enable = true, + use_virtual_text = true, + lint_events = { "BufWrite", "CursorHold" }, + }, + + playground = { + enable = true, + disable = {}, + updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code + persist_queries = true, -- Whether the query persists across vim sessions + keybindings = { + toggle_query_editor = "o", + toggle_hl_groups = "i", + toggle_injected_languages = "t", + toggle_anonymous_nodes = "a", + toggle_language_display = "I", + focus_language = "f", + unfocus_language = "F", + update = "R", + goto_node = "", + show_help = "?", + }, + }, + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + + -- MDX + vim.filetype.add({ + extension = { + mdx = "mdx", + }, + }) + vim.treesitter.language.register("markdown", "mdx") + end, + }, +} diff --git a/nvim/lua/utils/debug.lua b/nvim/lua/utils/debug.lua new file mode 100644 index 0000000..136823f --- /dev/null +++ b/nvim/lua/utils/debug.lua @@ -0,0 +1,158 @@ +-- selene: allow(global_usage) + +local M = {} + +function M.get_loc() + local me = debug.getinfo(1, "S") + local level = 2 + local info = debug.getinfo(level, "S") + while info and (info.source == me.source or info.source == "@" .. vim.env.MYVIMRC or info.what ~= "Lua") do + level = level + 1 + info = debug.getinfo(level, "S") + end + info = info or me + local source = info.source:sub(2) + source = vim.loop.fs_realpath(source) or source + return source .. ":" .. info.linedefined +end + +---@param value any +---@param opts? {loc:string} +function M._dump(value, opts) + opts = opts or {} + opts.loc = opts.loc or M.get_loc() + if vim.in_fast_event() then + return vim.schedule(function() + M._dump(value, opts) + end) + end + opts.loc = vim.fn.fnamemodify(opts.loc, ":~:.") + local msg = vim.inspect(value) + vim.notify(msg, vim.log.levels.INFO, { + title = "Debug: " .. opts.loc, + on_open = function(win) + vim.wo[win].conceallevel = 3 + vim.wo[win].concealcursor = "" + vim.wo[win].spell = false + local buf = vim.api.nvim_win_get_buf(win) + if not pcall(vim.treesitter.start, buf, "lua") then + vim.bo[buf].filetype = "lua" + end + end, + }) +end + +function M.dump(...) + local value = { ... } + if vim.tbl_isempty(value) then + value = nil + else + value = vim.tbl_islist(value) and vim.tbl_count(value) <= 1 and value[1] or value + end + M._dump(value) +end + +function M.extmark_leaks() + local nsn = vim.api.nvim_get_namespaces() + + local counts = {} + + for name, ns in pairs(nsn) do + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + local count = #vim.api.nvim_buf_get_extmarks(buf, ns, 0, -1, {}) + if count > 0 then + counts[#counts + 1] = { + name = name, + buf = buf, + count = count, + ft = vim.bo[buf].ft, + } + end + end + end + table.sort(counts, function(a, b) + return a.count > b.count + end) + dd(counts) +end + +function estimateSize(value, visited) + if value == nil then + return 0 + end + local bytes = 0 + + -- initialize the visited table if not already done + --- @type table + visited = visited or {} + + -- handle already-visited value to avoid infinite recursion + if visited[value] then + return 0 + else + visited[value] = true + end + + if type(value) == "boolean" or value == nil then + bytes = 4 + elseif type(value) == "number" then + bytes = 8 + elseif type(value) == "string" then + bytes = string.len(value) + 24 + elseif type(value) == "function" then + bytes = 32 -- base size for a function + -- add size of upvalues + local i = 1 + while true do + local name, val = debug.getupvalue(value, i) + if not name then + break + end + bytes = bytes + estimateSize(val, visited) + i = i + 1 + end + elseif type(value) == "table" then + bytes = 40 -- base size for a table entry + for k, v in pairs(value) do + bytes = bytes + estimateSize(k, visited) + estimateSize(v, visited) + end + local mt = debug.getmetatable(value) + if mt then + bytes = bytes + estimateSize(mt, visited) + end + end + return bytes +end + +function M.module_leaks(filter) + local sizes = {} + for modname, mod in pairs(package.loaded) do + if not filter or modname:match(filter) then + local root = modname:match("^([^%.]+)%..*$") or modname + -- root = modname + sizes[root] = sizes[root] or { mod = root, size = 0 } + sizes[root].size = sizes[root].size + estimateSize(mod) / 1024 / 1024 + end + end + sizes = vim.tbl_values(sizes) + table.sort(sizes, function(a, b) + return a.size > b.size + end) + dd(sizes) +end + +function M.get_upvalue(func, name) + local i = 1 + while true do + local n, v = debug.getupvalue(func, i) + if not n then + break + end + if n == name then + return v + end + i = i + 1 + end +end + +return M diff --git a/nvim/utils/bin/install-latest-neovim b/nvim/utils/bin/install-latest-neovim deleted file mode 100755 index 8943b75..0000000 --- a/nvim/utils/bin/install-latest-neovim +++ /dev/null @@ -1,9 +0,0 @@ -!#/bin/bash -cd ~ -sudo rm -r neovim -git clone https://github.com/neovim/neovim -cd neovim -sudo make CMAKE_BUILD_TYPE=Release install -cd ~ -sudo rm -r neovim - diff --git a/nvim/utils/bin/java-linux-ls b/nvim/utils/bin/java-linux-ls deleted file mode 100755 index c5ea391..0000000 --- a/nvim/utils/bin/java-linux-ls +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -# NOTE: -# This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead -# -# NOTE: -# If you're not using Linux you'll need to adjust the `-configuration` option -# to point to the `config_mac' or `config_win` folders depending on your system. - -JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar" -GRADLE_HOME=$HOME/gradle $HOME/.sdkman/candidates/java/current/bin/java \ - -Declipse.application=org.eclipse.jdt.ls.core.id1 \ - -Dosgi.bundles.defaultStartLevel=4 \ - -Declipse.product=org.eclipse.jdt.ls.core.product \ - -Dlog.protocol=true \ - -Dlog.level=ALL \ - -javaagent:/usr/local/share/lombok/lombok.jar \ - -Xms1g \ - -Xmx2G \ - -jar $(echo "$JAR") \ - -configuration "$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_linux" \ - -data "${1:-$HOME/workspace}" \ - --add-modules=ALL-SYSTEM \ - --add-opens java.base/java.util=ALL-UNNAMED \ - --add-opens java.base/java.lang=ALL-UNNAMED - - # for older java versions if you wanna use lombok - # -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \ diff --git a/nvim/utils/bin/java-mac-ls b/nvim/utils/bin/java-mac-ls deleted file mode 100755 index b7ad170..0000000 --- a/nvim/utils/bin/java-mac-ls +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# NOTE: -# This doesn't work as is on Windows. You'll need to create an equivalent `.bat` file instead -# -# NOTE: -# If you're not using Linux you'll need to adjust the `-configuration` option -# to point to the `config_mac' or `config_win` folders depending on your system. - -JAR="$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/plugins/org.eclipse.equinox.launcher_*.jar" -GRADLE_HOME=$HOME/gradle $HOME/.sdkman/candidates/java/current/bin/java \ - -Declipse.application=org.eclipse.jdt.ls.core.id1 \ - -Dosgi.bundles.defaultStartLevel=4 \ - -Declipse.product=org.eclipse.jdt.ls.core.product \ - -Dlog.protocol=true \ - -Dlog.level=ALL \ - -javaagent:/usr/local/share/lombok/lombok.jar \ - -Xms1g \ - -Xmx2G \ - -jar $(echo "$JAR") \ - -configuration "$HOME/.config/nvim/.language-servers/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository/config_mac" \ - -data "${1:-$HOME/workspace}" \ - --add-modules=ALL-SYSTEM \ - --add-opens java.base/java.util=ALL-UNNAMED \ - --add-opens java.base/java.lang=ALL-UNNAMED - - # for older java versions if you wanna use lombok - # -Xbootclasspath/a:/usr/local/share/lombok/lombok.jar \ - diff --git a/nvim/utils/bin/nv b/nvim/utils/bin/nv deleted file mode 100755 index 3408e21..0000000 --- a/nvim/utils/bin/nv +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -nvim -u ~/.config/nvcode/init.lua diff --git a/nvim/vimscript/functions.vim b/nvim/vimscript/functions.vim deleted file mode 100644 index e4ad801..0000000 --- a/nvim/vimscript/functions.vim +++ /dev/null @@ -1,73 +0,0 @@ -command! LspCodeAction lua require 'lv-utils'.code_action() -command! LspDeclaration lua require 'lv-utils'.declaration() -command! LspDefinition lua require 'lv-utils'.definition() -command! LspDocumentSymbol lua require 'lv-utils'.document_symbol() -command! LspFormatting lua require 'lv-utils'.formatting() -command! LspFormattingSync lua require 'lv-utils'.formatting_sync() -command! LspHover lua require 'lv-utils'.hover() -command! LspImplementation lua require 'lv-utils'.implementation() -command! LspRangeCodeAction lua require 'lv-utils'.range_code_action() -command! LspRangeFormatting lua require 'lv-utils'.range_formatting() -command! LspReferences lua require 'lv-utils'.references() -command! LspRename lua require 'lv-utils'.rename() -command! LspTypeDefinition lua require 'lv-utils'.type_definition() -command! LspWorkspaceSymbol lua require 'lv-utils'.workspace_symbol() -command! LspGotoNext lua require 'lv-utils'.goto_next() -command! LspGotoPrev lua require 'lv-utils'.goto_prev() -command! LspShowLineDiagnostics lua require 'lv-utils'.show_line_diagnostics() -command! NextHunk lua require 'lv-utils'.next_hunk() -command! PrevHunk lua require 'lv-utils'.prev_hunk() -command! StageHunk lua require 'lv-utils'.stage_hunk() -command! UndoStageHunk lua require 'lv-utils'.undo_stage_hunk() -command! ResetHunk lua require 'lv-utils'.reset_hunk() -command! ResetBuffer lua require 'lv-utils'.reset_buffer() -command! PreviewHunk lua require 'lv-utils'.preview_hunk() -command! BlameLine lua require 'lv-utils'.blame_line() -command! W noa w - -" Debugging -command! DebugToggleBreakpoint lua require'dap'.toggle_breakpoint() -command! DebugStart lua require'dap'.continue() -command! DebugContinue lua require'dap'.continue() -command! DebugStepOver lua require'dap'.step_over() -command! DebugStepOut lua require'dap'.step_out() -command! DebugStepInto lua require'dap'.step_into() -command! DebugToggleRepl lua require'dap'.repl.toggle() -command! DebugGetSession lua require'dap'.session() - -" Available Debug Adapters: -" https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ -" -" Adapter configuration and installation instructions: -" https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation -" -" Debug Adapter protocol: -" https://microsoft.github.io/debug-adapter-protocol/ - -" TODO Add full support later -" nnoremap :lua require'dap'.continue() -" nnoremap :lua require'dap'.step_over() -" nnoremap :lua require'dap'.step_into() -" nnoremap :lua require'dap'.step_out() -" nnoremap b :lua require'dap'.toggle_breakpoint() -" nnoremap B :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: ')) -" nnoremap lp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) -" nnoremap dr :lua require'dap'.repl.open() -" nnoremap dl :lua require'dap'.run_last() - -autocmd! User GoyoEnter lua require('gitsigns').toggle_signs() -autocmd! User GoyoLeave lua require('gitsigns').toggle_signs() - -autocmd User GoyoEnter set laststatus=0 -autocmd User GoyoLeave set laststatus=2 - -" autocmd! User GoyoEnter lua require('galaxyline').disable_galaxyline() -" autocmd! User GoyoLeave lua require('galaxyline').galaxyline_augroup() - -function! QuickFixToggle() - if empty(filter(getwininfo(), 'v:val.quickfix')) - copen - else - cclose - endif -endfunction diff --git a/nvim/vimscript/lv-vscode/init.vim b/nvim/vimscript/lv-vscode/init.vim deleted file mode 100644 index 1661d49..0000000 --- a/nvim/vimscript/lv-vscode/init.vim +++ /dev/null @@ -1,84 +0,0 @@ -" packadd quickscope - -execute 'luafile ' . stdpath('config') . '/lua/settings.lua' - -function! s:manageEditorSize(...) - let count = a:1 - let to = a:2 - for i in range(1, count ? count : 1) - call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize') - endfor -endfunction - -function! s:vscodeCommentary(...) abort - if !a:0 - let &operatorfunc = matchstr(expand(''), '[^. ]*$') - return 'g@' - elseif a:0 > 1 - let [line1, line2] = [a:1, a:2] - else - let [line1, line2] = [line("'["), line("']")] - endif - - call VSCodeCallRange("editor.action.commentLine", line1, line2, 0) -endfunction - -function! s:openVSCodeCommandsInVisualMode() - normal! gv - let visualmode = visualmode() - if visualmode == "V" - let startLine = line("v") - let endLine = line(".") - call VSCodeNotifyRange("workbench.action.showCommands", startLine, endLine, 1) - else - let startPos = getpos("v") - let endPos = getpos(".") - call VSCodeNotifyRangePos("workbench.action.showCommands", startPos[1], endPos[1], startPos[2], endPos[2], 1) - endif -endfunction - -function! s:openWhichKeyInVisualMode() - normal! gv - let visualmode = visualmode() - if visualmode == "V" - let startLine = line("v") - let endLine = line(".") - call VSCodeNotifyRange("whichkey.show", startLine, endLine, 1) - else - let startPos = getpos("v") - let endPos = getpos(".") - call VSCodeNotifyRangePos("whichkey.show", startPos[1], endPos[1], startPos[2], endPos[2], 1) - endif -endfunction - -" Better Navigation -nnoremap :call VSCodeNotify('workbench.action.navigateDown') -xnoremap :call VSCodeNotify('workbench.action.navigateDown') -nnoremap :call VSCodeNotify('workbench.action.navigateUp') -xnoremap :call VSCodeNotify('workbench.action.navigateUp') -nnoremap :call VSCodeNotify('workbench.action.navigateLeft') -xnoremap :call VSCodeNotify('workbench.action.navigateLeft') -nnoremap :call VSCodeNotify('workbench.action.navigateRight') -xnoremap :call VSCodeNotify('workbench.action.navigateRight') - -nnoremap gr call VSCodeNotify('editor.action.goToReferences') - -" Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors -" xnoremap vscodeCommentary() -" nnoremap vscodeCommentary() . '_' - -nnoremap _ :call VSCodeNotify('workbench.action.toggleEditorWidths') - -nnoremap :call VSCodeNotify('whichkey.show') -xnoremap :call openWhichKeyInVisualMode() - -xnoremap :call openVSCodeCommandsInVisualMode() - -xmap gc VSCodeCommentary -nmap gc VSCodeCommentary -omap gc VSCodeCommentary -nmap gcc VSCodeCommentaryLine - -" Simulate same TAB behavior in VSCode -nmap :Tabnext -nmap :Tabprev