diff --git a/.gitignore b/.gitignore index 1b83131..fc6c742 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ test.sh .luarc.json nvim plugin/packer_compiled.lua +lazy-locak.json diff --git a/init.lua b/init.lua index 46c126d..7e7a0fc 100644 --- a/init.lua +++ b/init.lua @@ -1,2 +1,130 @@ -require "core" -require "plugin" +if vim.g.vscode then + print("VSCode") + -- VSCode + local function split(direction, file) + if direction == 'h' then + vim.fn["VSCodeCall"]('workbench.action.splitEditorDown') + else + vim.fn["VSCodeCall"]('workbench.action.splitEditorRight') + end + if file ~= '' then + vim.fn["VSCodeExtensionNotify"]('open-file', vim.fn["expand"](file), 'all') + end + end + + local function splitNew(direction, file) + local fileToOpen = file == '' and '__vscode_new__' or file + split(direction, fileToOpen) + end + + local function closeOtherEditors() + vim.fn["VSCodeNotify"]('workbench.action.closeEditorsInOtherGroups') + vim.fn["VSCodeNotify"]('workbench.action.closeOtherEditors') + end + + local function manageEditorSize(count, to) + for i = 1, count or 1 do + local action = to == 'increase' and 'workbench.action.increaseViewSize' or 'workbench.action.decreaseViewSize' + vim.fn["VSCodeNotify"](action) + end + end + + vim.cmd("command! -complete=file -nargs=? Split call v:lua.split('h', )") + vim.cmd("command! -complete=file -nargs=? Vsplit call v:lua.split('v', )") + vim.cmd("command! -complete=file -nargs=? New call v:lua.split('h', '__vscode_new__')") + vim.cmd("command! -complete=file -nargs=? Vnew call v:lua.split('v', '__vscode_new__')") + vim.cmd( + "command! -bang Only if == '!' | call v:lua.closeOtherEditors() | else | call VSCodeNotify('workbench.action.joinAllGroups') | endif") + + vim.api.nvim_set_keymap('n', 's', ':call v:lua.split("h")', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', 's', ':call v:lua.split("h")', { noremap = true, silent = true }) + + vim.api.nvim_set_keymap('n', 'v', ':call v:lua.split("v")', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', 'v', ':call v:lua.split("v")', { noremap = true, silent = true }) + + vim.api.nvim_set_keymap('n', 'n', ':call v:lua.splitNew("h", "__vscode_new__")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', 'n', ':call v:lua.splitNew("h", "__vscode_new__")', + { noremap = true, silent = true }) + + vim.api.nvim_set_keymap('n', '=', ':call VSCodeNotify("workbench.action.evenEditorWidths")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '=', ':call VSCodeNotify("workbench.action.evenEditorWidths")', + { noremap = true, silent = true }) + + vim.api.nvim_set_keymap('n', '>', ':call v:lua.manageEditorSize(v:count, "increase")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '>', ':call v:lua.manageEditorSize(v:count, "increase")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '+', ':call v:lua.manageEditorSize(v:count, "increase")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '+', ':call v:lua.manageEditorSize(v:count, "increase")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '<', ':call v:lua.manageEditorSize(v:count, "decrease")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '<', ':call v:lua.manageEditorSize(v:count, "decrease")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '-', ':call v:lua.manageEditorSize(v:count, "decrease")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '-', ':call v:lua.manageEditorSize(v:count, "decrease")', + { noremap = true, silent = true }) + + -- Better Navigation + vim.api.nvim_set_keymap('n', '', ':call VSCodeNotify("workbench.action.navigateDown")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '', ':call VSCodeNotify("workbench.action.navigateDown")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '', ':call VSCodeNotify("workbench.action.navigateUp")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '', ':call VSCodeNotify("workbench.action.navigateUp")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '', ':call VSCodeNotify("workbench.action.navigateLeft")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '', ':call VSCodeNotify("workbench.action.navigateLeft")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '', ':call VSCodeNotify("workbench.action.navigateRight")', + { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '', ':call VSCodeNotify("workbench.action.navigateRight")', + { noremap = true, silent = true }) + + -- Bind C-/ to vscode commentary + vim.api.nvim_set_keymap('x', '', ':call Comment()', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '', ':call Comment()', { noremap = true, silent = true }) + + vim.api.nvim_set_keymap('n', '_', ':call VSCodeNotify("workbench.action.toggleEditorWidths")', + { noremap = true, silent = true }) + + vim.api.nvim_set_keymap('n', '', ':call VSCodeNotify("whichkey.show")', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('x', '', ':call VSCodeNotify("whichkey.show")', { noremap = true, silent = true }) + + -- Relative Number + vim.cmd("command! Nu call VSCodeCall('settings.cycle.relativeLineNumbers')") + vim.cmd("autocmd InsertEnter * :Nu") + vim.cmd("autocmd InsertLeave * :Nu") + + -- vim-commentary + vim.api.nvim_set_keymap('x', 'gc', 'VSCodeCommentary', {}) + vim.api.nvim_set_keymap('n', 'gc', 'VSCodeCommentary', {}) + vim.api.nvim_set_keymap('o', 'gc', 'VSCodeCommentary', {}) + vim.api.nvim_set_keymap('n', 'gcc', 'VSCodeCommentaryLine', {}) + + -- Theme Changer + local function setCursorLineNrColorInsert(mode) + if mode == "i" then + vim.fn["VSCodeNotify"]('nvim-theme.nvimColorInsert') + elseif mode == "r" then + vim.fn["VSCodeNotify"]('nvim-theme.nvimColorReplace') + end + end + + vim.cmd("augroup CursorLineNrColorSwap") + vim.cmd("autocmd!") + vim.cmd("autocmd ModeChanged *:[vV\\x16]* call VSCodeNotify('nvim-theme.nvimColorVisual')") + vim.cmd("autocmd ModeChanged *:[R]* call VSCodeNotify('nvim-theme.nvimColorReplace')") + vim.cmd("autocmd InsertEnter * call setCursorLineNrColorInsert(v:insertmode)") + vim.cmd("autocmd InsertLeave * call VSCodeNotify('nvim-theme.nvimColorNormal')") + vim.cmd("autocmd CursorHold * call VSCodeNotify('nvim-theme.nvimColorNormal')") + vim.cmd("augroup END") +else + require("config") +end diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index 160e1ee..0000000 --- a/lazy-lock.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, - "LuaSnip": { "branch": "master", "commit": "0df29db3543837f8b41597f2640397c5ec792b7b" }, - "SmoothCursor.nvim": { "branch": "main", "commit": "efe978cb59a752adbc5908aefde1de1d0e1fc87b" }, - "agrolens.nvim": { "branch": "main", "commit": "a2f15094a2b7e7bc79184de8edc13034116d8d47" }, - "alpha-nvim": { "branch": "main", "commit": "234822140b265ec4ba3203e3e0be0e0bb826dff5" }, - "auto-pairs": { "branch": "master", "commit": "39f06b873a8449af8ff6a3eee716d3da14d63a76" }, - "better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" }, - "bufferline.nvim": { "branch": "main", "commit": "243893ba9d5d1049dd451a25cab32ec7f8f67bcf" }, - "bufresize.nvim": { "branch": "master", "commit": "3b19527ab936d6910484dcc20fb59bdb12322d8b" }, - "catppuccin": { "branch": "main", "commit": "fc537040147f0374a22b88142a20eb6781141f0b" }, - "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, - "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, - "cmp-nvim-tags": { "branch": "main", "commit": "30bdc2eec86eb66730af541bb06d24d4a67e3eeb" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp-rg": { "branch": "master", "commit": "677a7874ee8f1afc648c2e7d63a97bc21a7663c5" }, - "cmp-tmux": { "branch": "main", "commit": "97ec06b8030b8bf6d1fd83d49bdd16c98e04c845" }, - "cmp-treesitter": { "branch": "master", "commit": "b8bc760dfcc624edd5454f0982b63786a822eed9" }, - "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "dial.nvim": { "branch": "master", "commit": "019bbe9daea397c93a99adc747f8f071379fee5c" }, - "diffview.nvim": { "branch": "main", "commit": "d38c1b5266850f77f75e006bcc26213684e1e141" }, - "dressing.nvim": { "branch": "master", "commit": "1f2d1206a03bd3add8aedf6251e4534611de577f" }, - "fidget.nvim": { "branch": "legacy", "commit": "90c22e47be057562ee9566bad313ad42d622c1d3" }, - "flash.nvim": { "branch": "main", "commit": "6d76c5dee65181ab55cbdfb0760260e800d643f4" }, - "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, - "gitsigns.nvim": { "branch": "main", "commit": "ff01d34daaed72f271a8ffa088a7e839a60c640f" }, - "guihua.lua": { "branch": "master", "commit": "5ad8dba19ce9b9fd8965598984dfdc9c119f97e4" }, - "hlargs.nvim": { "branch": "main", "commit": "6218a401824c5733ac50b264991b62d064e85ab2" }, - "indent-blankline.nvim": { "branch": "master", "commit": "0fe34b4c1b926e106d105d3ae88ef6cbf6743572" }, - "iswap.nvim": { "branch": "master", "commit": "8b038cb10585713b4c3918d44d6c329effad2a5d" }, - "kanagawa.nvim": { "branch": "master", "commit": "c19b9023842697ec92caf72cd3599f7dd7be4456" }, - "lazy.nvim": { "branch": "main", "commit": "33c447b96e1cb1a5a2be87982d5d32bb5054079d" }, - "legendary.nvim": { "branch": "master", "commit": "be1de69822e6329ef5ae87521a70911c434aa9eb" }, - "lsp_lines.nvim": { "branch": "main", "commit": "9e3f99fbbd28aaec80dc0158c43be8cca8dd5017" }, - "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "397273083f988c1a17acf3816947cd198338e700" }, - "mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" }, - "modes.nvim": { "branch": "main", "commit": "9ca1d683e9505f6fdc97a884151267cfc380a379" }, - "neoconf.nvim": { "branch": "main", "commit": "393d37abd9d82adcac627309a41758ae8e140d9e" }, - "neodev.nvim": { "branch": "main", "commit": "a4b6e7ca11ff5be2264d5c169fcedd97d8699ec4" }, - "neogit": { "branch": "master", "commit": "d3fbf8b48f4f8bc406eb23f8b06eb912776f8cb0" }, - "neon": { "branch": "main", "commit": "7765aaa7d1cd3804176140644640766e4411c766" }, - "nightly": { "branch": "main", "commit": "fbab0f60e2d92d119f6e0cf50c503dcd7753659e" }, - "nvim-autopairs": { "branch": "master", "commit": "748e72c05495a3d30e88a6ef04b21697019a9aa9" }, - "nvim-bqf": { "branch": "main", "commit": "8784eebf34371049b641646d00232c2603215297" }, - "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, - "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, - "nvim-lsp-file-operations": { "branch": "master", "commit": "0ae13ac58136c6175638b6e1ba04cb487dd22272" }, - "nvim-lspconfig": { "branch": "master", "commit": "61f984586fefa9869f07f3027e0dce5752412786" }, - "nvim-notify": { "branch": "master", "commit": "e4a2022f4fec2d5ebc79afa612f96d8b11c627b3" }, - "nvim-tmux-navigation": { "branch": "main", "commit": "543f090a45cef28156162883d2412fffecb6b750" }, - "nvim-tree.lua": { "branch": "master", "commit": "53b0bcaadaffb505acff230578b56a86ec1ab38a" }, - "nvim-treesitter": { "branch": "master", "commit": "49f7194e4c4d3c9ed891b0968798c062e8ac5a3d" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "76c7a89b41de77a4f83fb77fa072c5ad7605fe3b" }, - "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "7241635869b7a8115893ffa67bab3907756caf4f" }, - "nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" }, - "nvim-ts-rainbow2": { "branch": "master", "commit": "b3120cd5ae9ca524af9cb602f41e12e301fa985f" }, - "nvim-ufo": { "branch": "main", "commit": "f7eea53e88456403212df074b9aa3148a3908435" }, - "nvim-web-devicons": { "branch": "master", "commit": "a1e6268779411048a87f767a27380089362a0ce2" }, - "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, - "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" }, - "relative-toggle.nvim": { "branch": "main", "commit": "fabe2f60f5f148f2bf1fb76e8a542f5adf8d996a" }, - "rest.nvim": { "branch": "main", "commit": "5bcaa1012ea8efd6093c69d2a4c67fbde760d043" }, - "sad.nvim": { "branch": "master", "commit": "869c7f3ca3dcd28fd78023db6a7e1bf8af0f4714" }, - "smart-pairs": { "branch": "master", "commit": "6e7a5a8e3906f7a8a8c5b8603d5264ff1b5d87c3" }, - "smart-splits.nvim": { "branch": "master", "commit": "dbf2c13bad1b75ab207639ba817a7e8a8a450042" }, - "sqlite.lua": { "branch": "master", "commit": "b7e28c8463254c46a8e61c52d27d6a2040492fc3" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, - "telescope-symbols.nvim": { "branch": "master", "commit": "f2060117d965df4a626f068a4ebbd8ee051aa076" }, - "telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, - "tokyonight.nvim": { "branch": "main", "commit": "dce0ab49ae751f4f3617ab42d6f20c72369c7cb1" }, - "treesj": { "branch": "main", "commit": "81d0ae51b84143e228d27b6cf79d09012d2021cb" }, - "typescript-tools.nvim": { "branch": "master", "commit": "ebddb35900bbf5fa41fffa0463b676bf08e474e6" }, - "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, - "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, - "vim-snippets": { "branch": "master", "commit": "ccc2fa1529d372f7ac16d5eb07a385a72b50e05d" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" } -} \ No newline at end of file diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100644 index 0000000..1ee3b17 --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,41 @@ +local augroup = vim.api.nvim_create_augroup -- Create/get autocommand group +local autocmd = vim.api.nvim_create_autocmd -- Create autocommand + + +-- augroup('MyCustomNeogitEvents', { clear = true }) +-- autocmd('User', { +-- pattern = 'NeogitPushComplete', +-- group = 'MyCustomNeogitEvents', +-- callback = require('neogit').close, +-- }) +-- + +-- Remove whitespace on save +autocmd('BufWritePre', { + pattern = '', + command = ":%s/\\s\\+$//e" +}) + +-- Set indentation to 2 spaces +augroup('setIndent', { clear = true }) +autocmd('Filetype', { + group = 'setIndent', + pattern = { 'xml', 'html', 'xhtml', 'css', 'scss', 'javascript', 'typescript', + 'yaml', 'lua' + }, + command = 'setlocal shiftwidth=2 tabstop=2' +}) + + +vim.cmd([[command! Format :lua FormatWithLSP()]]) + +-- Define a function to trigger LSP formatting +function FormatWithLSP() + vim.lsp.buf.format({ async = true }) +end + +vim.cmd([[command! LuaEditSnipFunc :lua LuaEditSnipFunc()]]) + +function LuaEditSnipFunc() + require('luasnip.loaders.from_lua').edit_snippet_files() +end diff --git a/lua/config/defaults.lua b/lua/config/defaults.lua new file mode 100644 index 0000000..8c5e1c5 --- /dev/null +++ b/lua/config/defaults.lua @@ -0,0 +1,26 @@ +local M = {} + +M.config = { + figlet_name = { + [[ __ .__ __ ___________ ____ ]], + [[ | | _|__| ____ | | __\ \ \ / / ]], + [[ | |/ / |/ ___\| |/ // | \ Y / ]], + [[ | <| \ \___| __|_ \____|__ /\___/ ]], + [[ \/ \/ \/ \/ ]], + }, + themes = { + "tokyonight", + "catppuccin", + "kanagawa", + "nightfox", + "night-owl", + }, + colorscheme = "catppuccin", + transparent_background = true +} + +function M.setup() +end + +return M diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 0000000..32784d0 --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,6 @@ +require("config.options") +require("config.lazy") +require("config.keymaps") +require("config.autocmds") +local color_scheme = require("config.defaults").config.colorscheme +vim.cmd("colorscheme " .. color_scheme) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 0000000..ede17e3 --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,50 @@ +local keymap = vim.api.nvim_set_keymap +local map = vim.keymap.set +local opts = { noremap = true, silent = true } +local expr_opts = { expr = true, silent = true } + +keymap("n", "aa", ":hide", opts) + +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +keymap("n", "v", ":vsp", opts) +keymap("n", "V", ":sp", opts) + +-- better up/down +map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", expr_opts) +map({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", expr_opts) +map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", expr_opts) +map({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", expr_opts) + +-- Resize window using arrow keys +map("n", "", "resize +2", { desc = "Increase window height" }) +map("n", "", "resize -2", { desc = "Decrease window height" }) +map("n", "", "vertical resize -2", { desc = "Decrease window width" }) +map("n", "", "vertical resize +2", { desc = "Increase window width" }) + +-- Move Lines +map("n", "", "m .+1==", { desc = "Move down" }) +map("n", "", "m .-2==", { desc = "Move up" }) +map("i", "", "m .+1==gi", { desc = "Move down" }) +map("i", "", "m .-2==gi", { desc = "Move up" }) +map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) +map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) + +-- Clear search with +map({ "i", "n" }, "", "noh", { desc = "Escape and clear hlsearch" }) + +function load_extra_options() + local function bind_extra_cmd(options) + for optionCount = 1, #options do vim.cmd(options[optionCount]) end + end + local options = { + "filetype plugin on", "filetype indent on", "cabbr Q q", "cabbr Q! q!", + "cabbr W! w!", "cabbr W w", "cabbr WA wa", "cabbr Wa wa", "cabbr Wq wq", + "cabbr WQ wq", "cabbr Qa qa", "cabbr QA qa" + } + bind_extra_cmd(options) +end + +load_extra_options() diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..009de0d --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,62 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + 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) + +local opts = { + install = { + colorscheme = {}, + }, + checker = { + enabled = true, + notify = false, + }, + change_detection = { + notify = false, + }, +} + +local color_scheme = require("config.defaults").config.colorscheme + +require("lazy").setup({ + spec = { + { import = "plugins" }, + { import = "plugins.lsp" }, + { import = "plugins.extras.explorer" }, + -- ColorScheme + { import = "plugins.colorschemes." .. color_scheme }, + -- StatusLine Select One + -- { import = "plugins.extras.statusline.lualine" }, + { import = "plugins.extras.statusline.luafancy" }, + -- { import = "plugins.extras.statusline.galaxyline" }, + -- Added required configs + -- { import = "plugins.extras.lsp" }, + { import = "plugins.extras.dashboard.bufferline" }, + { import = "plugins.extras.wilder" }, + { import = "plugins.extras.figlet" }, + }, + defaults = { + lazy = false, + version = false, + }, + checker = { enabled = false }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}, opts) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..52a682d --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,104 @@ +----------------------------------------------------------- +-- General Neovim options setting +----------------------------------------------------------- + +local g = vim.g +local opt = vim.opt + + +if vim.fn.has("nvim-0.9.0") == 1 then + opt.splitkeep = 'screen' + opt.shortmess:append({ C = true }) +end + +----------------------------------------------------------- +-- General +----------------------------------------------------------- + +opt.mouse = 'a' -- Enable mouse mode +opt.clipboard = "unnamedplus" -- Copy/paste to system clipboard +opt.swapfile = false -- Don't use swapfile +opt.completeopt = 'menuone,noinsert,noselect' -- Autocomplete options + + + +opt.hlsearch = true -- Set highlight on search +opt.breakindent = true -- Enable break indent +opt.undofile = true -- Save undo history +opt.ignorecase = true -- Case insensitive searching UNLESS /C or capital in search +opt.smartcase = true -- Decrease update time +opt.termguicolors = true -- Set colorscheme + +opt.foldexpr = "nvim_treesitter#foldexpr()" +opt.foldmethod = "expr" + +opt.foldcolumn = '0' -- '0' is not bad +opt.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +opt.foldlevelstart = -1 +opt.foldenable = true +opt.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] + +opt.guifont = 'JetbrainsMono Nerd Font:h13' +opt.laststatus = 3 -- global statusline +opt.showmode = false + +opt.cursorline = true + +-- Indenting +opt.expandtab = true +opt.shiftwidth = 2 +opt.smartindent = true +opt.tabstop = 2 +opt.softtabstop = 2 + +-- opt.fillchars = { eob = " " } +opt.fillchars = { + fold = " ", + foldopen = "", + foldclose = "", + foldsep = " ", + diff = "╱", + eob = " ", +} +opt.listchars = { + tab = ">>>", + trail = "·", + precedes = "←", + extends = "→", + eol = "↲", + nbsp = "␣", +} +opt.ignorecase = true +opt.smartcase = true + +opt.spelllang = { "en" } +opt.scrolloff = 4 -- Lines of context +opt.timeoutlen = 300 +opt.undofile = true +opt.undolevels = 500 +opt.wildmode = "longest:full,full" -- Command-line completion mode +opt.winminwidth = 5 -- Minimum window width +opt.wrap = false -- Disable line wrap + +----------------------------------------------------------- +-- Memory, CPU +----------------------------------------------------------- +opt.hidden = true -- Enable background buffers +opt.history = 100 -- Remember N lines in history +opt.lazyredraw = true -- Faster scrolling +opt.synmaxcol = 240 -- Max column for syntax highlight +opt.updatetime = 250 -- ms to wait for trigger an event + +-- Disable nvim intro +opt.shortmess:append "sI" + + + +-- Numbers +opt.number = true +opt.numberwidth = 1 +opt.ruler = false + +g.mapleader = " " +g.maplocalleader = "\\" +g.markdown_recommended_style = 0 diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua deleted file mode 100644 index d118ed6..0000000 --- a/lua/core/default_config.lua +++ /dev/null @@ -1,61 +0,0 @@ -local M = {} -local set = vim.keymap.set -local keymap = vim.api.nvim_set_keymap -local opts = { noremap = true, silent = true } -local opts_s = { silent = true } -local opts_e_s = { expr = true, silent = true } - -M.options = { - kicknv_branch = "master", - name = "kickNV", - figlet_name = { - [[ __ .__ __ ___________ ____ ]], - [[ | | _|__| ____ | | __\ \ \ / / ]], - [[ | |/ / |/ ___\| |/ // | \ Y / ]], - [[ | <| \ \___| __|_ \____|__ /\___/ ]], - [[ \/ \/ \/ \/ ]], - } -} - -M.ui = { - theme_toggle = { - "nightly", - "tokyonight", - "kanagawa", - "catppuccin", - "neon" - }, - theme = "catppuccin", - transparency = true, -} - -M.opts = opts - -M.keymap = keymap -M.set = set - -M.keymaps = { - default = function() - set({ 'n', 'v' }, '', '', opts_s) - set('n', 'k', "v:count == 0 ? 'gk' : 'k'", opts_e_s) - set('n', 'j', "v:count == 0 ? 'gj' : 'j'", opts_e_s) - set("v", "<", "", ">gv") - end -} - - -function M.load_extra_options() - local function bind_extra_cmd(options) - for optionCount = 1, #options do vim.cmd(options[optionCount]) end - end - local options = { - "filetype plugin on", "filetype indent on", "cabbr Q q", "cabbr Q! q!", - "cabbr W! w!", "cabbr W w", "cabbr WA wa", "cabbr Wa wa", "cabbr Wq wq", - "cabbr WQ wq", "cabbr Qa qa", "cabbr QA qa" - } - bind_extra_cmd(options) -end - -return M diff --git a/lua/core/init.lua b/lua/core/init.lua deleted file mode 100644 index 72e5026..0000000 --- a/lua/core/init.lua +++ /dev/null @@ -1,88 +0,0 @@ -local opt = vim.opt -local g = vim.g -local o = vim.o - ------------- options ---------- - -if vim.fn.has("nvim-0.9.0") == 1 then - opt.splitkeep = 'screen' - opt.shortmess:append({ C = true }) -end - -o.hlsearch = true -- Set highlight on search -o.mouse = 'a' -- Enable mouse mode -o.breakindent = true -- Enable break indent -o.undofile = true -- Save undo history -o.ignorecase = true -- Case insensitive searching UNLESS /C or capital in search -o.smartcase = true -- Decrease update time -o.updatetime = 250 -o.termguicolors = true -- Set colorscheme - -o.foldexpr = "nvim_treesitter#foldexpr()" -o.foldmethod = "expr" - -o.foldcolumn = '0' -- '0' is not bad -o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value -o.foldlevelstart = -1 -o.foldenable = true -o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] - -opt.guifont = 'JetbrainsMono Nerd Font:h13' -opt.laststatus = 3 -- global statusline -opt.showmode = false - --- opt.clipboard = "unnamedplus" -opt.cursorline = true - --- Indenting -opt.expandtab = true -opt.shiftwidth = 2 -opt.smartindent = true -opt.tabstop = 2 -opt.softtabstop = 2 - --- opt.fillchars = { eob = " " } -opt.fillchars = { - fold = " ", - foldopen = "", - foldclose = "", - foldsep = " ", - diff = "╱", - eob = " ", -} -opt.listchars = { - tab = ">>>", - trail = "·", - precedes = "←", - extends = "→", - eol = "↲", - nbsp = "␣", -} -opt.ignorecase = true -opt.smartcase = true -opt.mouse = "a" - -opt.spelllang = { "en" } -opt.scrolloff = 4 -- Lines of context -opt.timeoutlen = 300 -opt.undofile = true -opt.undolevels = 10000 -opt.updatetime = 200 -- Save swap file and trigger CursorHold -opt.wildmode = "longest:full,full" -- Command-line completion mode -opt.winminwidth = 5 -- Minimum window width -opt.wrap = false -- Disable line wrap -opt.dictionary:append("~/.config/nvim/dictionary.txt") - - --- Numbers -opt.number = true -opt.numberwidth = 1 -opt.ruler = false - -g.mapleader = " " -g.maplocalleader = "\\" -g.markdown_recommended_style = 0 - ------------- autocommand ---------- - -require('core.default_config').load_extra_options() diff --git a/lua/plugin/config/autopairs.lua b/lua/plugin/config/autopairs.lua deleted file mode 100644 index e202401..0000000 --- a/lua/plugin/config/autopairs.lua +++ /dev/null @@ -1,20 +0,0 @@ -local M = {} -local status, autopairs = pcall(require, "windwp/nvim-autopairs") - -function M.setup() - if (not status) then return end - autopairs.setup({ - check_ts = true, - ts_config = { - lua = { 'string' }, - javascript = { 'template_string' }, - java = false, - } - }) - - local cmp_autopairs = require('nvim-autopairs.completion.cmp') - local cmp = require('cmp') - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) -end - -return M diff --git a/lua/plugin/config/bqf.lua b/lua/plugin/config/bqf.lua deleted file mode 100644 index 0e08058..0000000 --- a/lua/plugin/config/bqf.lua +++ /dev/null @@ -1,15 +0,0 @@ -local M = {} -local status, bqf = pcall(require, "bqf") - -function M.setup() - if (not status) then return end - - bqf.setup { - auto_resize_height = false, - preview = { - auto_preview = false, - }, - } -end - -return M diff --git a/lua/plugin/config/bufferline.lua b/lua/plugin/config/bufferline.lua deleted file mode 100644 index c76afc6..0000000 --- a/lua/plugin/config/bufferline.lua +++ /dev/null @@ -1,56 +0,0 @@ ----@diagnostic disable: missing-fields -local M = {} -local status, bufferline = pcall(require, "bufferline") -local opts = require("core.default_config").opts -local keymap = require("core.default_config").keymap - -function M.setup() - if (not status) then return end - - bufferline.setup { - options = { - offsets = { - { - filetype = "NvimTree", - text = " Explorer", - highlight = "Directory", - text_align = "left", - padding = 1 - }, - }, - left_trunc_marker = "", - right_trunc_marker = "", - number_style = "", - numbers = function(opts) - return string.format("%s", opts.ordinal) - end, - separator_style = { "|", "|" }, - insert_at_end = false, - insert_at_start = true, - close_icon = "", - modified_icon = "", - icon_pinned = "車", - semantic_letters = true, - show_buffer_close_icons = false, - show_tab_indicators = false, - always_show_bufferline = true, - max_name_length = 30, - max_prefix_length = 15, - tab_size = 20, - sort_by = "extension", - custom_filter = function(buf_number) - local name = vim.fn.bufname(buf_number) - if name ~= "" and not name:match("^term://") then - return true - ---@diagnostic disable-next-line: missing-return - end - end, - highlight = require("catppuccin.groups.integrations.bufferline").get(), - } - } - - keymap("n", "", ":BufferLineCycleNext", opts) - keymap("n", "", ":BufferLineCyclePrev", opts) -end - -return M diff --git a/lua/plugin/config/bufresize.lua b/lua/plugin/config/bufresize.lua deleted file mode 100644 index 6c36b18..0000000 --- a/lua/plugin/config/bufresize.lua +++ /dev/null @@ -1,23 +0,0 @@ -local M = {} -local opts = require("core.default_config").opts -local status, bufresize = pcall(require, "bufresize") - -function M.setup() - if (not status) then return end - bufresize.setup({ - register = { - keys = { - { "n", "=", "=", opts }, - { "n", "|", "|", opts }, - }, - trigger_events = { "BufWinEnter", "WinEnter" }, - }, - resize = { - keys = {}, - trigger_events = { "VimResized" }, - increment = false, - }, - }) -end - -return M diff --git a/lua/plugin/config/colorscheme.lua b/lua/plugin/config/colorscheme.lua deleted file mode 100644 index 40e6322..0000000 --- a/lua/plugin/config/colorscheme.lua +++ /dev/null @@ -1,127 +0,0 @@ -local M = {} -local ui = require("core.default_config").ui - - -function M.setup() - require('kanagawa').setup({ - compile = true, - commentStyle = { italic = true }, - functionStyle = { italic = true }, - keywordStyle = { italic = true }, - statementStyle = { bold = true }, - typeStyle = {}, - transparent = ui.transparency, - theme = "dragon", - colors = { - palette = {}, - theme = { - wave = {}, - lotus = {}, - dragon = {}, - all = { - ui = { - bg_gutter = "none" - } - } - }, - }, - overrides = function(colors) - local theme = colors.theme - return { - TelescopeTitle = { bold = true }, - TelescopePromptNormal = { bg = theme.ui.bg_p1, fg = "none" }, - TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = "none" }, - TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = "none" }, - TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = "none" }, - TelescopePreviewNormal = { bg = theme.ui.bg_dim }, - -- TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim }, - -- NormalFloat = { bg = "none" }, - LineNr = { bg = "none" }, - CursorLineNr = { bg = "none" }, - GitsignsAdd = { bg = "none" }, - GitSignsChange = { bg = "none" }, - GitsignsDelete = { bg = "none" }, - } - end, - background = { - dark = "dragon", - }, - }) - - require("tokyonight").setup({ - style = "moon", - light_style = "night", - transparent = ui.transparency, - terminal_colors = true, - styles = { - comments = { italic = true }, - keywords = { italic = true }, - functions = { italic = true }, - variables = { italic = true }, - sidebars = "dark", - floats = "dark", - }, - sidebars = { "qf", "help" }, - day_brightness = 0.3, - hide_inactive_statusline = true, - dim_inactive = true, - lualine_bold = true, - }) - - require("catppuccin").setup({ - flavour = "mocha", - background = { - dark = "mocha", - }, - transparent_background = ui.transparency, - show_end_of_buffer = false, - term_colors = true, - dim_inactive = { - enabled = false, - shade = "light", - percentage = 0.10, - }, - styles = { - comments = { "italic" }, - conditionals = { "italic" }, - loops = { "reverse" }, - functions = { "italic" }, - keywords = {}, - strings = {}, - variables = { "italic" }, - numbers = {}, - booleans = { "italic" }, - properties = {}, - types = {}, - operators = {}, - }, - integrations = { - cmp = true, - gitsigns = true, - nvimtree = true, - treesitter = true, - notify = true, - neogit = true, - treesitter_context = true, - ts_rainbow2 = true, - ts_rainbow = true, - telescope = { - enabled = true, - style = "nvchad", - }, - native_lsp = { - enabled = true, - underlines = { - errors = { "undercurl" }, - hints = { "undercurl" }, - warnings = { "undercurl" }, - information = { "undercurl" }, - }, - }, - }, - }) - - vim.cmd("colorscheme " .. ui.theme) -end - -return M diff --git a/lua/plugin/config/dashboard.lua b/lua/plugin/config/dashboard.lua deleted file mode 100644 index 4725c09..0000000 --- a/lua/plugin/config/dashboard.lua +++ /dev/null @@ -1,29 +0,0 @@ -local M = {} -local alpha = require('alpha') -local dashboard = require('alpha.themes.dashboard') - -function M.setup() - dashboard.section.header.val = require('core.default_config').options.figlet_name - - dashboard.section.buttons.val = { - dashboard.button("e", " New File", ":ene startinsert "), - dashboard.button("LDR ?", " Recently Opened Files", ":Telescope oldfiles"), - dashboard.button("LDR n", "📁 File Explorer", ":NvimTreeOpen"), - dashboard.button("LDR sf", "🔍 Search Files", ":Telescope find_files"), - dashboard.button("LDR sg", " Search Grep", ":Telescope live_grep"), - dashboard.button("LDR gb", " Git Branches", ":Telescope git_branches"), - dashboard.button("LDR gc", " Git Commits", ":Telescope git_commits"), - dashboard.button("LDR en", "📝 Neovim Edit", ":lua require('plugin.config.telescope').edit_neovim()"), - dashboard.button("q", " Quit NVIM", ":qa"), - } - - dashboard.section.footer.val = "Total plugins: " .. require("lazy").stats().count - dashboard.section.header.opts.hl = "Include" - dashboard.section.buttons.opts.hl = "Keyword" - dashboard.opts.opts.noautocmd = true - - - alpha.setup(dashboard.opts) -end - -return M diff --git a/lua/plugin/config/diffview.lua b/lua/plugin/config/diffview.lua deleted file mode 100644 index d807c04..0000000 --- a/lua/plugin/config/diffview.lua +++ /dev/null @@ -1,34 +0,0 @@ -local lib = require("diffview.lib") -local diffview = require("diffview") - -local M = {} - -M.toggle_file_history = function() - local view = lib.get_current_view() - if view == nil then ----@diagnostic disable-next-line: missing-parameter - diffview.file_history(); - return - end - - if view then - view:close() - lib.dispose_view(view) - end -end - -M.toggle_status = function() - local view = lib.get_current_view() - if view == nil then ----@diagnostic disable-next-line: missing-parameter - diffview.open(); - return - end - - if view then - view:close() - lib.dispose_view(view) - end -end - -return M diff --git a/lua/plugin/config/gitsigns.lua b/lua/plugin/config/gitsigns.lua deleted file mode 100644 index 35016f7..0000000 --- a/lua/plugin/config/gitsigns.lua +++ /dev/null @@ -1,70 +0,0 @@ -local M = {} -local status, gitsigns = pcall(require, 'gitsigns') -function M.setup() - if (not status) then return end - - gitsigns.setup { - signs = { - add = { - -- text = '+', - text = "▎", - hl = "GitSignsAdd", - numhl = "GitSignsAddNr", - linehl = "GitSignsAddLn", - }, - delete = { - -- text = "-", - text = "_", - hl = "GitSignsDelete", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - change = { - -- text = "±", - text = "▎", - hl = "GitSignsChange", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - changedelete = { - -- text = '~', - text = "▎", - hl = "GitSignsDelete", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - topdelete = { - text = '‾', - hl = "GitSignsDelete", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - }, - numhl = false, - linehl = false, - watch_gitdir = { - interval = 1000, - follow_files = true, - }, - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "eol", - delay = 1000, - ignore_whitespace = false - }, - current_line_blame_formatter_opts = { relative_time = true }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, - max_file_length = 40000, - preview_config = { - border = "shadow", - style = "minimal", - relative = "cursor", - row = 0, - col = 1 - } - } -end - -return M diff --git a/lua/plugin/config/hop.lua b/lua/plugin/config/hop.lua deleted file mode 100644 index 9bde284..0000000 --- a/lua/plugin/config/hop.lua +++ /dev/null @@ -1,56 +0,0 @@ -local M = {} -local keymap = require("core.default_config").keymap - -function M.setup() - local hop = require('hop') - hop.setup { - term_seq_bias = 0.5, - keys = 'etovxqpdygfblzhckisuran', - } - local directions = require('hop.hint').HintDirection - -- keymap({ 'n', 'v' }, 'f', - -- function() - -- hop.hint_char1({ - -- direction = directions.AFTER_CURSOR, - -- current_line_only = true, - -- }) - -- end, - -- { remap = true }) - -- keymap({ 'n', 'v' }, 'F', - -- function() - -- hop.hint_char1( - -- { - -- direction = directions.BEFORE_CURSOR, - -- current_line_only = true, - -- } - -- ) - -- end, - -- { remap = true }) - -- keymap({ 'n', 'v' }, 't', - -- function() - -- hop.hint_char1( - -- { - -- direction = directions.AFTER_CURSOR, - -- current_line_only = true, - -- hint_offset = -1, - -- } - -- ) - -- end, - -- { remap = true }) - -- keymap({ 'n', 'v' }, 'T', - -- function() - -- hop.hint_char1({ - -- direction = directions.BEFORE_CURSOR, - -- current_line_only = true, - -- hint_offset = 1, - -- }) - -- end, - -- { remap = true }) - -- keymap({ 'n', 'v' }, 'w', function() hop.hint_words() end, {}) - -- keymap({ 'n', 'v' }, 'k', function() hop.hint_lines() end, {}) - -- keymap('n', 'c', function() hop.hint_char1() end, {}) - -- keymap('n', 'C', function() hop.hint_char2() end, {}) - -- keymap('n', 'm', function() hop.hint_patterns() end, {}) -end - -return M diff --git a/lua/plugin/config/lastplace.lua b/lua/plugin/config/lastplace.lua deleted file mode 100644 index 238f25e..0000000 --- a/lua/plugin/config/lastplace.lua +++ /dev/null @@ -1,23 +0,0 @@ -local M = {} -local status, lastplace = pcall(require, "nvim-lastplace") - -function M.setup() - if (not status) then return end - - lastplace.setup({ - lastplace_ignore_buftype = { - "quickfix", - "nofile", - "help", - }, - lastplace_ignore_filetype = { - "gitcommit", - "gitrebase", - "svn", - "hgcommit", - }, - lastplace_open_folds = true, - }) -end - -return M diff --git a/lua/plugin/config/legendary.lua b/lua/plugin/config/legendary.lua deleted file mode 100644 index e7320a7..0000000 --- a/lua/plugin/config/legendary.lua +++ /dev/null @@ -1,150 +0,0 @@ -local M = {} -local telescope_builtin = require('telescope.builtin') -local gs = require('gitsigns') - -function M.setup() - require('legendary').setup({ - keymaps = { - { 'n', ':NvimTreeToggle', description = '[N]vimTree Toggle' }, - { '', ':nohlsearch', description = 'No Highlights Search' }, - { ';', ':Legendary', description = '[:] Legendary Commands' }, - -- Telescope - { '?', telescope_builtin.oldfiles, description = '[?] Find recently opened files' }, - { 'sf', telescope_builtin.find_files, description = '[S]earch [F]iles' }, - { 'sw', telescope_builtin.grep_string, description = '[S]earch current [W]ord' }, - { 'sg', telescope_builtin.live_grep, description = '[S]earch by [G]rep' }, - { '', telescope_builtin.buffers, description = '[S]earch [B]uffers' }, - { 'sc', function () require('plugin.config.telescope').colorscheme_picker() end, description = '[S]earch [C]olorscheme' }, - { 'so', function () require('plugin.config.telescope').treesitter() end, description = '[S]earch Treesitter Symb[o]ls' }, - { 'ss', telescope_builtin.symbols, description = '[S]earch [S]ymbols' }, - { 'sx', telescope_builtin.resume, description = '[S]earch [X]resume' }, - { 'sd', telescope_builtin.diagnostics, description = '[S]earch [D]iagnostics' }, - { 'sm', telescope_builtin.marks, description = '[S]earch [M]arks' }, - { 'sj', telescope_builtin.jumplist, description = '[S]earch [J]umplists' }, - { 'st', telescope_builtin.tags, description = '[S]earch [T]ags' }, - { '/', require('plugin.config.telescope').current_buffer_fuzzy_find, description = '[/] Fuzzily search in current buffer' }, - { 'en', require('plugin.config.telescope').edit_neovim, description = '[E]dit [N]eovim' }, - { 'gb', telescope_builtin.git_branches, description = '[G]it [B]ranches' }, - { 'gc', telescope_builtin.git_commits, description = '[G]it [B]ranches' }, - { 'gs', telescope_builtin.git_status, description = '[G]it [S]tatus' }, - { 'gt', telescope_builtin.git_stash, description = '[G]it s[T]atus' }, - -- Git signs - { 'hs', gs.stage_hunk, description = 'Stage Hunk', mode = { 'n' } }, - { 'hr', gs.reset_hunk, description = 'Reset Hunk', mode = { 'n' } }, - { 'hs', function() gs.stage_hunk { vim.fn.line("."), vim.fn.line("v") } end, description = 'Stage Hunk (Visual)', mode = { 'v' } }, - { 'hr', function() gs.reset_hunk { vim.fn.line("."), vim.fn.line("v") } end, description = 'Reset Hunk (Visual)', mode = { 'v' } }, - { 'hs', gs.stage_buffer, description = 'Stage Buffer', mode = { 'n' } }, - { 'hu', gs.undo_stage_hunk, description = 'Undo Stage Hunk', mode = { 'n' } }, - { 'hr', gs.reset_buffer, description = 'Reset Buffer', mode = { 'n' } }, - { 'hp', gs.preview_hunk, description = 'Preview Hunk', mode = { 'n' } }, - { 'hb', function() gs.blame_line { full = true } end, description = 'Blame Line', mode = { 'n' } }, - { 'tb', gs.toggle_current_line_blame, description = 'Toggle Current Line Blame', mode = { 'n' } }, - { 'hd', gs.diffthis, description = 'Diff This', mode = { 'v', 'n' } }, - { 'hd', function() gs.diffthis('~') end, description = 'Diff This (Visual)', mode = { 'n' } }, - { 'td', gs.toggle_deleted, description = 'Toggle Deleted', mode = { 'n' } }, - -- Command Pallet - { 'cp', require('legendary').find, description = '[C]ommand [P]allet', mode = {'n', 'v'} }, - -- LSP - { - 'K', - function() - local winid = require('ufo').peekFoldedLinesUnderCursor() - if not winid then - vim.lsp.buf.hover() - end - end, description = 'Hover Documentation', mode = { 'n' } }, - -- UFO - { 'zR', require('ufo').openAllFolds, description = 'Open All Folds', mode = { 'n' } }, - { 'zM', require('ufo').closeAllFolds, description = 'Close All Folds', mode = { 'n' } }, - { 'zr', require('ufo').openFoldsExceptKinds, description = 'Open Folds Except Kinds', mode = { 'n' } }, - { 'zm', require('ufo').closeFoldsWith, description = 'Open Folds With', mode = { 'n' } }, - { 'gD', vim.lsp.buf.declaration, description = '[G]oto [D]eclaration', mode = { 'n' } }, - { 'gI', vim.lsp.buf.implementation, description = '[G]oto [I]mplementation', mode = { 'n' } }, - { 'gd', telescope_builtin.lsp_definitions, description = '[G]oto [D]efinition', mode = { 'n' } }, - { 'gr', telescope_builtin.lsp_references, description = '[G]oto [R]eferences', mode = { 'n' } }, - { 'gs', vim.lsp.buf.signature_help, description = '[G]oto [S]ignature', mode = { 'n' } }, - { 'rn', vim.lsp.buf.rename, description = '[R]e[n]ame', mode = { 'n' } }, - { 'ca', vim.lsp.buf.code_action, description = '[C]ode [A]ction', mode = { 'n' } }, - { 'l', ':Neogit', description = 'NeoGit', mode = { 'n' } }, - { 'L', ':Neogit commit', description = 'NeoGit', mode = { 'n' } }, - -- Split - { 'j', require('treesj.').toggle, description = 'Toggle Split or Join', mode = { 'n' } }, - { 'k', ':ISwap', description = 'Swap', mode = { 'n', 'v' } }, - }, - commands = { - { ':Format', function() vim.lsp.buf.format({async = true}) end, description = 'Format current buffer with LSP', mode = { 'n', 'v', 'x' } }, - { ':ToggleLspLine', function() require('lsp_lines').toggle() end, description = 'Toggle lsp_lines', mode = { 'n' } }, - { - ':ToggleBlameLine', - function() - gs.toggle_current_line_blame() - end, - description = 'Toggle Current Line Blame', - mode = { 'n' } - }, - { ':DiffThis', function() gs.diffthis() end, description = 'Diff this', mode = { 'n' } }, - { ':DiffView', function() gs.diffthis('~') end, description = 'Diff View', mode = { 'n' } }, - { - ':TSJSplit', - function() - require('treesj').split() - end, - description = 'Split Lines', - mode = { 'n' }, - }, - { - ':TSJJoin', - function() - require('treesj').join() - end, - description = 'Join Lines', - mode = { 'n' }, - }, - { - ':LuaSnipEdit', - function() - require('luasnip.loaders.from_lua').edit_snippet_files() - end, - description = 'Edit Snippets Files', - mode = { 'n' }, - }, - { - ':Notifi', - ':Telescope notify', - description = 'Notify', - mode = { 'n' } - }, - { - ':HlangsToggle', - function () - require('hlargs').toggle() - end, - description = 'Hlangs Toggle' - }, - { - ':Sad', - ':Sad', - description = 'Space Age seD' - } - }, - extensions = { - lazy_nvim = { - auto_register = true - }, - nvim_tree = false, - smart_splits = { - directions = { 'h', 'j', 'k', 'l' }, - mods = { - move = '', - resize = '', - swap = { - mod = '', - prefix = '', - }, - }, - }, - }, - }) -end - -return M diff --git a/lua/plugin/config/lsp-signature.lua b/lua/plugin/config/lsp-signature.lua deleted file mode 100644 index d58211d..0000000 --- a/lua/plugin/config/lsp-signature.lua +++ /dev/null @@ -1,68 +0,0 @@ -local cfg = { - debug = false, -- set to true to enable debug logging - log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log", -- log dir when debug is on - -- default is ~/.cache/nvim/lsp_signature.log - verbose = false, -- show debug line number - - bind = true, -- This is mandatory, otherwise border config won't get registered. - -- If you want to hook lspsaga or other signature handler, pls set to false - doc_lines = 10, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated); - -- set to 0 if you DO NOT want any API comments be shown - -- This setting only take effect in insert mode, it does not affect signature help in normal - -- mode, 10 by default - - max_height = 12, -- max height of signature floating_window - max_width = 80, -- max_width of signature floating_window - noice = false, -- set to true if you using noice to render markdown - wrap = true, -- allow doc/signature text wrap inside floating_window, useful if your lsp return doc/sig is too long - - floating_window = true, -- show hint in a floating window, set to false for virtual text only mode - - floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note: - -- will set to true when fully tested, set to false will use whichever side has more space - -- this setting will be helpful if you do not want the PUM and floating win overlap - - floating_window_off_x = 1, -- adjust float windows x position. - -- can be either a number or function - floating_window_off_y = -5, -- adjust float windows y position. e.g -2 move window up 2 lines; 2 move down 2 lines - -- can be either number or function, see examples - - close_timeout = 4000, -- close floating window after ms when laster parameter is entered - fix_pos = true, -- set to true, the floating window will not auto-close until finish all parameters - hint_enable = true, -- virtual hint enable - hint_prefix = " ", -- Symbol for parameter - hint_scheme = "String", - hint_inline = function() - return false - end, -- should the hint be inline(nvim 0.10 only)? default false - hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight - handler_opts = { - border = "rounded", -- double, rounded, single, shadow, none, or a table of borders - }, - - always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58 - - auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil. - extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","} - zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom - - padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc - - transparency = nil, -- disabled by default, allow floating win transparent value 1~100 - shadow_blend = 36, -- if you using shadow as border use this set the opacity - shadow_guibg = "Black", -- if you using shadow as border use this set the color e.g. 'Green' or '#121315' - timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency - toggle_key = nil, -- toggle signature on and off in insert mode, e.g. toggle_key = '' - toggle_key_flip_floatwin_setting = false, -- true: toggle float setting after toggle key pressed - - select_signature_key = nil, -- cycle to next signature, e.g. '' function overloading - move_cursor_key = nil, -- imap, use nvim_set_current_win to move cursor between current win and floating -} - --- recommended: -require("lsp_signature").setup(cfg) - --- Colour changes for popup window in LspSignature -vim.api.nvim_set_hl(0, "LspSignatureActiveParameter", { bg = "#45403d", fg = "NONE" }) -vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#282828", fg = "NONE" }) -vim.api.nvim_set_hl(0, "FloatBorder", { bg = "#282828", fg = "NONE" }) diff --git a/lua/plugin/config/lsp.lua b/lua/plugin/config/lsp.lua deleted file mode 100644 index 2a6fb0e..0000000 --- a/lua/plugin/config/lsp.lua +++ /dev/null @@ -1,243 +0,0 @@ -local M = {} - -local servers = { - -- gopls = {}, - -- pylsp = {}, - ruff_lsp = {}, - tsserver = {}, - rust_analyzer = {}, - jsonls = { - settings = { - json = { - schemas = { - - { - fileMatch = { "package.json" }, - url = "https://json.schemastore.org/package.json", - }, - { - fileMatch = { "tsconfig*.json" }, - url = "https://json.schemastore.org/tsconfig.json", - }, - { - fileMatch = { - ".prettierrc", - ".prettierrc.json", - "prettier.config.json", - }, - url = "https://json.schemastore.org/prettierrc.json", - }, - { - fileMatch = { ".eslintrc", ".eslintrc.json" }, - url = "https://json.schemastore.org/eslintrc.json", - }, - { - fileMatch = { - ".babelrc", - ".babelrc.json", - "babel.config.json", - }, - url = "https://json.schemastore.org/babelrc.json", - }, - { - fileMatch = { "lerna.json" }, - url = "https://json.schemastore.org/lerna.json", - }, - { - fileMatch = { "now.json", "vercel.json" }, - url = "https://json.schemastore.org/now.json", - }, - { - fileMatch = { - ".stylelintrc", - ".stylelintrc.json", - "stylelint.config.json", - }, - url = "http://json.schemastore.org/stylelintrc.json", - }, - }, - }, - }, - }, - lua_ls = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - }, - }, - }, - ltex = { - filetypes = { - "bib", - "gitcommit", - "markdown", - "org", - "plaintex", - "rst", - "rnoweb", - "tex", - "pandoc", - "rust", - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - "lua", - "python", - "html", - }, - settings = { - ltex = { - enabled = { - "bib", - "gitcommit", - "markdown", - "org", - "plaintex", - "rst", - "rnoweb", - "tex", - "pandoc", - "rust", - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - "lua", - "python", - "html", - }, - additionalRules = { - languageModel = "~/ngrams/", - checkFrequency = "save", - } - } - } - }, -} - -local on_attach = function(_, bufnr) - vim.fn.sign_define("DiagnosticSignError", { text = " ", texthl = "DiagnosticSignError", numhl = "" }) - vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn", numhl = "" }) - vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo", numhl = "" }) - - if vim.lsp.setup then - vim.lsp.setup { - floating_preview = { border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" } }, - diagnostics = { - signs = { error = " ", warning = " ", hint = " ", information = " " }, - display = { - underline = true, - update_in_insert = false, - -- virtual_text = { spacing = 4, prefix = "●" }, - virtual_text = false, - severity_sort = true, - }, - }, - completion = { - kind = { - Class = " ", - Color = " ", - Constant = " ", - Constructor = " ", - Enum = "了 ", - EnumMember = " ", - Field = " ", - File = " ", - Folder = " ", - Function = " ", - Interface = "ﰮ ", - Keyword = " ", - Method = "ƒ ", - Module = " ", - Property = " ", - Snippet = "﬌ ", - Struct = " ", - Text = " ", - Unit = " ", - Value = " ", - Variable = " ", - }, - }, - } - else - end - - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) - end - - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - - nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - -- nmap('D', vim.lsp.buf.type_definition, '[T]ype [D]efinition') - -- nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - -- nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - -- nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - -- nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - -- nmap('wl', function() - -- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - -- end, '[W]orkspace [L]ist Folders') -end - -function M.setup() - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - capabilities.textDocument.completion.completionItem.preselectSupport = true - capabilities.textDocument.completion.completionItem.insertReplaceSupport = true - capabilities.textDocument.completion.completionItem.labelDetailsSupport = true - capabilities.textDocument.completion.completionItem.deprecatedSupport = true - capabilities.textDocument.completion.completionItem.commitCharactersSupport = true - capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } } - capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities.textDocument.completion.completionItem.resolveSupport = { - properties = { "documentation", "detail", "additionalTextEdits" }, - } - capabilities.textDocument.foldingRange = { - dynamicRegistration = false, - lineFoldingOnly = true - } - - -- Setup mason so it can manage external tooling - require('mason').setup() - - -- Ensure the servers above are installed - local mason_lspconfig = require 'mason-lspconfig' - - mason_lspconfig.setup { - ensure_installed = vim.tbl_keys(servers), - } - - mason_lspconfig.setup_handlers { - function(server_name) - require('lspconfig')[server_name].setup { - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - } - end, - } - -- Turn on lsp status information - require('fidget').setup() -end - -return M diff --git a/lua/plugin/config/manson-tool-installer.lua b/lua/plugin/config/manson-tool-installer.lua deleted file mode 100644 index 777eb18..0000000 --- a/lua/plugin/config/manson-tool-installer.lua +++ /dev/null @@ -1,17 +0,0 @@ -local M = {} - -function M.setup() - require("mason-tool-installer").setup({ - ensure_installed = { - "lua-language-server", - "typescript-language-server", - }, - auto_update = true, - run_on_start = true, - start_delay = 0, -- 3 second delay - debounce_hours = 24, -- at least 24 hours between attempts to install/update - }) - vim.cmd("MasonToolsUpdate") -end - -return M diff --git a/lua/plugin/config/modes.lua b/lua/plugin/config/modes.lua deleted file mode 100644 index 1c03216..0000000 --- a/lua/plugin/config/modes.lua +++ /dev/null @@ -1,24 +0,0 @@ -local M = {} - -function M.setup() - require("modes").setup({ - colors = { - normal = "#ffcb6b", - insert = "#c3e88d", - delete = "#f07178", - copy = "#f78c6c", - visual = "#82aaff", - }, - line_opacity = 0.25, - set_cursor = true, - ignore_filetypes = { - "alpha", - "NvimTree", - "TelescopePrompt", - "NeogitStatus", - "NeogitPopup", - } - }) -end - -return M diff --git a/lua/plugin/config/neogit.lua b/lua/plugin/config/neogit.lua deleted file mode 100644 index 1112f1b..0000000 --- a/lua/plugin/config/neogit.lua +++ /dev/null @@ -1,15 +0,0 @@ -local M = {} -local neogit = require('neogit') - -function M.setup() - neogit.setup { - kind = "vsplit", - integrations = { - telescope = true, - diffview = true, - - } - } -end - -return M diff --git a/lua/plugin/config/notification.lua b/lua/plugin/config/notification.lua deleted file mode 100644 index a356cc1..0000000 --- a/lua/plugin/config/notification.lua +++ /dev/null @@ -1,39 +0,0 @@ -local M = {} -local status, notify = pcall(require, "notify") - -function M.setup() - if (not status) then return end - notify.setup({ - stages = "fade_in_slide_out", - render = "compact", - timeout = 1500, - fps = 20, - max_height = function() - return math.floor(vim.o.lines * 0.75) - end, - max_width = function() - return math.floor(vim.o.columns * 0.75) - end, - background_colour = "#000000", - minimum_width = 26, - icons = { - ERROR = "", - WARN = "", - INFO = "", - DEBUG = "", - TRACE = "✎", - } - }) - vim.notify = notify -end - -function M.info(msg) - vim.notify(" => INFO: " .. msg, vim.log.levels.INFO) -end - -function M.error(title, msg) - vim.api.nvim_echo({ { " => ERROR: " .. title, "ErrorMsg" } }, true, {}) - vim.notify(msg, vim.log.levels.ERROR) -end - -return M diff --git a/lua/plugin/config/relativenumber.lua b/lua/plugin/config/relativenumber.lua deleted file mode 100644 index cb4b78d..0000000 --- a/lua/plugin/config/relativenumber.lua +++ /dev/null @@ -1,27 +0,0 @@ -local M = {} -local status, relativetoggle = pcall(require, "relative-toggle") - -function M.setup() - if (not status) then return end - relativetoggle.setup({ - pattern = "*", - events = { - on = { - "BufEnter", - "FocusGained", - "InsertLeave", - "WinEnter", - "CmdlineLeave", - }, - off = { - "BufLeave", - "FocusLost", - "InsertEnter", - "WinLeave", - "CmdlineEnter", - }, - }, - }) -end - -return M diff --git a/lua/plugin/config/rest.lua b/lua/plugin/config/rest.lua deleted file mode 100644 index 3ca77c9..0000000 --- a/lua/plugin/config/rest.lua +++ /dev/null @@ -1,37 +0,0 @@ -local M = {} - -local status, restnv = pcall(require, "rest-nvim") - -function M.setup() - restnv.setup({ - result_split_horizontal = false, - highlight = { enabled = true, timeout = 150 }, - result = { - show_url = true, - show_http_info = true, - show_headers = true, - formatters = { - json = "jq", - html = function(body) - return vim.fn.system({ "tidy", "-i", "-q", "-" }, body) - end - } - }, - jump_to_request = true, - }) - local rest_nvim = require('rest-nvim') - vim.api.nvim_create_autocmd("FileType", { - pattern = "http", - callback = function() - local buff = tonumber(vim.fn.expand(""), 10) - vim.keymap.set("n", "rn", rest_nvim.run, - { noremap = true, buffer = buff }) - vim.keymap.set("n", "rl", rest_nvim.last, - { noremap = true, buffer = buff }) - vim.keymap.set("n", "rp", function() rest_nvim.run(true) end, - { noremap = true, buffer = buff }) - end - }) -end - -return M diff --git a/lua/plugin/config/smartsplit.lua b/lua/plugin/config/smartsplit.lua deleted file mode 100644 index 8d9326d..0000000 --- a/lua/plugin/config/smartsplit.lua +++ /dev/null @@ -1,21 +0,0 @@ -local M = {} -local status, smart_splits = pcall(require, "smart-splits") - -function M.setup() - smart_splits.setup { - ignored_filetypes = { - 'nofile', - 'quickfix', - 'prompt', - }, - ignored_buftypes = { 'NvimTree' }, - resize_mode = { - silent = true, - hooks = { - on_leave = require("bufresize").register - } - } - } -end - -return M diff --git a/lua/plugin/config/smoothcursor.lua b/lua/plugin/config/smoothcursor.lua deleted file mode 100644 index 7d7e385..0000000 --- a/lua/plugin/config/smoothcursor.lua +++ /dev/null @@ -1,18 +0,0 @@ -local M = {} - -function M.setup() - require("smoothcursor").setup({ - cursor = "", - disable_float_win = true, - fancy = { - enable = true, - head = { - cursor = "", - texthl = "SmoothCursor", - linehl = "cursorline", - } - } - }) -end - -return M diff --git a/lua/plugin/config/treesitter.lua b/lua/plugin/config/treesitter.lua deleted file mode 100644 index afbf6cb..0000000 --- a/lua/plugin/config/treesitter.lua +++ /dev/null @@ -1,116 +0,0 @@ -local M = {} -local status, ts = pcall(require, "nvim-treesitter.configs") -local parser_config = require "nvim-treesitter.parsers".get_parser_configs() - -function M.setup() - if (not status) then return end - ts.setup { - ensure_installed = { - "cpp", - "python", - "html", - "javascript", - "typescript", - "json", - "json5", - "jsonc", - "go", - "gomod", - "bash", - "lua", - "luadoc", - "luap", - "comment", - "markdown", - "markdown_inline", - "glimmer", - "regex", - "vim", - "vimdoc", - "yaml", - "toml", - "tsx", - "css", - "scss", - "dockerfile", - }, - sync_install = false, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - disable = { "cpp", "latex" }, - }, - indent = { - enable = { "javascriptreact" }, - disable = { 'python' }, - }, - autotag = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - rainbow = { - enable = true, - extendend_mode = true, - max_file_lines = 1000, - query = 'rainbow-parens', - strategy = require('ts-rainbow').strategy.global, - }, - context_commentstring = { - enable = true, - enable_autocmd = false - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, - } - parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" } -end - -return M diff --git a/lua/plugin/config/treesj.lua b/lua/plugin/config/treesj.lua deleted file mode 100644 index 960566b..0000000 --- a/lua/plugin/config/treesj.lua +++ /dev/null @@ -1,12 +0,0 @@ -local M = {} - -function M.setup() - require('treesj').setup({ - notify = true, - dot_repeat = false, - max_join_length = 500, - use_default_keymaps = false, - }) -end - -return M diff --git a/lua/plugin/config/typescript-tools.lua b/lua/plugin/config/typescript-tools.lua deleted file mode 100644 index 91f75f1..0000000 --- a/lua/plugin/config/typescript-tools.lua +++ /dev/null @@ -1,195 +0,0 @@ -local M = {} -local methods = vim.lsp.protocol.Methods -local baseDefinitionHandler = vim.lsp.handlers["textDocument/definition"] - -local filter = require("lsp.utils.filter").filter -local filterReactDTS = require("lsp.utils.filterReactDTS").filterReactDTS - -local handlers = { - ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - silent = true, - border = EcoVim.ui.float.border, - }), - ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = EcoVim.ui.float.border }), - ["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, - { virtual_text = EcoVim.lsp.virtual_text } - ), - ["textDocument/definition"] = function(err, result, method, ...) - P(result) - if vim.tbl_islist(result) and #result > 1 then - local filtered_result = filter(result, filterReactDTS) - return baseDefinitionHandler(err, filtered_result, method, ...) - end - - baseDefinitionHandler(err, result, method, ...) - end, -} - - --- Toggle format on save. -local autoformat = true -vim.api.nvim_create_user_command('ToggleAutoFormat', function() - autoformat = not autoformat -end, {}) - ----@param bufnr integer -local function format(bufnr) - if not autoformat then - return - end - - local clients = vim.lsp.get_clients { - bufnr = bufnr, - method = methods.textDocument_formatting or methods.textDocument_rangeFormatting, - } - - -- Prioritize formatting with EFM. - local name = nil - if vim.tbl_contains(clients, function(client) - return client.name == 'efm' - end) then - name = 'efm' - end - - if #clients == 0 then - return - end - - vim.lsp.buf.format { - bufnr = bufnr, - name = name, - async = #clients == 1, - } -end - ----@param bufnr number -local function setup_inlay_hints(bufnr) - local inlay_hints_group = vim.api.nvim_create_augroup('ToggleInlayHints', { clear = false }) - - -- Initial inlay hint display. - -- Idk why but without the delay inlay hints aren't displayed at the very start. - vim.defer_fn(function() - local mode = vim.api.nvim_get_mode().mode - vim.lsp.inlay_hint(bufnr, mode == 'n' or mode == 'v') - end, 500) - - vim.api.nvim_create_autocmd('InsertEnter', { - group = inlay_hints_group, - buffer = bufnr, - callback = function() - vim.lsp.inlay_hint(bufnr, false) - end, - }) - vim.api.nvim_create_autocmd('InsertLeave', { - group = inlay_hints_group, - buffer = bufnr, - callback = function() - vim.lsp.inlay_hint(bufnr, true) - end, - }) -end - - -function M.on_attach(buf_client, bufnr) - local function keymap(lhs, rhs, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = desc }) - end - - if buf_client.supports_method(methods.textDocument_codeAction) then - keymap('ca', vim.lsp.buf.code_action, 'Code action', { 'n', 'v' }) - end - - if buf_client.supports_method(methods.textDocument_rename) then - vim.keymap.set('n', 'cr', vim.lsp.buf.rename, { desc = 'Rename' }) - end - - if buf_client.supports_method(methods.textDocument_definition) then - keymap('gd', function() - require('telescope.builtin').lsp_definitions { reuse_win = true } - end, 'Go to definition') - end - - if buf_client.supports_method(methods.textDocument_signatureHelp) then - keymap('', vim.lsp.buf.signature_help, 'Signature help', 'i') - end - - keymap('gr', 'Telescope lsp_references', 'Go to references') - keymap('gI', function() - require('telescope.builtin').lsp_implementations { reuse_win = true } - end, 'Go to implementation') - keymap('gD', function() - require('telescope.builtin').lsp_type_definitions { reuse_win = true } - end, 'Go to type definition') - - keymap('td', function() - require('telescope.builtin').lsp_document_symbols() - end, 'Document symbols') - keymap('tw', function() - require('telescope.builtin').lsp_dynamic_workspace_symbols() - end, 'Workspace symbols') - - keymap('cd', vim.diagnostic.open_float, 'Line diagnostics') - keymap('[d', vim.diagnostic.goto_prev, 'Previous diagnostic') - keymap(']d', vim.diagnostic.goto_next, 'Next diagnostic') - keymap('[e', function() - vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.ERROR } - end, 'Previous error') - keymap(']e', function() - vim.diagnostic.goto_next { severity = vim.diagnostic.severity.ERROR } - end, 'Next error') - - -- noice deals with the UI. - keymap('K', vim.lsp.buf.hover, 'Hover') - - -- Enable inlay hints if the client supports it. - if buf_client.supports_method(methods.textDocument_inlayHint) then - setup_inlay_hints(bufnr) - end - - -- Set up format on save for some file types and specific projects. - local local_fmt_command = vim.g.format_command - if local_fmt_command then - vim.keymap.set('n', 'cf', function() - local cursor = vim.api.nvim_win_get_cursor(0) - vim.cmd(local_fmt_command) - cursor[1] = math.min(cursor[1], vim.api.nvim_buf_line_count(0)) - vim.api.nvim_win_set_cursor(0, cursor) - end, { desc = 'Format buffer' }) - end - if vim.tbl_contains({ 'lua', 'rust' }, vim.bo[bufnr].filetype) then - vim.api.nvim_create_autocmd('BufWritePre', { - buffer = bufnr, - group = vim.api.nvim_create_augroup('FormatOnSave', { clear = false }), - callback = function() - format(bufnr) - end, - }) - end -end - -function M.setup() - require("typescript-tools").setup({ - on_attach = function(client, bufnr) - if vim.fn.has("nvim-0.10") then - -- Enable inlay hints - vim.lsp.inlay_hint(bufnr, true) - end - end, - handlers = handlers, - settings = { - tsserver_plugins = { - "@styled/typescript-styled-plugin", - }, - separate_diagnostic_server = true, - tsserver_file_preferences = { - includeInlayParameterNameHints = "all", - includeCompletionsForModuleExports = true, - quotePreference = "auto", - }, - }, - }) -end - -return M diff --git a/lua/plugin/config/ufo.lua b/lua/plugin/config/ufo.lua deleted file mode 100644 index f8612c1..0000000 --- a/lua/plugin/config/ufo.lua +++ /dev/null @@ -1,62 +0,0 @@ -local M = {} - -local handler = function(virtText, lnum, endLnum, width, truncate) - local newVirtText = {} - local suffix = ('  %d '):format(endLnum - lnum) - local lines = ('[%d lines] '):format(endLnum - lnum) - local sufWidth = vim.fn.strdisplaywidth(suffix) - local targetWidth = width - sufWidth - local curWidth = 0 - for _, chunk in ipairs(virtText) do - local chunkText = chunk[1] - local chunkWidth = vim.fn.strdisplaywidth(chunkText) - if targetWidth > curWidth + chunkWidth then - table.insert(newVirtText, chunk) - else - chunkText = truncate(chunkText, targetWidth - curWidth) - local hlGroup = chunk[2] - table.insert(newVirtText, { chunkText, hlGroup }) - chunkWidth = vim.fn.strdisplaywidth(chunkText) - if curWidth + chunkWidth < targetWidth then - suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth) - end - break - end - curWidth = curWidth + chunkWidth - end - table.insert(newVirtText, { suffix, 'MoreMsg' }) - table.insert(virtText, { suffix, 'Comment' }) - table.insert(virtText, { lines, 'Todo' }) - return newVirtText -end - - -function M.setup() - require('ufo').setup({ - fold_virt_text_handler = handler, - provider_selector = function(bufnr, filetype, buftype) - return { - 'treesitter', - 'indent', - } - end, - preview = { - win_config = { - border = { - "┏", - "━", - "┓", - "┃", - "┛", - "━", - "┗", - "┃", - }, - winblend = 0, - winhighlight = "Normal:Folded", - } - } - }) -end - -return M diff --git a/lua/plugin/init.lua b/lua/plugin/init.lua deleted file mode 100644 index 33b1920..0000000 --- a/lua/plugin/init.lua +++ /dev/null @@ -1,518 +0,0 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - local success, maybe_error = pcall( - vim.fn.system, { - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - } - ) - if not success then - require('plugin.config.notification').error("ERROR: Fail to install plugin manager lazy.nvim", maybe_error) - require('plugin.config.notification').info("You can cleanup the " .. lazypath .. " and start again") - return - end -end -vim.opt.rtp:prepend(lazypath) - -local plugins = { - { - "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - { - "folke/neodev.nvim", - config = function() - require("neodev").setup() - end - }, - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - { - "j-hui/fidget.nvim", - branch = "legacy" - }, - { - "https://git.sr.ht/~whynothugo/lsp_lines.nvim", - config = function() - require("lsp_lines").setup() - end, - }, - }, - config = function() - require("plugin.config.lsp").setup() - end, - cmd = { "Mason" } - }, - { - "pmizio/typescript-tools.nvim", - ft = { "typescript", "typescriptreact" }, - event = { - "BufReadPost", - "BufNewFile", - }, - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-lspconfig", - }, - -- opts = { - -- on_attach = require('plugin.config.typescript-tools').on_attach, - -- settings = { - -- separate_diagnostic_server = true, - -- tsserver_file_preferences = { - -- includeInlayParameterNameHints = 'literals', - -- includeInlayVariableTypeHints = true, - -- includeInlayFunctionLikeReturnTypeHints = true, - -- includeCompletionsForModuleExports = true, - -- quotePreference = "auto", - -- }, - -- }, - -- }, - }, - { - "folke/neoconf.nvim", - cmd = "Neoconf", - config = function() - require("neoconf").setup() - end - }, - { - -- AutoCompletion - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-nvim-lua", - "ray-x/cmp-treesitter", - "lukas-reineke/cmp-rg", - "quangnguyen30192/cmp-nvim-tags", - "andersevenrud/cmp-tmux", - "saadparwaiz1/cmp_luasnip", - "L3MON4D3/LuaSnip", - "rafamadriz/friendly-snippets", - "lukas-reineke/cmp-under-comparator", - { - "honza/vim-snippets", - dependencies = { - "friendly-snippets", - "vim-snippets", - } - } - }, - config = function() - require("plugin.config.cmp").setup() - end - }, - { - -- File Syntax - "nvim-treesitter/nvim-treesitter", - event = { - "BufReadPost", - "BufNewFile", - }, - build = function() - pcall(require("nvim-treesitter.install").update { with_sync = false }) - end, - config = function() - require("plugin.config.treesitter").setup() - end, - dependencies = { - "JoosepAlviste/nvim-ts-context-commentstring", - "nvim-treesitter/nvim-treesitter-textobjects", - "p00f/nvim-ts-rainbow", - "HiPhish/nvim-ts-rainbow2", - "windwp/nvim-ts-autotag", - "mizlan/iswap.nvim", - { - "m-demare/hlargs.nvim", - config = function() - require("hlargs").setup() - end - }, - { - "ZhiyuanLck/smart-pairs", - event = "InsertEnter", - config = function() - require("pairs"):setup() - end - } - } - }, - { - "kevinhwang91/nvim-ufo", - dependencies = "kevinhwang91/promise-async", - event = "BufReadPost", - config = function() - require("plugin.config.ufo").setup() - end - }, - { - "mrjones2014/smart-splits.nvim", - event = "BufEnter", - config = function() - require("plugin.config.smartsplit").setup() - end, - lazy = false, - dependencies = { - "kwkarlwang/bufresize.nvim", - config = function() - require("plugin.config.bufresize").setup() - end - } - }, - { - "lewis6991/gitsigns.nvim", - config = function() - require("plugin.config.gitsigns").setup() - end - }, - { - "NeogitOrg/neogit", - dependencies = { - "nvim-lua/plenary.nvim", - { - "sindrets/diffview.nvim", - lazy = true, - enabled = true, - event = "BufRead", - } - }, - config = function() - require("plugin.config.neogit").setup() - end - }, - - "jiangmiao/auto-pairs", - { "tpope/vim-surround", event = "BufEnter" }, - { "tpope/vim-repeat", event = "BufEnter" }, - - -- colorscheme - { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, - { "Alexis12119/nightly.nvim", name = "nightly", priority = 1000 }, - { "rafamadriz/neon", name = "neon", priority = 1000 }, - { "rebelot/kanagawa.nvim", priority = 1000 }, - { "folke/tokyonight.nvim", priority = 1000 }, - - -- statusline - { - "nvim-lualine/lualine.nvim", - config = function() - require("plugin.config.statusline").setup() - end, - dependencies = { - "kyazdani42/nvim-web-devicons", - } - }, - - { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", - config = function() - require("plugin.config.indent_blankline").setup() - end - }, -- Add indentation guides even on blank lines - - { - "numToStr/Comment.nvim", - config = function() - require("Comment").setup({ - pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook() - }) - end, - dependencies = { - "nvim-ts-context-commentstring", - "JoosepAlviste/nvim-ts-context-commentstring" - } - }, -- "gc" to comment visual regions/lines - - "tpope/vim-sleuth", -- Detect tabstop and shiftwidth automatically - { -- braket and tag - "windwp/nvim-autopairs", - config = function() - require("plugin.config.autopairs").setup() - end - }, - - { - "max397574/better-escape.nvim", - event = "InsertEnter", - config = function() - require("better_escape").setup { - mapping = { "jk" }, -- a table with mappings to use - } - end - }, - - { - -- File manager - "nvim-tree/nvim-tree.lua", - version = "nightly", - event = "VimEnter", - config = function() - require("plugin.config.nvimtree").setup() - end, - dependencies = { - { - "antosha417/nvim-lsp-file-operations", - config = function() - require("lsp-file-operations").setup() - end - } - } - }, - { - -- Notifocation - "rcarriga/nvim-notify", - event = "VeryLazy", - config = function() - require("plugin.config.notification").setup() - end, - lazy = false - }, - - { - -- Bufferline - "akinsho/bufferline.nvim", - version = "v3.*", - config = function() - require("plugin.config.bufferline").setup() - end - }, - - { - -- Telescope - "nvim-telescope/telescope.nvim", - event = { "VimEnter" }, - cmd = { "Telescope" }, - version = "0.1.x", - dependencies = { - "nvim-lua/plenary.nvim", - { - "nvim-telescope/telescope-fzf-native.nvim", - run = "make", - cond = vim.fn.executable "make" == 1, - }, - -- "debugloop/telescope-undo.nvim" - "nvim-telescope/telescope-symbols.nvim", - "desdic/agrolens.nvim", - }, - config = function() - require("plugin.config.telescope").setup() - end - }, - - { - "kevinhwang91/nvim-bqf", - ft = "qf", - cmd = "BqfAutoToggle", - event = "QuickFixCmdPost", - }, - - { - -- Lastplace - "ethanholz/nvim-lastplace", - event = "BufRead", - config = function() - require("plugin.config.lastplace").setup() - end - }, - - { - -- keymaps, commands, and autocommands - "mrjones2014/legendary.nvim", - priority = 10000, - lazy = false, - dependencies = { - "kkharji/sqlite.lua", - { - "stevearc/dressing.nvim", - event = "VeryLazy", - config = function() - require("dressing").setup() - end - } - }, - config = function() - require("plugin.config.legendary").setup() - end - }, - { - "monaqa/dial.nvim", - event = "VeryLazy", - keys = { "", { "", mode = "n" } }, - }, - { - "mvllow/modes.nvim", - event = "VeryLazy", - config = function() - require("plugin.config.modes").setup() - end - }, - - { - "gen740/SmoothCursor.nvim", - event = "VeryLazy", - config = function() - require("plugin.config.smoothcursor").setup() - end - }, - - { - "NTBBloodbath/rest.nvim", - event = "VeryLazy", - dependencies = { - "nvim-lua/plenary.nvim" - }, - config = function() - require("plugin.config.rest").setup() - end - }, - { - "folke/flash.nvim", - event = "VeryLazy", - keys = { - { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, - { "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, - { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, - { - "R", - mode = { "o", "x" }, - function() require("flash").treesitter_search() end, - "Treesitter Search" - }, - { - "", - mode = { "c" }, - function() require("flash").toggle() end, - desc = - "Toggle Flash Search" - }, - }, - }, - - { - -- Dashboard - "goolord/alpha-nvim", - event = "VimEnter", - config = function() - require("plugin.config.dashboard").setup() - end - }, - - { - -- Split - "Wansmer/treesj", - event = "BufWinEnter", - dependencies = { "nvim-treesitter/nvim-treesitter" }, - config = function() - require("plugin.config.treesj").setup() - end, - }, - - { -- tmux nav for nvim - "alexghergh/nvim-tmux-navigation", - event = "VeryLazy", - config = function() - require "nvim-tmux-navigation".setup { - disable_when_zoomed = true, - keybindings = { - left = "", - down = "", - up = "", - right = "", - } - } - end - }, - - { - "cpea2506/relative-toggle.nvim", - config = function() - require("plugin.config.relativenumber").setup() - end - }, - - { - "ray-x/sad.nvim", - event = "VeryLazy", - dependencies = { "ray-x/guihua.lua", run = "cd lua/fzy && make" }, - config = function() - require("sad").setup {} - end, - }, - -- { - -- "akinsho/toggleterm.nvim", - -- lazy = true, - -- cmd = { - -- "ToggleTerm", - -- "ToggleTermSetName", - -- "ToggleTermToggleAll", - -- "ToggleTermSendVisualLines", - -- "ToggleTermSendCurrentLine", - -- "ToggleTermSendVisualSelection", - -- }, - -- config = function() - -- require("toggleterm").setup() - -- end, - -- } -} - -local opts = { - spec = { - { import = "base" }, - { import = "pde" }, - }, - install = { - missing = true, - colorscheme = { - "catppuccin", - "tokyonight", - }, - }, - rtp = { - disabled_plugins = { - "2html_plugin", - "tohtml", - "getscript", - "getscriptPlugin", - "gzip", - "logipat", - "netrw", - "netrwPlugin", - "netrwSettings", - "netrwFileHandlers", - "matchit", - "tar", - "tarPlugin", - "rrhelper", - "spellfile", - "spellfile_plugin", - "vimball", - "vimballPlugin", - "zip", - "zipPlugin", - "tutor", - "rplugin", - "syntax", - "synmenu", - "optwin", - "compiler", - "bugreport", - } - } -} - -require("lazy").setup(plugins, opts) -require("plugin.config.colorscheme").setup() - - -------------------------------- ------------- keymaps ---------- -------------------------------- -require("core.default_config").keymaps.default() diff --git a/lua/plugins/basic.lua b/lua/plugins/basic.lua new file mode 100644 index 0000000..1c7fb10 --- /dev/null +++ b/lua/plugins/basic.lua @@ -0,0 +1,129 @@ +return { + "jiangmiao/auto-pairs", + { "tpope/vim-surround", event = "BufEnter" }, + { "tpope/vim-repeat", event = "BufEnter" }, + { + "max397574/better-escape.nvim", + event = "InsertEnter", + config = function() + require("better_escape").setup { + mapping = { "jk" }, + } + end + }, + { + -- Lastplace + "ethanholz/nvim-lastplace", + event = "BufRead", + config = function() + local status, lastplace = pcall(require, "nvim-lastplace") + if (not status) then return end + lastplace.setup({ + lastplace_ignore_buftype = { + "quickfix", + "nofile", + "help", + }, + lastplace_ignore_filetype = { + "gitcommit", + "gitrebase", + "svn", + "hgcommit", + }, + lastplace_open_folds = true, + }) + end + }, + { + "cpea2506/relative-toggle.nvim", + config = function() + local status, relativetoggle = pcall(require, "relative-toggle") + if (not status) then return end + relativetoggle.setup({ + pattern = "*", + events = { + on = { + "BufEnter", + "FocusGained", + "InsertLeave", + "WinEnter", + "CmdlineLeave", + }, + off = { + "BufLeave", + "FocusLost", + "InsertEnter", + "WinLeave", + "CmdlineEnter", + }, + }, + }) + end + }, + { + "rcarriga/nvim-notify", + priority = 1000, + event = { + "CursorMoved", + "CursorHold", + "InsertEnter", + "CmdlineEnter", + }, + config = function() + local status, notify = pcall(require, "notify") + if (not status) then return end + notify.setup({ + background_colour = "#000000" + }) + vim.notify = notify + end, + lazy = false + }, + { + "echasnovski/mini.bufremove", + event = "BufEnter", + keys = { + { + "bd", + function() + local bd = require("mini.bufremove").delete + if vim.bo.modified then + local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel") + if choice == 1 then -- Yes + vim.cmd.write() + bd(0) + elseif choice == 2 then -- No + bd(0, true) + end + else + bd(0) + end + end, + desc = "Delete Buffer", + }, + { + "bD", + function() + require("mini.bufremove").delete(0, true) + end, + desc = "Delete Buffer (Force)", + }, + }, + }, + { + 'norcalli/nvim-colorizer.lua', + ft = { + 'lua', + 'css', + 'html', + 'sass', + 'less', + 'typescriptreact', + 'conf', + 'vim', + }, + config = function() + require('colorizer').setup() + end, +} +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..4751c3d --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,31 @@ +-- Auto Completion: Cmp + +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-nvim-lua", + "ray-x/cmp-treesitter", + "lukas-reineke/cmp-rg", + "quangnguyen30192/cmp-nvim-tags", + "andersevenrud/cmp-tmux", + "saadparwaiz1/cmp_luasnip", + "L3MON4D3/LuaSnip", + "rafamadriz/friendly-snippets", + "lukas-reineke/cmp-under-comparator", + { + "honza/vim-snippets", + dependencies = { + "friendly-snippets", + "vim-snippets", + } + } + }, + config = function() + require("utils.cmp").setup() + end +} diff --git a/lua/plugins/colorschemes/catppuccin.lua b/lua/plugins/colorschemes/catppuccin.lua new file mode 100644 index 0000000..7b0d3dd --- /dev/null +++ b/lua/plugins/colorschemes/catppuccin.lua @@ -0,0 +1,122 @@ +if true then + return { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + config = function() + require("catppuccin").setup({ + flavour = "mocha", + background = { + dark = "mocha", + }, + color_overrides = { + mocha = { + rosewater = "#EA6962", + flamingo = "#EA6962", + pink = "#D3869B", + mauve = "#D3869B", + red = "#EA6962", + maroon = "#EA6962", + peach = "#BD6F3E", + yellow = "#D8A657", + green = "#A9B665", + teal = "#89B482", + sky = "#89B482", + sapphire = "#89B482", + blue = "#7DAEA3", + lavender = "#7DAEA3", + text = "#D4BE98", + subtext1 = "#BDAE8B", + subtext0 = "#A69372", + overlay2 = "#8C7A58", + overlay1 = "#735F3F", + overlay0 = "#5A4525", + surface2 = "#4B4F51", + surface1 = "#2A2D2E", + surface0 = "#232728", + base = "#1D2021", + mantle = "#191C1D", + crust = "#151819", + }, + }, + transparent_background = require("config.defaults").config.transparent_background, + show_end_of_buffer = false, + term_colors = true, + dim_inactive = { + enabled = false, + shade = "light", + percentage = 0.10, + }, + styles = { + comments = { "italic" }, + conditionals = { "italic" }, + loops = { "bold" }, + functions = { "bold" }, + keywords = { "bold" }, + strings = {}, + variables = { "italic" }, + numbers = { "bold" }, + booleans = { "italic" }, + properties = {}, + types = { "bold" }, + operators = {}, + }, + integrations = { + flash = true, + alpha = true, + cmp = true, + gitsigns = true, + nvimtree = true, + treesitter = true, + notify = true, + neogit = true, + treesitter_context = true, + ts_rainbow2 = true, + ts_rainbow = true, + indent_blankline = { enabled = true }, + mason = true, + telescope = { + enabled = true, + style = "nvchad", + }, + native_lsp = { + enabled = true, + underlines = { + errors = { "undercurl" }, + hints = { "undercurl" }, + warnings = { "undercurl" }, + information = { "undercurl" }, + }, + }, + }, + custom_highlights = function(colors) + return { + NormalFloat = { bg = colors.crust }, + FloatBorder = { bg = colors.crust, fg = colors.crust }, + VertSplit = { bg = colors.base, fg = colors.surface0 }, + CursorLineNr = { fg = colors.mauve, style = { "bold" } }, + Pmenu = { bg = colors.crust, fg = "" }, + PmenuSel = { bg = colors.surface0, fg = "" }, + TelescopeSelection = { bg = colors.surface0 }, + TelescopePromptCounter = { fg = colors.mauve, style = { "bold" } }, + TelescopePromptPrefix = { bg = colors.surface0 }, + TelescopePromptNormal = { bg = colors.surface0 }, + TelescopeResultsNormal = { bg = colors.mantle }, + TelescopePreviewNormal = { bg = colors.crust }, + TelescopePromptBorder = { bg = colors.surface0, fg = colors.surface0 }, + TelescopeResultsBorder = { bg = colors.mantle, fg = colors.mantle }, + TelescopePreviewBorder = { bg = colors.crust, fg = colors.crust }, + TelescopePromptTitle = { fg = colors.surface0, bg = colors.surface0 }, + TelescopeResultsTitle = { fg = colors.mantle, bg = colors.mantle }, + TelescopePreviewTitle = { fg = colors.crust, bg = colors.crust }, + IndentBlanklineChar = { fg = colors.surface0 }, + IndentBlanklineContextChar = { fg = colors.surface2 }, + GitSignsChange = { fg = colors.peach }, + NvimTreeIndentMarker = { link = "IndentBlanklineChar" }, + NvimTreeExecFile = { fg = colors.text }, + } + end + }) + end, + } +end diff --git a/lua/plugins/colorschemes/kanagawa.lua b/lua/plugins/colorschemes/kanagawa.lua new file mode 100644 index 0000000..bb9618f --- /dev/null +++ b/lua/plugins/colorschemes/kanagawa.lua @@ -0,0 +1,52 @@ +if true then + return { + "rebelot/kanagawa.nvim", + priority = 1000, + config = function() + require('kanagawa').setup({ + compile = true, + commentStyle = { italic = true }, + functionStyle = { italic = true }, + keywordStyle = { italic = true }, + statementStyle = { bold = true }, + typeStyle = {}, + transparent = false, + theme = "dragon", + colors = { + palette = {}, + theme = { + wave = {}, + lotus = {}, + dragon = {}, + all = { + ui = { + bg_gutter = "none" + } + } + }, + }, + overrides = function(colors) + local theme = colors.theme + return { + TelescopeTitle = { bold = true }, + TelescopePromptNormal = { bg = theme.ui.bg_p1, fg = "none" }, + TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = "none" }, + TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = "none" }, + TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = "none" }, + TelescopePreviewNormal = { bg = theme.ui.bg_dim }, + -- TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim }, + -- NormalFloat = { bg = "none" }, + LineNr = { bg = "none" }, + CursorLineNr = { bg = "none" }, + GitsignsAdd = { bg = "none" }, + GitSignsChange = { bg = "none" }, + GitsignsDelete = { bg = "none" }, + } + end, + background = { + dark = "dragon", + }, + }) + end + } +end diff --git a/lua/plugins/colorschemes/nightfox.lua b/lua/plugins/colorschemes/nightfox.lua new file mode 100644 index 0000000..f86eeef --- /dev/null +++ b/lua/plugins/colorschemes/nightfox.lua @@ -0,0 +1,33 @@ +if true then + return { + "EdenEast/nightfox.nvim", + enabled = true, + priority = 1000, + config = function() + require('nightfox').setup({ + options = { + -- Compiled file's destination location + compile_path = vim.fn.stdpath("cache") .. "/nightfox", + compile_file_suffix = "_compiled", -- Compiled file suffix + transparent = require("config.defaults").config.transparent_background, + terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal` + dim_inactive = false, -- Non focused panes set to alternative background + styles = { -- Style to be applied to different syntax groups + comments = "NONE", -- Value is any valid attr-list value `:help attr-list` + functions = "NONE", + keywords = "NONE", + numbers = "NONE", + strings = "NONE", + types = "NONE", + variables = "NONE", + }, + inverse = { -- Inverse highlight for different types + match_paren = false, + visual = false, + search = false, + }, + }, + }) + end + } +end diff --git a/lua/plugins/colorschemes/nightowl.lua b/lua/plugins/colorschemes/nightowl.lua new file mode 100644 index 0000000..fba67f0 --- /dev/null +++ b/lua/plugins/colorschemes/nightowl.lua @@ -0,0 +1,8 @@ +if true then + result { + "oxfist/night-owl.nvim", + as = "night-owl", + enabled = true, + priority = 1000, + } +end diff --git a/lua/plugins/colorschemes/tokyonight.lua b/lua/plugins/colorschemes/tokyonight.lua new file mode 100644 index 0000000..174c703 --- /dev/null +++ b/lua/plugins/colorschemes/tokyonight.lua @@ -0,0 +1,36 @@ +if true then + return { + "folke/tokyonight.nvim", + name = "tokyonight", + priority = 1000, + config = function() + require("tokyonight").setup({ + style = "night", + light_style = "day", + transparent = require("config.defaults").config.transparent_background, + terminal_colors = true, + styles = { + comments = { italic = true }, + keywords = { italic = true }, + functions = {}, + variables = {}, + sidebars = "dark", + floats = "transparent", + }, + sidebars = { + "qf", + "help", + "vista_kind", + "terminal", + "spectre_panel", + "startuptime", + "Outline", + }, + day_brightness = 0.3, + hide_inactive_statusline = false, + dim_inactive = true, + lualine_bold = false, + }) + end, + } +end diff --git a/lua/plugins/extras/coding/codeium.lua b/lua/plugins/extras/coding/codeium.lua new file mode 100644 index 0000000..dd0b2ba --- /dev/null +++ b/lua/plugins/extras/coding/codeium.lua @@ -0,0 +1,11 @@ +return { + "nvim-cmp", + dependencies = { + { + "Exafunction/codeium.nvim", + cmd = "Codeium", + build = ":Codeium Auth", + opts = {}, + }, + }, +} diff --git a/lua/plugins/extras/coding/hover.lua b/lua/plugins/extras/coding/hover.lua new file mode 100644 index 0000000..3b10bb9 --- /dev/null +++ b/lua/plugins/extras/coding/hover.lua @@ -0,0 +1,17 @@ +return { + -- hover + { + "lewis6991/hover.nvim", + -- stylua: ignore + keys = { + { "K", function() require("hover").hover() end, desc = "hover.nvim" }, + { "K", function() require("hover").hover() end, desc = "hover.nvim (select)", mode = { "v" } }, + }, + init = function() + -- Require providers + require("hover.providers.lsp") + require("hover.providers.man") + require("hover.providers.dictionary") + end, + }, +} diff --git a/lua/plugins/extras/coding/refactoring.lua b/lua/plugins/extras/coding/refactoring.lua new file mode 100644 index 0000000..2a5761b --- /dev/null +++ b/lua/plugins/extras/coding/refactoring.lua @@ -0,0 +1,25 @@ +return { + { + "ThePrimeagen/refactoring.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "nvim-telescope/telescope.nvim", + }, + lazy = true, + config = function() + require("refactoring").setup({}) + require("telescope").load_extension("refactoring") + end, + keys = { + { + "cr", + function() + require("telescope").extensions.refactoring.refactors() + end, + mode = { "n", "v" }, + desc = "Refactors", + }, + }, + }, +} diff --git a/lua/plugins/extras/dashboard/alpha.lua b/lua/plugins/extras/dashboard/alpha.lua new file mode 100644 index 0000000..e447a44 --- /dev/null +++ b/lua/plugins/extras/dashboard/alpha.lua @@ -0,0 +1,26 @@ +return { + "goolord/alpha-nvim", + event = "VimEnter", + config = function() + local alpha = require("alpha") + local dashboard = require("alpha.themes.dashboard") + dashboard.section.header.val = require("config.defaults").config.figlet_name + + dashboard.section.buttons.val = { + dashboard.button("e", " New File", ":ene startinsert "), + dashboard.button("LDR ?", " Recently Opened Files", ":Telescope oldfiles"), + dashboard.button("LDR n", "  File Explorer", ":NvimTreeOpen"), + dashboard.button("LDR sf", "🔍 Search Files", ":Telescope find_files"), + dashboard.button("LDR sg", " Search Grep", ":Telescope live_grep"), + dashboard.button("q", "󰅙 Quit NVIM", ":qa"), + } + + dashboard.section.footer.val = "Total plugins: " .. require("lazy").stats().count + dashboard.section.header.opts.hl = "Include" + dashboard.section.buttons.opts.hl = "Keyword" + dashboard.opts.opts.noautocmd = true + + + alpha.setup(dashboard.opts) + end +} diff --git a/lua/plugins/extras/dashboard/bufferline.lua b/lua/plugins/extras/dashboard/bufferline.lua new file mode 100644 index 0000000..937c2f5 --- /dev/null +++ b/lua/plugins/extras/dashboard/bufferline.lua @@ -0,0 +1,47 @@ +return { + { + "akinsho/bufferline.nvim", + version = "v3.*", + opts = { + options = { + offsets = { + { + filetype = "NvimTree", + text = " Explorer", + highlight = "Directory", + text_align = "left", + padding = 1 + }, + }, + left_trunc_marker = "", + right_trunc_marker = "", + number_style = "", + numbers = function(opts) + return string.format("%s", opts.ordinal) + end, + separator_style = { "|", "|" }, + insert_at_end = false, + insert_at_start = true, + close_icon = "", + modified_icon = "", + icon_pinned = "車", + semantic_letters = true, + show_buffer_close_icons = false, + show_tab_indicators = false, + always_show_bufferline = true, + max_name_length = 30, + max_prefix_length = 15, + tab_size = 20, + sort_by = "extension", + custom_filter = function(buf_number) + local name = vim.fn.bufname(buf_number) + if name ~= "" and not name:match("^term://") then + return true + end + end, + highlight = (require("config.defaults").config.colorscheme == "catppuccin") and + require("catppuccin.groups.integrations.bufferline").get() or nil, + }, + }, + }, +} diff --git a/lua/plugins/extras/explorer/nvimtree.lua b/lua/plugins/extras/explorer/nvimtree.lua new file mode 100644 index 0000000..39e4171 --- /dev/null +++ b/lua/plugins/extras/explorer/nvimtree.lua @@ -0,0 +1,19 @@ +return { + "nvim-tree/nvim-tree.lua", + version = "nightly", + event = "VimEnter", + keys = { + { "n", mode = { "n" }, "NvimTreeToggle", desc = "NvimTree Explorer" }, + }, + config = function() + require("utils.nvimtree").setup() + end, + dependencies = { + { + "antosha417/nvim-lsp-file-operations", + config = function() + require("lsp-file-operations").setup() + end + } + } +} diff --git a/lua/plugins/extras/explorer/oil.lua b/lua/plugins/extras/explorer/oil.lua new file mode 100644 index 0000000..6d73b44 --- /dev/null +++ b/lua/plugins/extras/explorer/oil.lua @@ -0,0 +1,22 @@ +return { + "stevearc/oil.nvim", + event = "VimEnter", + dependencies = { "nvim-tree/nvim-web-devicons" }, + keys = { + { "e", mode = { "n" }, "Oil", desc = "Oil Explorer Current" }, + { "E", mode = { "n" }, "Oil .", desc = "Oil Explorer Root" }, + }, + opts = { + default_file_explorer = true, + columns = { + "icon", + "permissions", + "size", + "mtime", + }, + buf_options = { + buflisted = false, + bufhidden = "hide", + }, + }, + } diff --git a/lua/plugins/extras/figlet/figlet.lua b/lua/plugins/extras/figlet/figlet.lua new file mode 100644 index 0000000..feef644 --- /dev/null +++ b/lua/plugins/extras/figlet/figlet.lua @@ -0,0 +1,4 @@ +return { + "pavanbhat1999/figlet.nvim", + requires = "numToStr/Comment.nvim" +} diff --git a/lua/plugins/extras/hacker/hacker.lua b/lua/plugins/extras/hacker/hacker.lua new file mode 100644 index 0000000..833458d --- /dev/null +++ b/lua/plugins/extras/hacker/hacker.lua @@ -0,0 +1,3 @@ +if true then + return { "letieu/hacker.nvim" } +end diff --git a/lua/plugins/extras/lsp/none-ls.lua b/lua/plugins/extras/lsp/none-ls.lua new file mode 100644 index 0000000..c4833f1 --- /dev/null +++ b/lua/plugins/extras/lsp/none-ls.lua @@ -0,0 +1,74 @@ +return { + "nvimtools/none-ls.nvim", -- configure formatters & linters + lazy = true, + -- event = { "BufReadPre", "BufNewFile" }, -- to enable uncomment this + dependencies = { + "jay-babu/mason-null-ls.nvim", + }, + config = function() + local mason_null_ls = require("mason-null-ls") + + local null_ls = require("null-ls") + + local null_ls_utils = require("null-ls.utils") + + mason_null_ls.setup({ + ensure_installed = { + "prettier", -- prettier formatter + "stylua", -- lua formatter + "black", -- python formatter + "pylint", -- python linter + "eslint_d", -- js linter + }, + }) + + -- for conciseness + local formatting = null_ls.builtins.formatting -- to setup formatters + local diagnostics = null_ls.builtins.diagnostics -- to setup linters + + -- to setup format on save + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + + -- configure null_ls + null_ls.setup({ + -- add package.json as identifier for root (for typescript monorepos) + root_dir = null_ls_utils.root_pattern(".null-ls-root", "Makefile", ".git", "package.json"), + -- setup formatters & linters + sources = { + -- to disable file types use + -- "formatting.prettier.with({disabled_filetypes: {}})" (see null-ls docs) + formatting.prettier.with({ + extra_filetypes = { "svelte" }, + }), -- js/ts formatter + formatting.stylua, -- lua formatter + formatting.isort, + formatting.black, + diagnostics.pylint, + diagnostics.eslint_d.with({ -- js/ts linter + condition = function(utils) + return utils.root_has_file({ ".eslintrc.js", ".eslintrc.cjs" }) -- only enable if root has .eslintrc.js or .eslintrc.cjs + end, + }), + }, + -- configure format on save + on_attach = function(current_client, bufnr) + if current_client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ + filter = function(client) + -- only use null-ls for formatting instead of lsp server + return client.name == "null-ls" + end, + bufnr = bufnr, + }) + end, + }) + end + end, + }) + end, +} diff --git a/lua/plugins/extras/rest/rest.lua b/lua/plugins/extras/rest/rest.lua new file mode 100644 index 0000000..00fbb85 --- /dev/null +++ b/lua/plugins/extras/rest/rest.lua @@ -0,0 +1,43 @@ +return { + "NTBBloodbath/rest.nvim", + event = "VeryLazy", + dependencies = { + "nvim-lua/plenary.nvim" + }, + config = function() + local status, restnv = pcall(require, "rest-nvim") + if (not status) then + vim.notify("error loading rest.nvim") + return + end + restnv.setup({ + result_split_horizontal = false, + highlight = { enabled = true, timeout = 150 }, + result = { + show_url = true, + show_http_info = true, + show_headers = true, + formatters = { + json = "jq", + html = function(body) + return vim.fn.system({ "tidy", "-i", "-q", "-" }, body) + end + } + }, + jump_to_request = true, + }) + local rest_nvim = require('rest-nvim') + vim.api.nvim_create_autocmd("FileType", { + pattern = "http", + callback = function() + local buff = tonumber(vim.fn.expand(""), 10) + vim.keymap.set("n", "rn", rest_nvim.run, + { noremap = true, buffer = buff }) + vim.keymap.set("n", "rl", rest_nvim.last, + { noremap = true, buffer = buff }) + vim.keymap.set("n", "rp", function() rest_nvim.run(true) end, + { noremap = true, buffer = buff }) + end + }) + end +} diff --git a/lua/plugins/extras/statusline/galaxyline.lua b/lua/plugins/extras/statusline/galaxyline.lua new file mode 100644 index 0000000..985fad6 --- /dev/null +++ b/lua/plugins/extras/statusline/galaxyline.lua @@ -0,0 +1,11 @@ +if true then + return { + 'glepnir/galaxyline.nvim', + event = 'UIEnter', + dependencies = { "kyazdani42/nvim-web-devicons" }, + branch = 'main', + config = function() + require('utils.galaxyline') + end, + } +end diff --git a/lua/plugins/extras/statusline/luafancy.lua b/lua/plugins/extras/statusline/luafancy.lua new file mode 100644 index 0000000..242ff5c --- /dev/null +++ b/lua/plugins/extras/statusline/luafancy.lua @@ -0,0 +1,14 @@ +if true then + return { + "nvim-lualine/lualine.nvim", + event = "UIEnter", + dependencies = { + "kyazdani42/nvim-web-devicons", + "meuter/lualine-so-fancy.nvim", + }, + config = function() + require("utils.luafancy").setup() + end, + } +end + diff --git a/lua/plugins/extras/statusline/lualine.lua b/lua/plugins/extras/statusline/lualine.lua new file mode 100644 index 0000000..7665578 --- /dev/null +++ b/lua/plugins/extras/statusline/lualine.lua @@ -0,0 +1,10 @@ +if true then + return { + "nvim-lualine/lualine.nvim", + event = "UIEnter", + dependencies = { "kyazdani42/nvim-web-devicons" }, + config = function() + require("utils.lualine").setup() + end, + } +end diff --git a/lua/plugins/extras/tmux/tmux.lua b/lua/plugins/extras/tmux/tmux.lua new file mode 100644 index 0000000..b9f4e0e --- /dev/null +++ b/lua/plugins/extras/tmux/tmux.lua @@ -0,0 +1,18 @@ +-- tmux navigation for nvim +if true then + return { + "alexghergh/nvim-tmux-navigation", + event = "VeryLazy", + config = function() + require "nvim-tmux-navigation".setup { + disable_when_zoomed = true, + keybindings = { + left = "", + down = "", + up = "", + right = "", + }, + } + end + } +end diff --git a/lua/plugins/extras/wasp/wasp.lua b/lua/plugins/extras/wasp/wasp.lua new file mode 100644 index 0000000..e8ca5db --- /dev/null +++ b/lua/plugins/extras/wasp/wasp.lua @@ -0,0 +1,15 @@ +if true then + return { + "LeoRiether/wasp.nvim", + config = function() + require('wasp').setup { + template_path = function() return 'lib/template.' .. vim.fn.expand("%:e") end, + lib = { + finder = 'telescope', -- or 'fzf' + path = 'lib/', + }, + competitive_companion = { file = 'inp' }, + } + end + } +end diff --git a/lua/plugins/extras/wezterm/wezterm.lua b/lua/plugins/extras/wezterm/wezterm.lua new file mode 100644 index 0000000..09f0890 --- /dev/null +++ b/lua/plugins/extras/wezterm/wezterm.lua @@ -0,0 +1,4 @@ +return { + 'willothy/wezterm.nvim', + config = true +} diff --git a/lua/plugins/extras/wilder/wilder.lua b/lua/plugins/extras/wilder/wilder.lua new file mode 100644 index 0000000..ba5c887 --- /dev/null +++ b/lua/plugins/extras/wilder/wilder.lua @@ -0,0 +1,60 @@ +return { + 'gelguy/wilder.nvim', + event = "VimEnter", + config = function() + local wilder = require("wilder") + wilder.setup({ + modes = { ":" }, + next_key = "", + previous_key = "", + }) + wilder.set_option('renderer', wilder.renderer_mux({ + [':'] = wilder.popupmenu_renderer(wilder.popupmenu_border_theme({ + highlighter = wilder.basic_highlighter(), + reverse = 0, + border = 'rounded', + left = { ' ', wilder.popupmenu_devicons() }, + right = { ' ', wilder.popupmenu_scrollbar() }, + })), + ['/'] = wilder.wildmenu_renderer({ + highlighter = { + wilder.lua_pcre2_highlighter(), + wilder.lua_fzy_highlighter(), + }, + pumblend = 20, + separator = ' · ', + left = { ' ', wilder.wildmenu_spinner(), ' ' }, + right = { ' ', wilder.wildmenu_index() }, + highlights = { + accent = wilder.make_hl('WilderAccent', 'Pmenu', { { a = 1 }, { a = 1 }, { foreground = '#f4468f' } }), + }, + }), + ['?'] = wilder.wildmenu_renderer({ + highlighter = { + wilder.lua_pcre2_highlighter(), + wilder.lua_fzy_highlighter(), + }, + pumblend = 20, + separator = ' · ', + left = { ' ', wilder.wildmenu_spinner(), ' ' }, + right = { ' ', wilder.wildmenu_index() }, + highlights = { + accent = wilder.make_hl('WilderAccent', 'Pmenu', { { a = 1 }, { a = 1 }, { foreground = '#f4468f' } }), + }, + }), + }), + 'pipeline', { + wilder.branch( + wilder.python_file_finder_pipeline({ + file_command = { 'rg', '--files' }, + dir_command = { 'fd', '-td' }, + filters = { 'fuzzy_filter', 'difflib_sorter' }, + }), + wilder.cmdline_pipeline(), + wilder.python_search_pipeline() + ), + } + ) + end, + build = ':UpdateRemotePlugins' +} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..5880ac6 --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,115 @@ +return { + { + "lewis6991/gitsigns.nvim", + event = { + "CmdlineEnter", + "InsertEnter", + "CursorHold", + "CursorMoved", + }, + keys = { + { "hs", function() require("gitsigns").hunk_stage() end, desc = "Git Hunk Stage", mode = { "n" } }, + { "hr", function() require("gitsigns").hunk_reset() end, desc = "Git Hunk Reset", mode = { "n" } }, + { 'hs', function() require("gitsigns").stage_hunk { vim.fn.line("."), vim.fn.line("v") } end, desc = 'Stage Hunk (Visual)', mode = { 'v' } }, + { 'hr', function() require("gitsigns").reset_hunk { vim.fn.line("."), vim.fn.line("v") } end, desc = 'Reset Hunk (Visual)', mode = { 'v' } }, + { 'hs', function() require("gitsigns").stage_buffer() end, desc = 'Stage Buffer', mode = { 'n' } }, + { 'hu', function() require("gitsigns").undo_stage_hunk() end, desc = 'Undo Stage Hunk', mode = { 'n' } }, + { 'hr', function() require("gitsigns").reset_buffer() end, desc = 'Reset Buffer', mode = { 'n' } }, + { 'hp', function() require("gitsigns").preview_hunk() end, desc = 'Preview Hunk', mode = { 'n' } }, + { 'hb', function() require("gitsigns").blame_line() end, desc = 'Blame Line', mode = { 'n' } }, + { 'tb', function() require("gitsigns").toggle_current_line_blame() end, desc = 'Toggle Current Line Blame', mode = { 'n' } }, + { 'hd', function() require("gitsigns").diffthis() end, desc = 'Diff This', mode = { 'v', 'n' } }, + { 'hd', function() require("gitsigns").diffthis("~") end, desc = 'Diff This (Visual)', mode = { 'n' } }, + { 'td', function() require("gitsigns").toggle_deleted() end, desc = 'Toggle Deleted', mode = { 'n' } }, + }, + config = function() + local status, gitsigns = pcall(require, 'gitsigns') + if (not status) then return end + + gitsigns.setup { + signs = { + add = { + text = "▎", + hl = "GitSignsAdd", + numhl = "GitSignsAddNr", + linehl = "GitSignsAddLn", + }, + delete = { + text = "_", + hl = "GitSignsDelete", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + change = { + text = "▎", + hl = "GitSignsChange", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + changedelete = { + text = "▎", + hl = "GitSignsDelete", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + topdelete = { + text = '‾', + hl = "GitSignsDelete", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + }, + numhl = false, + linehl = false, + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", + delay = 1000, + ignore_whitespace = false + }, + current_line_blame_formatter_opts = { relative_time = true }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, + max_file_length = 40000, + preview_config = { + border = "shadow", + style = "minimal", + relative = "cursor", + row = 0, + col = 1 + } + } + end + }, + { + "NeogitOrg/neogit", + event = "VimEnter", + dependencies = { + "nvim-lua/plenary.nvim", + { + "sindrets/diffview.nvim", + lazy = true, + enabled = true, + event = "BufRead", + } + }, + keys = { + { "l", mode = { "n" }, "Neogit", desc = "NeoGit UI" }, + { "L", mode = { "n" }, "Neogit commit", desc = "NeoGit UI Commmit" }, + }, + config = function() + require('neogit').setup { + kind = "vsplit", + integrations = { + telescope = true, + diffview = true, + } + } + end + }, +} diff --git a/lua/plugins/lsp/lspconfig.lua b/lua/plugins/lsp/lspconfig.lua new file mode 100644 index 0000000..8727a27 --- /dev/null +++ b/lua/plugins/lsp/lspconfig.lua @@ -0,0 +1,194 @@ +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "antosha417/nvim-lsp-file-operations", config = true }, + { "folke/neoconf.nvim", cmd = "Neoconf", config = true }, + { "folke/neodev.nvim", config = true }, + { "j-hui/fidget.nvim", branch = "legacy" }, + }, + config = function() + local lspconfig = require("lspconfig") + local cmp_nvim_lsp = require("cmp_nvim_lsp") + + local keymap = vim.keymap + + local opts = { noremap = true, silent = true } + local on_attach = function(client, bufnr) + opts.buffer = bufnr + opts.desc = "Show LSP references" + keymap.set("n", "gr", "Telescope lsp_references", opts) -- show definition, references + + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration + + opts.desc = "Show LSP definitions" + keymap.set("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions + + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations + + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions + + opts.desc = "Show lsp symbols of buffer" + keymap.set("n", "gs", "Telescope lsp_document_symbols", opts) -- show lsp type definitions + + opts.desc = "Show lsp symbols of directory" + keymap.set("n", "gS", "Telescope lsp_workspace_symbols", opts) -- show lsp type definitions + + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection + + opts.desc = "Smart rename" + keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = "Show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file + + opts.desc = "Show line diagnostics" + keymap.set("n", "d", vim.diagnostic.open_float, opts) -- show diagnostics for line + + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer + + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer + + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor + end + + -- used to enable autocompletion (assign to every lsp server config) + local capabilities = cmp_nvim_lsp.default_capabilities() + + -- Change the Diagnostic symbols in the sign column (gutter) + -- (not in youtube nvim video) + local signs = { + Error = " ", + Warn = " ", + Hint = "󰠠 ", + Info = " ", + } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + if vim.lsp.setup then + vim.lsp.setup { + floating_preview = { border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" } }, + diagnostics = { + signs = { error = " ", warning = " ", hint = " ", information = " " }, + display = { + underline = true, + update_in_insert = false, + virtual_text = false, + severity_sort = true, + }, + }, + completion = { + kind = { + Class = " ", + Color = " ", + Constant = " ", + Constructor = " ", + Enum = "了 ", + EnumMember = " ", + Field = " ", + File = " ", + Folder = " ", + Function = " ", + Interface = "ﰮ ", + Keyword = " ", + Method = "ƒ ", + Module = " ", + Property = " ", + Snippet = " ", + Struct = " ", + Text = " ", + Unit = " ", + Value = " ", + Variable = " ", + }, + }, + } + else + end + + + -- configure html server + lspconfig["html"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure typescript server with plugin + lspconfig["tsserver"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure css server + lspconfig["cssls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure emmet language server + lspconfig["emmet_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, + }) + + -- configure lua server (with special settings) + lspconfig["lua_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { -- custom settings for lua + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + workspace = { + -- make language server aware of runtime files + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, + + }) + -- configure docker-compose server + lspconfig["docker_compose_language_service"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure docker server + lspconfig["dockerls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure yaml server + lspconfig["yamlls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure golang server + lspconfig["gopls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- Turn on lsp status information + require("fidget").setup() + end, +} diff --git a/lua/plugins/lsp/mason.lua b/lua/plugins/lsp/mason.lua new file mode 100644 index 0000000..ed9fc46 --- /dev/null +++ b/lua/plugins/lsp/mason.lua @@ -0,0 +1,36 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + }, + config = function() + local mason = require("mason") + local mason_lspconfig = require("mason-lspconfig") + local mason_tool_installer = require("mason-tool-installer") + + mason.setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }) + + mason_lspconfig.setup({ + ensure_installed = { + "tsserver", + "html", + "cssls", + "lua_ls", + "docker_compose_language_service", + "dockerls", + "yamlls", + "gopls" + }, + automatic_installation = true, + }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..8f6cd69 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,116 @@ +return { + { + "nvim-telescope/telescope.nvim", + event = { "VimEnter" }, + cmd = { "Telescope" }, + version = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + run = "make", + cond = vim.fn.executable "make" == 1, + }, + "nvim-telescope/telescope-live-grep-args.nvim", + "nvim-telescope/telescope-symbols.nvim", + }, + keys = { + { + "?", + mode = { "n" }, + function() require("telescope.builtin").oldfiles() end, + desc = + "[?] Find recently opened files" + }, + { + "sf", + mode = { "n" }, + function() require("telescope.builtin").find_files() end, + desc = "[S]earch [F]iles", + }, + { + "sw", + mode = { "n" }, + function() require("telescope.builtin").grep_string() end, + desc = "[S]earch current [W]ord", + }, + { + "sg", + mode = { "n" }, + function() require("telescope.builtin").live_grep() end, + desc = "[S]earch by [G]rep", + }, + { + "st", + mode = { "n" }, + function() require("telescope.builtin").tags() end, + desc = "[S]earch by [T]ags", + }, + { + "ss", + mode = { "n" }, + function() require("telescope.builtin").symbols() end, + desc = "[S]earch [S]ymbols", + }, + { + "", + mode = { "n" }, + function() + require("telescope.builtin").buffers({ + ignore_current_buffer = true, + sort_mru = true, + sort_lastused = true + }) + end, + desc = "Switch Buffers", + }, + { + "sk", + function() + require("telescope-live-grep-args.shortcuts").grep_word_under_cursor({ postfix = false }) + end, + desc = "Grep keyword under cursor (root dir)", + mode = { "n" }, + }, + { + "/", + mode = { "n" }, + function() require("utils.telescope").current_buffer_fuzzy_find() end, + desc = "[/] Fuzzily search in current buffer", + }, + { + "/", + function() + require("telescope-live-grep-args.shortcuts").grep_visual_selection({ postfix = false }) + end, + desc = "Grep (root dir)", + mode = { "v" }, + }, + }, + config = function() + require("utils.telescope").setup() + end + }, + { + "folke/flash.nvim", + event = "VeryLazy", + keys = { + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + { + "R", + mode = { "o", "x" }, + function() require("flash").treesitter_search() end, + "Treesitter Search" + }, + { + "", + mode = { "c" }, + function() require("flash").toggle() end, + desc = + "Toggle Flash Search" + }, + }, + }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..a3dc2b1 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,199 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + event = { "VeryLazy", "BufReadPost", "BufNewFile" }, + init = function(plugin) + require("lazy.core.loader").add_to_rtp(plugin) + require("nvim-treesitter.query_predicates") + end, + cmd = { + "TSUpdateSync", + "TSUpdate", + "TSInstall", + }, + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + "p00f/nvim-ts-rainbow", + "HiPhish/nvim-ts-rainbow2", + "windwp/nvim-ts-autotag", + "JoosepAlviste/nvim-ts-context-commentstring", + { + "mizlan/iswap.nvim", + event = "BufWinEnter", + cmd = { + 'ISwap', + 'ISwapWith', + 'ISwapNode', + 'ISwapNodeWith', + }, + keys = { + { "k", mode = { "n" }, ":ISwap", desc = "Swap variables" }, + }, + }, + { + "Wansmer/treesj", + event = "BufWinEnter", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + keys = { + { "j", mode = { "n" }, function() require("treesj").toggle() end, desc = "Toggle Split or Join" }, + }, + config = function() + require('treesj').setup({ + notify = true, + dot_repeat = false, + max_join_length = 500, + use_default_keymaps = false, + }) + end, + }, + { + "m-demare/hlargs.nvim", + config = function() + require("hlargs").setup() + end + }, + { + "ZhiyuanLck/smart-pairs", + event = "InsertEnter", + config = function() + require("pairs"):setup() + end + }, + }, + build = function() + pcall(require("nvim-treesitter.install").update { with_sync = false }) + end, + config = function() + local status, treesitter = pcall(require, "nvim-treesitter.configs") + if (not status) then return end + treesitter.setup { + ensure_installed = { + "cpp", + "python", + "html", + "javascript", + "typescript", + "json", + "json5", + "jsonc", + "go", + "gomod", + "bash", + "lua", + "luadoc", + "luap", + "comment", + "markdown", + "markdown_inline", + "glimmer", + "regex", + "vim", + "vimdoc", + "yaml", + "toml", + "tsx", + "css", + "scss", + "dockerfile", + }, + sync_install = false, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + disable = { "cpp", "latex" }, + }, + indent = { + enable = { "javascriptreact" }, + disable = { 'python' }, + }, + autotag = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + rainbow = { + enable = true, + extendend_mode = true, + max_file_lines = 1000, + query = 'rainbow-parens', + strategy = require('ts-rainbow').strategy.global, + }, + context_commentstring = { + enable = true, + enable_autocmd = false + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, + } + end, + }, + { + "lukas-reineke/indent-blankline.nvim", + event = "BufWinEnter", + + main = "ibl", + config = function() + require("utils.indent_blankline").setup() + end + }, + { + "numToStr/Comment.nvim", + event = { "ModeChanged" }, + config = function() + require("Comment").setup({ + pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook() + }) + end, + dependencies = { + "nvim-ts-context-commentstring", + "JoosepAlviste/nvim-ts-context-commentstring" + } + }, +} diff --git a/lua/plugin/config/cmp.lua b/lua/utils/cmp.lua similarity index 77% rename from lua/plugin/config/cmp.lua rename to lua/utils/cmp.lua index 81227df..0523dd4 100644 --- a/lua/plugin/config/cmp.lua +++ b/lua/utils/cmp.lua @@ -2,25 +2,28 @@ local M = {} local status_cmp, cmp = pcall(require, "cmp") if (not status_cmp) then + vim.notify("error loading cmp") return end local status_luasnip, luasnip = pcall(require, "luasnip") if (not status_luasnip) then + vim.notify("error loading luasnip") return end local types = require("cmp.types") -local lsp_symbol = "" -local luasnip_symbol = "﬌" +local lsp_symbol = "✳" +local luasnip_symbol = "⇨" local treesitter_symbol = "" -local buffer_symbol = "﬘" +local buffer_symbol = "󰕸" local tags_symbol = "" local rg_symbol = "" local path_symbol = "" local tmux_symbol = "" +local codeium_symbol = "󰨞" local function deprioritize_snippet(entry1, entry2) if entry1:get_kind() == types.lsp.CompletionItemKind.Snippet then @@ -32,9 +35,6 @@ local function deprioritize_snippet(entry1, entry2) end function M.setup() - -- nvim-cmp setup - - cmp.setup { snippet = { expand = function(args) @@ -86,7 +86,6 @@ function M.setup() if luasnip.choice_active() then luasnip.change_choice(1) else - -- Print current time local t = os.date("*t") local time = string.format("%02d:%02d:%02d", t.hour, t.min, t.sec) print(time) @@ -104,18 +103,20 @@ function M.setup() { name = 'nvim_lsp', icon = lsp_symbol, + group_index = 1, max_item_count = 10, entry_filter = function(entry) return cmp.lsp.CompletionItemKind.Snippet ~= entry:get_kind() end }, - { name = 'luasnip', icon = luasnip_symbol, max_item_count = 6 }, - { name = 'treesitter', icon = treesitter_symbol, max_item_count = 6 }, - { name = 'buffer', icon = buffer_symbol, max_item_count = 6 }, - { name = 'rg', icon = rg_symbol, max_item_count = 6 }, - { name = 'tags', icon = tags_symbol, max_item_count = 5 }, - { name = 'path', icon = path_symbol, max_item_count = 4 }, - { name = 'tmux', icon = tmux_symbol, max_item_count = 3 }, + { name = 'luasnip', icon = luasnip_symbol, group_index = 1, max_item_count = 8 }, + { name = 'treesitter', icon = treesitter_symbol, group_index = 2, max_item_count = 4, keyword_length = 2 }, + { name = 'buffer', icon = buffer_symbol, group_index = 2, max_item_count = 3 }, + { name = 'rg', icon = rg_symbol, group_index = 2, max_item_count = 3 }, + { name = 'tags', icon = tags_symbol, group_index = 2, max_item_count = 2 }, + { name = 'path', icon = path_symbol, group_index = 2, max_item_count = 2 }, + { name = 'tmux', icon = tmux_symbol, group_index = 2, max_item_count = 3 }, + { name = 'codeium', icon = codeium_symbol, group_index = 1, max_item_count = 3 }, }, formatting = { fields = { "kind", "abbr", "menu" }, @@ -157,6 +158,7 @@ function M.setup() tags = "[Tags]", path = "[Path]", tmux = "[Tmux]", + codeium = "[CODEIUM]", })[entry.source.name] return vim_item end, @@ -165,18 +167,33 @@ function M.setup() window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), - experimental = { ghost_text = false, native_menu = false } + experimental = { + ghost_text = { + hl_group = "CmpGhostText", + }, + } }, sorting = { priority_weight = 2, comparators = { + cmp.config.compare.score, cmp.config.compare.recently_used, + cmp.config.compare.exact, + function(entry1, entry2) + local _, entry1_under = entry1.completion_item.label:find "^_+" + local _, entry2_under = entry2.completion_item.label:find "^_+" + entry1_under = entry1_under or 0 + entry2_under = entry2_under or 0 + if entry1_under > entry2_under then + return false + elseif entry1_under < entry2_under then + return true + end + end, + require "cmp-under-comparator".under, ---@diagnostic disable-next-line: assign-type-mismatch cmp.config.compare.locality, - cmp.config.compare.score, - require "cmp-under-comparator".under, deprioritize_snippet, - cmp.config.compare.exact, cmp.config.compare.offset, cmp.config.compare.kind, cmp.config.compare.sort_text, diff --git a/lua/utils/galaxyline.lua b/lua/utils/galaxyline.lua new file mode 100644 index 0000000..560ddf2 --- /dev/null +++ b/lua/utils/galaxyline.lua @@ -0,0 +1,484 @@ +-- https://github.com/glepnir/galaxyline.nvim/tree/main/lua + +local gl = require("galaxyline") + +-- { == Colors ==> ============================================================ + +local colors = require("galaxyline.theme").default + +if vim.g.colors_name == "tokyonight" then + local palette = require("tokyonight.colors").setup() + colors = { + fg = palette.fg_dark, + bg = palette.bg_highlight, + darkblue = palette.bg_dark, + cyan = palette.cyan, + green = palette.green, + yellow = palette.blue, + orange = palette.orange, + violet = palette.purple, + magenta = palette.magenta, + blue = palette.blue, + red = palette.red, + } +end + +if vim.g.colors_name == "catppuccin-mocha" then + local palette = require("catppuccin.palettes.mocha") + colors = { + fg = palette.text, + bg = palette.base, + darkblue = palette.mantle, + cyan = palette.overlay0, + green = palette.green, + yellow = palette.lavender, + orange = palette.flamingo, + violet = palette.lavender, + magenta = palette.mauve, + blue = palette.mantle, + red = palette.red, + } +end +-- <== } + +-- { == Sections ==> ========================================================== + +local diagnostic = require("galaxyline.provider_diagnostic") + +local conditions = { + gl = require("galaxyline.condition"), + has_file_type = function() + if not vim.bo.filetype or vim.bo.filetype == "" then return false end + return true + end, + ---@param win_width? number + break_width = function(win_width) + win_width = win_width or 50 + if vim.fn.winwidth(0) / 2 > win_width then return true end + return false + end, +} + +local format_icons = { dos = "", mac = "", unix = "" } + +-- Seperators +-- pixels { big = {   }, small = {   } } + +gl.section.left = { + -- Mode ---------------------------------------------------------------------- + { + ModeStartSep = { + provider = function() end, + -- separator = " ", + separator = " ", + separator_highlight = { colors.darkblue, colors.bg }, + }, + }, + { + ViMode = { + icon = function() + local icons = { + n = "󰆾 ", + i = " ", + c = "󰞷 ", + v = "󰆿 ", + V = "󰆿 ", + [""] = "󰆿 ", + C = "󰞷 ", + R = "󰛔 ", + t = " ", + } + return icons[vim.fn.mode()] + end, + provider = function() + -- auto change color according the vim mode + local alias = { + n = "N ", + i = "I ", + c = "C ", + V = "VL", + [""] = "VB", + v = "V ", + C = "C ", + ["r?"] = ":CONFIRM", + rm = "--MORE", + R = "R ", + Rv = "RV", + s = "S ", + S = "S ", + ["r"] = "HIT-ENTER", + [""] = "SELECT", + t = "T ", + ["!"] = "SH", + } + local mode_color = { + n = colors.cyan, + i = colors.red, + v = colors.yellow, + [""] = colors.yellow, + V = colors.yellow, + c = colors.magenta, + no = colors.red, + s = colors.orange, + S = colors.orange, + [""] = colors.orange, + ic = colors.yellow, + R = colors.blue, + Rv = colors.blue, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ["r?"] = colors.cyan, + ["!"] = colors.red, + t = colors.red, + } + local vim_mode = vim.fn.mode() + vim.api.nvim_command("hi GalaxyViMode guifg=" .. mode_color[vim_mode]) + return alias[vim_mode] + end, + highlight = { colors.darkblue, colors.bg }, + separator = " ", + separator_highlight = { colors.darkblue, colors.bg }, + }, + }, + { + ModeEndSep = { + provider = function() end, + separator = "", + separator_highlight = { colors.bg }, + }, + }, + + -- Git ----------------------------------------------------------------------- + { + GitStartSep = { + provider = function() end, + separator = " ", + separator_highlight = { colors.darkblue }, + }, + }, + { + GitIcon = { + provider = function() return "  " end, + condition = conditions.gl.check_git_workspace, + highlight = { colors.orange, colors.darkblue }, + }, + }, + { + GitBranch = { + provider = "GitBranch", + highlight = { colors.fg, colors.darkblue }, + condition = conditions.gl.check_git_workspace, + separator = " ", + separator_highlight = { colors.darkblue, colors.darkblue }, + }, + }, + { + DiffAdd = { + provider = "DiffAdd", + icon = " ", + condition = conditions.break_width, + highlight = { colors.green, colors.darkblue }, + }, + }, + { + DiffModified = { + provider = "DiffModified", + icon = "  ", + condition = conditions.break_width, + highlight = { colors.orange, colors.darkblue }, + }, + }, + { + DiffRemove = { + provider = "DiffRemove", + icon = "  ", + condition = conditions.break_width, + highlight = { colors.red, colors.darkblue }, + }, + }, + { + DiffEndSep = { + provider = function() end, + separator = "", + separator_highlight = { colors.bg, colors.darkblue }, + }, + }, + { + Space = { + provider = function() return " " end, + highlight = { colors.bg, colors.bg }, + }, + }, + + -- File ---------------------------------------------------------------------- + { + FileIcon = { + provider = "FileIcon", + condition = function() + if vim.fn.empty(vim.fn.expand("%:t")) ~= 1 then return true end + return false + end, + highlight = { + require("galaxyline.provider_fileinfo").get_file_icon_color, + colors.bg, + }, + }, + }, + { + BufferType = { + -- provider = "FilePath", + provider = "FileName", + condition = conditions.has_file_type, + highlight = { colors.fg, colors.bg }, + }, + }, + + -- Diagnostics --------------------------------------------------------------- + { + DiagnosticError = { + provider = diagnostic.get_diagnostic_error, + icon = "  ", + highlight = { colors.red, colors.bg }, + }, + }, + { + DiagnosticWarn = { + provider = diagnostic.get_diagnostic_warn, + condition = function() return conditions.break_width(55) end, + icon = "  ", + highlight = { colors.yellow, colors.bg }, + }, + }, + { + DiagnosticInfo = { + provider = diagnostic.get_diagnostic_info, + condition = function() return conditions.break_width(55) end, + highlight = { colors.green, colors.bg }, + icon = "  ", + }, + }, + { + DiagnosticHint = { + provider = diagnostic.get_diagnostic_hint, + condition = function() return conditions.break_width(55) end, + highlight = { colors.violet, colors.bg }, + icon = " 󰌵 ", + }, + }, + { + DarkSepara = { + provider = function() return "" end, + highlight = { colors.bg }, + }, + }, +} + +gl.section.right = { + -- LSP Client ---------------------------------------------------------------- + { + LspStartSep = { + provider = function() return "  " end, + highlight = { colors.yellow, colors.bg }, + separator = "", + separator_highlight = { colors.bg }, + }, + }, + { + GetLspClient = { + provider = "GetLspClient", + condition = function() return conditions.break_width(35) end, + highlight = { colors.fg, colors.bg }, + }, + }, + { + LspEndSep = { + provider = function() return "" end, + highlight = { colors.bg, colors.darkblue }, + separator = " ", + separator_highlight = { colors.bg, colors.bg }, + }, + }, + + -- Position ------------------------------------------------------------------ + { + LineInfo = { + provider = "LineColumn", + condition = conditions.break_width, + highlight = { colors.fg, colors.darkblue }, + separator = "  ", + separator_highlight = { colors.yellow, colors.darkblue }, + }, + }, + { + ScrollBar = { + provider = "ScrollBar", + highlight = { colors.violet, colors.darkblue }, + separator = " ", + separator_highlight = { colors.blue, colors.darkblue }, + }, + }, + { + Percent = { + provider = "LinePercent", + highlight = { colors.fg, colors.darkblue }, + separator = " ", -- " ", --     󰞁 󰆌 + separator_highlight = { colors.blue, colors.darkblue }, + }, + }, + + -- Indentation --------------------------------------------------------------- + { + Indentation = { + provider = function() + local indentation_type = "Tabs:" + if vim.api.nvim_buf_get_option(0, "expandtab") then indentation_type = " Spaces:" end + return indentation_type .. vim.o.ts + end, + condition = conditions.break_width, + highlight = { colors.fg, colors.darkblue }, + separator = "  ", + separator_highlight = { colors.yellow, colors.darkblue }, + }, + }, + + -- File Format --------------------------------------------------------------- + { + FileFormat = { + provider = function() + local fileFormat = string.upper(vim.bo.fileencoding) + return fileFormat + end, + condition = function() return conditions.break_width(55) end, + highlight = { colors.fg, colors.darkblue }, + -- separator = " ", + separator = " " .. format_icons[vim.bo.fileformat] .. " ", + separator_highlight = { colors.yellow, colors.darkblue }, + }, + }, + + { + RightSpace = { + provider = function() return " " end, + highlight = { colors.darkblue, colors.darkblue }, + }, + }, +} + +gl.short_line_list = { + "alpha", + "LuaTree", + "vista", + "dbui", + "startify", + "term", + "nerdtree", + "fugitive", + "fugitiveblame", + "plug", + "NvimTree", + "neo-tree", + "DiffviewFiles", + "Outline", + "neoterm", + "fern", + "toggleterm", + "filetree", + "explorer", +} + +local BufferTypeMap = { + ["alpha"] = "󰍂 Alpha", + ["Mundo"] = "Mundo History", + ["MundoDiff"] = "Mundo Diff", + ["NvimTree"] = " Tree", + ["neo-tree"] = " Tree", + ["fugitive"] = " Fugitive", + ["fugitiveblame"] = " Fugitive Blame", + ["help"] = "󰋗 Help", + ["minimap"] = "Minimap", + ["qf"] = "󰁨 Quick Fix", + ["tabman"] = "Tab Manager", + ["tagbar"] = "Tagbar", + ["FTerm"] = "Terminal", + ["neoterm"] = " NeoTerm", + ["toggleterm"] = " ToggleTerm", + ["git"] = " Git", + ["NeogitStatus"] = " Neogit Status", + ["NeogitPopup"] = " Neogit Popup", + ["NeogitCommitMessage"] = "󰍣 Neogit Commit", + ["DiffviewFiles"] = " Diff View", + ["dapui_scopes"] = "󱁯 Dap Scope", + ["dapui_breakpoints"] = " Dap Breakpoints", + ["dapui_stacks"] = " Dap Stacks", + ["dapui_watches"] = "󰙔 Dap Watch", + ["dap-repl"] = " Dap REPL", + ["Outline"] = " SymbolOutline", + ["fern"] = " Fern FM", + ["filetree"] = " Tree", +} + +gl.section.short_line_left = { + { + ShortLineBlankSpace = { + provider = function() return " " end, + highlight = { colors.bg, colors.bg }, + }, + }, + { + ShortLineLeftBufferName = { + provider = "FileName", + condition = function() + if BufferTypeMap[vim.bo.filetype] then return false end + return true + end, + highlight = { colors.fg, colors.bg }, + }, + }, + { + ShortLineLeftBufferType = { + provider = function() + -- local file_name = vim.fn.expand("%:t") + if vim.bo.filetype == "neo-tree" then return " 󰙅 Neo-tree " end + local mapped_name = BufferTypeMap[vim.bo.filetype] + if mapped_name then return " " .. mapped_name .. " " end + end, + condition = conditions.has_file_type, + highlight = { colors.fg, colors.bg }, + separator = " ", + separator_highlight = { colors.bg, colors.darkblue }, + }, + }, + { + ShortLineLeftWindowNumber = { + provider = function() return vim.api.nvim_win_get_number(vim.api.nvim_get_current_win()) .. " " end, + icon = " ", + highlight = { colors.blue, colors.darkblue }, + separator = "", + separator_highlight = { colors.darkblue, "colors.black" }, + }, + }, +} + +-- { == Load Setup ==> ======================================================== + +gl.galaxyline_augroup() +-- <== } + +-- { == Events ==> ============================================================ + +-- We run into some issues with tint. Toggling it off/on apparently fixes them, while refreshing does not +local tint_ok, tint = pcall(require, "tint") + +local function pseudo_toggle_tint() + if tint_ok then + tint.toggle() + tint.toggle() + end +end +pseudo_toggle_tint() + +local timer = vim.loop.new_timer() + +-- <== } diff --git a/lua/plugin/config/indent_blankline.lua b/lua/utils/indent_blankline.lua similarity index 100% rename from lua/plugin/config/indent_blankline.lua rename to lua/utils/indent_blankline.lua diff --git a/lua/utils/luafancy.lua b/lua/utils/luafancy.lua new file mode 100644 index 0000000..0d9aae0 --- /dev/null +++ b/lua/utils/luafancy.lua @@ -0,0 +1,96 @@ +local M = {} + +local function get_words() + if vim.bo.filetype == "md" or vim.bo.filetype == "txt" or vim.bo.filetype == "markdown" then + if vim.fn.wordcount().visual_words == 1 then + return tostring(vim.fn.wordcount().visual_words) .. " word" + elseif not (vim.fn.wordcount().visual_words == nil) then + return tostring(vim.fn.wordcount().visual_words) .. " words" + else + return tostring(vim.fn.wordcount().words) .. " words" + end + else + return "" + end +end + +local function filename() + local file = vim.fn.expand("%:p") + local homedir = vim.loop.os_homedir() + local base_dir = homedir .. "/projects" + local _, index = string.find(file, base_dir, 1, true) + if index then + return vim.fn.fnamemodify(file, ":~:.") + else + return vim.fn.expand("%:t") + end +end + +function M.setup() + require("lualine").setup({ + options = { + theme = require("config.defaults").config.colorscheme, + component_separators = { left = "|", right = "|" }, + section_separators = { left = "", right = "" }, + globalstatus = true, + refresh = { + statusline = 100, + }, + }, + sections = { + lualine_a = { + { "fancy_mode", width = 3 } + }, + lualine_b = { + { "fancy_branch" }, + { "fancy_diff" }, + { "fancy_lsp_servers" }, + { "fancy_diagnostics" }, + }, + lualine_c = { + { + "filename", + file_status = true, + path = 1, + formatter = filename, + symbols = { + modified = '  ', + readonly = '  ', + unnamed = '  ', + newfile = '  ', + }, + }, + }, + lualine_x = { + { "fancy_cwd", substitute_home = true } + }, + lualine_y = { + { "fancy_filetype", ts_icon = "" }, + get_words, + { + require("lazy.status").updates, + cond = require("lazy.status").has_updates, + color = { fg = "#ff9e64" }, + }, + { "fancy_searchcount" }, + { "fancy_macro" }, + { "fancy_location" }, + }, + lualine_z = { "progress" }, + }, + inactive_sections = { + lualine_c = { '%f %y %m' }, + lualine_x = {}, + }, + extensions = { + "fzf", + "fugitive", + "quickfix", + "nvim-tree", + "man", + "lazy" + }, + }) +end + +return M diff --git a/lua/plugin/config/statusline.lua b/lua/utils/lualine.lua similarity index 97% rename from lua/plugin/config/statusline.lua rename to lua/utils/lualine.lua index 82d0332..a5f86f5 100644 --- a/lua/plugin/config/statusline.lua +++ b/lua/utils/lualine.lua @@ -1,5 +1,4 @@ local M = {} -local ui = require("core.default_config").ui local function getLsps() local lspNames = "[" @@ -64,7 +63,7 @@ end function M.setup() require("lualine").setup({ options = { - theme = ui.theme, + theme = require("config.defaults").config.colorscheme, section_separators = "", component_separators = "", }, diff --git a/lua/plugin/config/nvimtree.lua b/lua/utils/nvimtree.lua similarity index 94% rename from lua/plugin/config/nvimtree.lua rename to lua/utils/nvimtree.lua index 267e246..1effd44 100644 --- a/lua/plugin/config/nvimtree.lua +++ b/lua/utils/nvimtree.lua @@ -1,6 +1,4 @@ local M = {} -local opts = require("core.default_config").opts -local keymap = require("core.default_config").keymap local status, nvimtree = pcall(require, 'nvim-tree') function M.setup() diff --git a/lua/plugin/config/telescope.lua b/lua/utils/telescope.lua similarity index 84% rename from lua/plugin/config/telescope.lua rename to lua/utils/telescope.lua index 023b893..829e6ef 100644 --- a/lua/plugin/config/telescope.lua +++ b/lua/utils/telescope.lua @@ -1,5 +1,5 @@ local M = {} -local telescope = require('telescope') +local telescope = require("telescope") function M.setup() telescope.setup { @@ -69,7 +69,11 @@ function M.setup() }, agrolens = { theme = 'ivy' - } + }, + live_grep_args = { + auto_quoting = true, + }, + }, pickers = { buffers = { @@ -128,27 +132,4 @@ function M.treesitter() } end -function M.colorscheme_picker() - local ui = require("core.default_config").ui - require('telescope.pickers').new({}, { - prompt_title = "Select ColorScheme", - finder = require('telescope.finders').new_table({ - results = ui.theme_toggle - }), - sorter = require('telescope.config').values.generic_sorter({}), - attach_mappings = function(prompt_bufnr, map) - local select_theme = function() - local selection = require('telescope.actions').get_selected_entry() - if selection then - ui.theme = selection.value - end - end - map('i', '', select_theme) - map('n', '', select_theme) - return true - end - }):find() -end - - return M diff --git a/snippets/go.lua b/snippets/go.lua new file mode 100644 index 0000000..81ee282 --- /dev/null +++ b/snippets/go.lua @@ -0,0 +1,112 @@ +local ls = require("luasnip") --{{{ +local s = ls.s +local i = ls.i +local t = ls.t + +local d = ls.dynamic_node +local c = ls.choice_node +local f = ls.function_node +local sn = ls.snippet_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +local snippets, autosnippets = {}, {} --}}} + +local group = vim.api.nvim_create_augroup("GoLang Snippets", { clear = true }) +local file_pattern = "*.go" + +local function cs(trigger, nodes, opts) --{{{ + local snippet = s(trigger, nodes) + local target_table = snippets + + local pattern = file_pattern + local keymaps = {} + + if opts ~= nil then + -- check for custom pattern + if opts.pattern then + pattern = opts.pattern + end + + -- if opts is a string + if type(opts) == "string" then + if opts == "auto" then + target_table = autosnippets + else + table.insert(keymaps, { "i", opts }) + end + end + + -- if opts is a table + if opts ~= nil and type(opts) == "table" then + for _, keymap in ipairs(opts) do + if type(keymap) == "string" then + table.insert(keymaps, { "i", keymap }) + else + table.insert(keymaps, keymap) + end + end + end + + -- set autocmd for each keymap + if opts ~= "auto" then + for _, keymap in ipairs(keymaps) do + vim.api.nvim_create_autocmd("BufEnter", { + pattern = pattern, + group = group, + callback = function() + vim.keymap.set(keymap[1], keymap[2], function() + ls.snip_expand(snippet) + end, { noremap = true, silent = true, buffer = true }) + end, + }) + end + end + end + + table.insert(target_table, snippet) -- insert snippet into appropriate table +end --}}} + +cs( -- Go gin example snippet + "ginexample", + fmt( + [[ + package {} + + import "github.com/gin-gonic/gin" + + func main() {{ + r:= gin.Default(); + r.GET("/", func(ctx *gin.Context) {{ + ctx.String(200, "{}") + }}) + r.Run(":{}") + }} + ]], + { + i(1, "main"), + i(2, "Hello World"), + i(3, "port number"), + } + ) +) + +cs( + "gorm:sqlite", + fmt([[ + // import "github.com/jinzhu/gorm" + // import _ "github.com/jinzhu/gorm/dialects/sqlite" + db, err := gorm.Open("sqlite3", "{}.db") + if err != nil {{ + panic("Failed to connect database") + }} + ]], + { + i(1, "db_name") + } + ) +) + + +return snippets, autosnippets