From aaa91a61698ed7ac908b302a5be095750ea3ba3c Mon Sep 17 00:00:00 2001 From: amolinae06 Date: Wed, 22 Jan 2025 10:36:00 -0600 Subject: [PATCH] fixed config and plugins --- .gitignore | 1 + lua/config/plugins/cmp.lua | 61 ++++++++++++++----------------- lua/config/plugins/lsp.lua | 2 - lua/config/plugins/mason.lua | 9 ----- lua/config/plugins/treesitter.lua | 41 --------------------- lua/plugins/cmp.lua | 23 +++++++++--- lua/plugins/lspconfig.lua | 50 +++++++++++++------------ lua/plugins/mason.lua | 21 ----------- lua/plugins/nonels.lua | 15 ++++++++ lua/plugins/telescope.lua | 24 ++++++++++++ lua/plugins/treesitter.lua | 13 +++++++ lua/plugins/ui.lua | 7 +--- 12 files changed, 125 insertions(+), 142 deletions(-) delete mode 100644 lua/config/plugins/lsp.lua delete mode 100644 lua/config/plugins/mason.lua delete mode 100644 lua/config/plugins/treesitter.lua delete mode 100644 lua/plugins/mason.lua create mode 100644 lua/plugins/nonels.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua diff --git a/.gitignore b/.gitignore index e033bc6..f274119 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.luarc.json lazy-lock.json diff --git a/lua/config/plugins/cmp.lua b/lua/config/plugins/cmp.lua index 44d1645..b91167f 100644 --- a/lua/config/plugins/cmp.lua +++ b/lua/config/plugins/cmp.lua @@ -1,36 +1,29 @@ --- Set up nvim-cmp. -local cmp = require'cmp' -require("luasnip.loaders.from_vscode").lazy_load() + local cmp = require'cmp' + require("luasnip.loaders.from_vscode").lazy_load() -cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - end, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }), - sources = cmp.config.sources({ - -- { name = 'nvim_lsp' }, - { name = 'luasnip' }, -- For luasnip users. - }, { - { name = 'buffer' }, + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, + -- { name = 'path' }, + -- { name = 'cmdline' }, + }) }) -}) - --- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline({ '/', '?' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } -}) diff --git a/lua/config/plugins/lsp.lua b/lua/config/plugins/lsp.lua deleted file mode 100644 index e7b4600..0000000 --- a/lua/config/plugins/lsp.lua +++ /dev/null @@ -1,2 +0,0 @@ -local lspconfig = require("lspconfig") -lspconfig.lua_ls.setup({}) diff --git a/lua/config/plugins/mason.lua b/lua/config/plugins/mason.lua deleted file mode 100644 index af77151..0000000 --- a/lua/config/plugins/mason.lua +++ /dev/null @@ -1,9 +0,0 @@ -require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } -}) diff --git a/lua/config/plugins/treesitter.lua b/lua/config/plugins/treesitter.lua deleted file mode 100644 index 9a396a6..0000000 --- a/lua/config/plugins/treesitter.lua +++ /dev/null @@ -1,41 +0,0 @@ -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" (the listed parsers MUST always be installed) - ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline" }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, - - -- List of parsers to ignore installing (or "all") - ignore_install = { "javascript" }, - - ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) - -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! - - highlight = { - enable = true, - - -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to - -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is - -- the name of the parser) - -- list of language that will be disabled - disable = { "c", "rust" }, - -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files - disable = function(lang, buf) - local max_filesize = 100 * 1024 -- 100 KB - local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) - if ok and stats and stats.size > max_filesize then - return true - end - end, - - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, -} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 671c0f1..4053811 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -2,18 +2,31 @@ return { { "hrsh7th/nvim-cmp", dependencies = { - "hrsh7th/cmp-nvim-lsp" + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer" }, opts = function() require "config.plugins.cmp" end, }, + { + "hrsh7th/cmp-nvim-lsp", + dependencies = {}, + config = function () + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + require('lspconfig').clangd.setup { + capabilities = capabilities, + } + end, + }, { "L3MON4D3/LuaSnip", - dependencies = { - "saadparwaiz1/cmp_luasnip", - "rafamadriz/friendly-snippets" + dependencies = { + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets" }, opts = {} - }, + } } diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 8b79493..5eb54ef 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,34 +1,36 @@ return { { "neovim/nvim-lspconfig", - opts = { - require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } - }) - } - }, - { - "williamboman/mason.nvim", - opts = function() - require "config.plugins.mason" + dependencies= {}, + config = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup({}) + + vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) + vim.keymap.set({'n', 'v'}, 'ca', vim.lsp.buf.code_action, {}) end, }, { - "williamboman/mason-lspconfig.nvim", - dependencies = { - "williamboman/mason.nvim", - "neovim/nvim-lspconfig" - }, + "williamboman/mason.nvim", + dependencies = {}, opts = { - require("mason-lspconfig").setup({ - ensure_installed = { "lua_ls" }, - }) + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } } }, + { + "williamboman/mason-lspconfig.nvim", + dependencies = {}, + config = function() + require("mason-lspconfig").setup { + ensure_installed = { "lua_ls" }, + } + end, + } } diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua deleted file mode 100644 index ca1814f..0000000 --- a/lua/plugins/mason.lua +++ /dev/null @@ -1,21 +0,0 @@ -return { - { - "williamboman/mason.nvim", - dependencies = {}, - opts = function() - require "config.plugins.mason" - end, - }, - { - "williamboman/mason-lspconfig.nvim", - dependencies = { - "williamboman/mason.nvim", - "neovim/nvim-lspconfig" - }, - opts = { - require("mason-lspconfig").setup({ - ensure_installed = { "lua_ls" }, - }) - } - }, -} diff --git a/lua/plugins/nonels.lua b/lua/plugins/nonels.lua new file mode 100644 index 0000000..707386d --- /dev/null +++ b/lua/plugins/nonels.lua @@ -0,0 +1,15 @@ +return { + { + "nvimtools/none-ls.nvim", + config = function() + local null_ls = require("null-ls") + null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua, + -- null_ls.builtins.completion.spell, + }, + }) + vim.keymap.set("n", "gf", vim.lsp.buf.format, {}) + end, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..4a8f009 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,24 @@ +return { + { + "nvim-telescope/telescope.nvim", + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local builtin = require('telescope.builtin') + vim.keymap.set('n', '', builtin.find_files, { desc = 'Telescope find files' }) + vim.keymap.set('n', '', builtin.live_grep, { desc = 'Telescope live grep' }) + end, + }, + { + "nvim-telescope/telescope-ui-select.nvim", + config = function() + require("telescope").setup { + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown {} + } + } + } + require("telescope").load_extension("ui-select") + end, + } +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..078e630 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,13 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + dependencies = {}, + opts = { + auto_install = true, + ensure_installed = { "lua" }, + highlight = { enable = true }, + indent = { enable = true } + } + } +} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 415486c..42a62d9 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -20,11 +20,6 @@ return { { "nvim-treesitter/nvim-treesitter", event = { "BufReadPost", "BufNewFile" }, - opts = function() - return require "config.plugins.treesitter" - end, - config = function(_, opts) - require("nvim-treesitter.configs").setup(opts) - end, + opts = {} }, }