From d93e3880674dfaa46d0a6dc9c4513571aa4d15b3 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Wed, 14 Aug 2024 14:40:31 +0545 Subject: [PATCH] update --- lazy-lock.json | 8 ++-- lua/keymaps.lua | 6 +-- lua/plugins.lua | 21 +-------- lua/plugins/barbar.lua | 10 ---- lua/plugins/bufferline.lua | 33 +++++++++++++ lua/plugins/codeium.lua | 15 +++--- lua/plugins/completions.lua | 37 +++++++++++---- lua/plugins/dashboard.lua | 60 ------------------------ lua/plugins/inc-rename.lua | 6 +++ lua/plugins/lspconfig.lua | 38 --------------- lua/plugins/lualine.lua | 51 +++----------------- lua/plugins/markdown.lua | 14 ++++++ lua/plugins/mason.lua | 54 ++++++++++++++++++++++ lua/plugins/nerdy.lua | 9 ++++ lua/plugins/none-ls.lua | 82 +++++++++++++++++++++++++++------ lua/plugins/notify.lua | 1 - lua/plugins/nvim-treesitter.lua | 39 +++++++++++----- 17 files changed, 261 insertions(+), 223 deletions(-) delete mode 100644 lua/plugins/barbar.lua create mode 100644 lua/plugins/bufferline.lua delete mode 100644 lua/plugins/dashboard.lua create mode 100644 lua/plugins/inc-rename.lua create mode 100644 lua/plugins/markdown.lua create mode 100644 lua/plugins/mason.lua create mode 100644 lua/plugins/nerdy.lua diff --git a/lazy-lock.json b/lazy-lock.json index f935e75..26da048 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,22 +2,24 @@ "LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" }, "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, "alpha-nvim": { "branch": "main", "commit": "355fbb81a59637a8963cf5847074f8c44dbef11f" }, - "barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" }, + "bufferline.nvim": { "branch": "main", "commit": "2e3c8cc5a57ddd32f1edd2ffd2ccb10c09421f6c" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "codeium.vim": { "branch": "main", "commit": "0b74f274b82c00eaad4b5b5cd8b2e76f872d19f1" }, "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, - "github-preview.nvim": { "branch": "main", "commit": "b1f286a0c2c5bfcc0fea467decbb73e657428065" }, - "gitsigns.nvim": { "branch": "main", "commit": "562dc47189ad3c8696dbf460d38603a74d544849" }, + "inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "f2acd4a21db1ca0a12559e7a9f7cdace3bdbfb09" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" }, + "nerdy.nvim": { "branch": "main", "commit": "b467d6609b78d6a5f1e12cbc08fcc1ac87af20f5" }, "none-ls.nvim": { "branch": "main", "commit": "cfa65d86e21eeb60544d5e823f6db43941322a53" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, "nvim": { "branch": "main", "commit": "18bab5ec4c782cdf7d7525dbe89c60bfa02fc195" }, diff --git a/lua/keymaps.lua b/lua/keymaps.lua index dcf6554..f3eb5ba 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -17,9 +17,9 @@ end) vim.keymap.set('n', 'ft', vim.lsp.buf.format, {}) -- buffer -vim.keymap.set('n', '', ':BufferNext') -vim.keymap.set('n', '', ':BufferPrevious') -vim.keymap.set('n', 'q', ':BufferClose') +vim.keymap.set("n", "", ":BufferLineCycleNext") +vim.keymap.set("n", "", ":BufferLineCyclePrev") +vim.keymap.set("n", "q", ":BufferLinePickClose") -- comment vim.keymap.set('n', '/', 'gcc', { remap = true }) diff --git a/lua/plugins.lua b/lua/plugins.lua index 0658aee..a564707 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,20 +1 @@ -return { - -- Markdown Preview - { - 'wallpants/github-preview.nvim', - cmd = { 'GithubPreviewToggle' }, - keys = { 'mpt' }, - opts = { - -- config goes here - }, - config = function(_, opts) - local gpreview = require('github-preview') - gpreview.setup(opts) - - local fns = gpreview.fns - vim.keymap.set('n', 'mpt', fns.toggle) - vim.keymap.set('n', 'mps', fns.single_file_toggle) - vim.keymap.set('n', 'mpd', fns.details_tags_toggle) - end, - }, -} +return {} diff --git a/lua/plugins/barbar.lua b/lua/plugins/barbar.lua deleted file mode 100644 index 7737d97..0000000 --- a/lua/plugins/barbar.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - 'romgrk/barbar.nvim', - dependencies = { - 'nvim-tree/nvim-web-devicons', - 'lewis6991/gitsigns.nvim', - }, - config = function() - require('barbar').setup() - end, -} diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 0000000..39568fd --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,33 @@ +return { + 'akinsho/bufferline.nvim', + event = { 'BufReadPost', 'BufAdd', 'BufNewFile' }, + version = '*', + dependencies = 'nvim-tree/nvim-web-devicons', + opts = { + options = { + debug = { logging = true }, + mode = 'buffers', + indicator = { icon = '▍', style = 'none' }, + sort_by = 'insert_after_current', + move_wraps_at_ends = true, + right_mouse_command = 'vert sbuffer %d', + show_close_icon = false, + show_buffer_close_icons = false, + diagnostics = 'nvim_lsp', + diagnostics_indicator = function(count, level) + local icon = level:match('error') and ' ' or ' ' + return ' ' .. icon .. count + end, + diagnostics_update_in_insert = false, + hover = { enabled = true, reveal = { 'close' } }, + offsets = { + { + filetype = 'neo-tree', + text = ' File Explorer', + highlight = 'Directory', + separator = false, + }, + }, + }, + }, +} diff --git a/lua/plugins/codeium.lua b/lua/plugins/codeium.lua index 0a490b9..a83d9d6 100644 --- a/lua/plugins/codeium.lua +++ b/lua/plugins/codeium.lua @@ -3,22 +3,21 @@ return { event = 'InsertEnter', cmd = 'Codeium', build = 'Codeium Auth:', - dependencies = { - 'nvim-lua/plenary.nvim', - 'hrsh7th/nvim-cmp', - }, config = function() - vim.keymap.set('i', '', function() + vim.keymap.set('i', '', function() return vim.fn['codeium#Accept']() end, { expr = true, silent = true }) - vim.keymap.set('i', '', function() + vim.keymap.set("n", "c", function() + return vim.fn["codeium#Chat"]() + end, { desc = "Chat with IA (Codeium)" }) + vim.keymap.set('i', '', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true, silent = true }) - vim.keymap.set('i', '', function() + vim.keymap.set('i', '', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true, silent = true }) - vim.keymap.set('i', '', function() + vim.keymap.set('i', '', function() return vim.fn['codeium#Clear']() end, { expr = true, silent = true }) end, diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index d2af186..e1f1a4e 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -33,7 +33,30 @@ return { [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require('luasnip').expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require('luasnip').jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, @@ -44,15 +67,11 @@ return { }), formatting = { format = lspkind.cmp_format({ - mode = 'symbol', -- show only symbol annotations - maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - -- can also be a function to dynamically calculate max width such as - -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, - ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) - show_labelDetails = true, -- show labelDetails in menu. Disabled by default + mode = 'symbol', + maxwidth = 50, + ellipsis_char = '...', + show_labelDetails = true, - -- The function below will be called before any actual modifications from lspkind - -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) before = function(entry, vim_item) return vim_item end, diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua deleted file mode 100644 index 054e1fe..0000000 --- a/lua/plugins/dashboard.lua +++ /dev/null @@ -1,60 +0,0 @@ -return { - 'nvimdev/dashboard-nvim', - dependencies = { - 'nvim-tree/nvim-web-devicons', - }, - event = 'VimEnter', - config = function() - require('dashboard').setup({ - theme = 'hyper', - disable_move = false, - shortcut_type = 'letter', - change_to_vcs_root = true, - hide = { - statusline = true, - tabline = false, - winbar = false, - }, - config = { - header = { - '', - - ' ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ', - ' ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ', - ' ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ', - ' ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ', - ' ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ', - ' ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ', - '', - }, - weak_header = { - enable = false, - append = { ' Learn, Make, Explore! ' }, - }, - packages = { enable = true }, - project = { enable = true, limit = 8 }, - mru = { limit = 8 }, - shortcut ={ - { - desc = ' Recent files', - group = 'Label', - action = 'Telescope oldfiles', - key = 'r', - }, - { - desc = ' Find file', - group = 'Label', - action = 'Telescope find_files', - key = 'f', - }, - { - desc = ' Find text', - group = 'Label', - action = 'Telescope live_grep', - key = 't', - }, - }, - }, - }) - end, -} diff --git a/lua/plugins/inc-rename.lua b/lua/plugins/inc-rename.lua new file mode 100644 index 0000000..49c2ac0 --- /dev/null +++ b/lua/plugins/inc-rename.lua @@ -0,0 +1,6 @@ +return { + "smjonas/inc-rename.nvim", + config = function() + require("inc_rename").setup() + end, +} diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index eac5a41..90060d0 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,42 +1,4 @@ return { - { - 'williamboman/mason.nvim', - cmd = 'Mason', - dependencies = { - 'williamboman/mason-lspconfig.nvim', - 'WhoIsSethDaniel/mason-tool-installer.nvim', - }, - config = function() - require('mason').setup() - require('mason-lspconfig').setup({ - ensure_installed = { - 'lua_ls', - 'clangd', - 'pylsp', - 'bashls', - 'jsonls', - 'vimls', - 'jdtls', - 'html', - 'cssls', - 'tailwindcss', - 'tsserver', - }, - }) - - require('mason-tool-installer').setup({ - ensure_installed = { - 'prettier', - 'stylua', - 'clang-format', - 'black', - 'gdformat', - 'djhtml', - }, - }) - end, - }, - { 'neovim/nvim-lspconfig', event = { 'BufReadPre', 'BufNewFile' }, diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index fcf8a75..7e5e51b 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -1,46 +1,7 @@ -return { - 'nvim-lualine/lualine.nvim', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - require('lualine').setup({ - options = { - icons_enabled = true, - theme = 'auto', - component_separators = { left = '', right = '' }, - section_separators = { left = '', right = '' }, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - }, - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { 'filename' }, - lualine_x = { 'encoding', 'fileformat', 'filetype' }, - lualine_y = { 'progress' }, - lualine_z = { 'location' }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { 'filename' }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {}, - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {}, - }) - end, + return { + "nvim-lualine/lualine.nvim", + event = { 'BufReadPre', 'BufNewFile' }, + config = function() + require("lualine").setup() + end, } diff --git a/lua/plugins/markdown.lua b/lua/plugins/markdown.lua new file mode 100644 index 0000000..019b87d --- /dev/null +++ b/lua/plugins/markdown.lua @@ -0,0 +1,14 @@ +return { + { + 'iamcco/markdown-preview.nvim', + build = 'cd app && yarn install', + ft = { 'markdown' }, + keys = { + { + 'mp', + 'MarkdownPreviewToggle', + { desc = 'toggle markdown preview', noremap = true }, + }, + }, + }, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..aae1854 --- /dev/null +++ b/lua/plugins/mason.lua @@ -0,0 +1,54 @@ +return { + 'williamboman/mason.nvim', + cmd = { 'Mason', 'MasonInstall', 'MasonInstallAll', 'MasonUpdate' }, + 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') + + -- enable mason and configure icons + mason.setup({ + ui = { + border = 'rounded', + icons = { + package_installed = '✓', + package_pending = '➜', + package_uninstalled = '✗', + }, + }, + }) + + mason_lspconfig.setup({ + -- list of servers for mason to install + ensure_installed = { + 'tsserver', + 'html', + 'cssls', + 'tailwindcss', + 'lua_ls', + 'pyright', + 'jdtls', + 'bashls', + 'jsonls', + 'clangd', + }, + }) + + mason_tool_installer.setup({ + ensure_installed = { + 'prettier', -- prettier formatter + 'biome', -- js formatter + 'stylua', -- lua formatter + 'black', -- python formatter + 'clang-format', -- c/c++ formatter + 'luacheck', + 'pylint', + 'eslint_d', + }, + }) + end, +} diff --git a/lua/plugins/nerdy.lua b/lua/plugins/nerdy.lua new file mode 100644 index 0000000..e61830c --- /dev/null +++ b/lua/plugins/nerdy.lua @@ -0,0 +1,9 @@ +return { + "2kabhishek/nerdy.nvim", + dependencies = { + "stevearc/dressing.nvim", + "nvim-telescope/telescope.nvim", + }, + cmd = "Nerdy", + vim.keymap.set("n", "si", "Nerdy", opts), --> nerd icons +} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index a5396e2..06e028b 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -1,18 +1,70 @@ return { - 'nvimtools/none-ls.nvim', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local null_ls = require('null-ls') + 'nvimtools/none-ls.nvim', -- configure formatters & linters + event = { 'CursorHold', 'CursorHoldI' }, + dependencies = { + 'jay-babu/mason-null-ls.nvim', + }, + config = function() + local mason_null_ls = require('mason-null-ls') - null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.clang_format, - null_ls.builtins.formatting.black, - null_ls.builtins.formatting.gdformat, - null_ls.builtins.formatting.djhtml, - }, - }) - end, + local null_ls = require('null-ls') + + local null_ls_utils = require('null-ls.utils') + + mason_null_ls.setup({ + ensure_installed = { + 'prettier', -- prettier formatter + 'biome', -- js formatter + 'clang-format', -- c/c++ 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({ + root_dir = null_ls_utils.root_pattern('.null-ls-root', 'Makefile', '.git', 'package.json'), + sources = { + formatting.prettier, -- js/ts formatter + formatting.stylua, -- lua formatter + formatting.isort, + formatting.black, + formatting.clang_format, + 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/notify.lua b/lua/plugins/notify.lua index d7b98ee..74fb19a 100644 --- a/lua/plugins/notify.lua +++ b/lua/plugins/notify.lua @@ -1,6 +1,5 @@ return { 'rcarriga/nvim-notify', - event = 'VeryLazy', config = function() vim.notify = require('notify') diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua index 6238aad..5ad35e5 100644 --- a/lua/plugins/nvim-treesitter.lua +++ b/lua/plugins/nvim-treesitter.lua @@ -1,18 +1,35 @@ return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', dependencies = { 'windwp/nvim-ts-autotag', }, event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local configs = require("nvim-treesitter.configs") + config = function() + local configs = require('nvim-treesitter.configs') - configs.setup({ - ensure_installed = { "c", "lua", "vim", "vimdoc", "python", "cpp", "html", "css", "javascript", "typescript", "json", "php", "gdscript", 'markdown', 'markdown_inline', 'bash','java' }, - sync_install = true, - highlight = { enable = true }, - indent = { enable = true }, - }) - end, + configs.setup({ + ensure_installed = { + 'c', + 'lua', + 'vim', + 'vimdoc', + 'python', + 'cpp', + 'html', + 'css', + 'javascript', + 'typescript', + 'json', + 'php', + 'markdown', + 'markdown_inline', + 'bash', + 'java', + }, + sync_install = true, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, }