/ cli / neovim / nvim / lua / plugins / example.lua
example.lua
  1  -- since this is just an example spec, don't actually load anything here and return an empty spec
  2  -- stylua: ignore
  3  if true then return {} end
  4  
  5  -- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
  6  --
  7  -- In your plugin files, you can:
  8  -- * add extra plugins
  9  -- * disable/enabled LazyVim plugins
 10  -- * override the configuration of LazyVim plugins
 11  return {
 12    -- add gruvbox
 13    { "ellisonleao/gruvbox.nvim" },
 14  
 15    -- Configure LazyVim to load gruvbox
 16    {
 17      "LazyVim/LazyVim",
 18      opts = {
 19        colorscheme = "gruvbox",
 20      },
 21    },
 22  
 23    -- change trouble config
 24    {
 25      "folke/trouble.nvim",
 26      -- opts will be merged with the parent spec
 27      opts = { use_diagnostic_signs = true },
 28    },
 29  
 30    -- disable trouble
 31    { "folke/trouble.nvim", enabled = false },
 32  
 33    -- override nvim-cmp and add cmp-emoji
 34    {
 35      "hrsh7th/nvim-cmp",
 36      dependencies = { "hrsh7th/cmp-emoji" },
 37      ---@param opts cmp.ConfigSchema
 38      opts = function(_, opts)
 39        table.insert(opts.sources, { name = "emoji" })
 40      end,
 41    },
 42  
 43    -- change some telescope options and a keymap to browse plugin files
 44    {
 45      "nvim-telescope/telescope.nvim",
 46      keys = {
 47        -- add a keymap to browse plugin files
 48        -- stylua: ignore
 49        {
 50          "<leader>fp",
 51          function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
 52          desc = "Find Plugin File",
 53        },
 54      },
 55      -- change some options
 56      opts = {
 57        defaults = {
 58          layout_strategy = "horizontal",
 59          layout_config = { prompt_position = "top" },
 60          sorting_strategy = "ascending",
 61          winblend = 0,
 62        },
 63      },
 64    },
 65  
 66    -- add pyright to lspconfig
 67    {
 68      "neovim/nvim-lspconfig",
 69      ---@class PluginLspOpts
 70      opts = {
 71        ---@type lspconfig.options
 72        servers = {
 73          -- pyright will be automatically installed with mason and loaded with lspconfig
 74          pyright = {},
 75        },
 76      },
 77    },
 78  
 79    -- add tsserver and setup with typescript.nvim instead of lspconfig
 80    {
 81      "neovim/nvim-lspconfig",
 82      dependencies = {
 83        "jose-elias-alvarez/typescript.nvim",
 84        init = function()
 85          require("lazyvim.util").lsp.on_attach(function(_, buffer)
 86            -- stylua: ignore
 87            vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
 88            vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
 89          end)
 90        end,
 91      },
 92      ---@class PluginLspOpts
 93      opts = {
 94        ---@type lspconfig.options
 95        servers = {
 96          -- tsserver will be automatically installed with mason and loaded with lspconfig
 97          tsserver = {},
 98        },
 99        -- you can do any additional lsp server setup here
100        -- return true if you don't want this server to be setup with lspconfig
101        ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
102        setup = {
103          -- example to setup with typescript.nvim
104          tsserver = function(_, opts)
105            require("typescript").setup({ server = opts })
106            return true
107          end,
108          -- Specify * to use this function as a fallback for any server
109          -- ["*"] = function(server, opts) end,
110        },
111      },
112    },
113  
114    -- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
115    -- treesitter, mason and typescript.nvim. So instead of the above, you can use:
116    { import = "lazyvim.plugins.extras.lang.typescript" },
117  
118    -- add more treesitter parsers
119    {
120      "nvim-treesitter/nvim-treesitter",
121      opts = {
122        ensure_installed = {
123          "bash",
124          "html",
125          "javascript",
126          "json",
127          "lua",
128          "markdown",
129          "markdown_inline",
130          "python",
131          "query",
132          "regex",
133          "tsx",
134          "typescript",
135          "vim",
136          "yaml",
137        },
138      },
139    },
140  
141    -- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
142    -- would overwrite `ensure_installed` with the new value.
143    -- If you'd rather extend the default config, use the code below instead:
144    {
145      "nvim-treesitter/nvim-treesitter",
146      opts = function(_, opts)
147        -- add tsx and treesitter
148        vim.list_extend(opts.ensure_installed, {
149          "tsx",
150          "typescript",
151        })
152      end,
153    },
154  
155    -- the opts function can also be used to change the default opts:
156    {
157      "nvim-lualine/lualine.nvim",
158      event = "VeryLazy",
159      opts = function(_, opts)
160        table.insert(opts.sections.lualine_x, {
161          function()
162            return "😄"
163          end,
164        })
165      end,
166    },
167  
168    -- or you can return new options to override all the defaults
169    {
170      "nvim-lualine/lualine.nvim",
171      event = "VeryLazy",
172      opts = function()
173        return {
174          --[[add your custom lualine config here]]
175        }
176      end,
177    },
178  
179    -- use mini.starter instead of alpha
180    { import = "lazyvim.plugins.extras.ui.mini-starter" },
181  
182    -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
183    { import = "lazyvim.plugins.extras.lang.json" },
184  
185    -- add any tools you want to have installed below
186    {
187      "williamboman/mason.nvim",
188      opts = {
189        ensure_installed = {
190          "stylua",
191          "shellcheck",
192          "shfmt",
193          "flake8",
194        },
195      },
196    },
197  }