example.lua 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. -- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
  5. --
  6. -- In your plugin files, you can:
  7. -- * add extra plugins
  8. -- * disable/enabled LazyVim plugins
  9. -- * override the configuration of LazyVim plugins
  10. return {
  11. -- add gruvbox
  12. { "ellisonleao/gruvbox.nvim" },
  13. -- Configure LazyVim to load gruvbox
  14. {
  15. "LazyVim/LazyVim",
  16. opts = {
  17. colorscheme = "gruvbox",
  18. },
  19. },
  20. -- change trouble config
  21. {
  22. "folke/trouble.nvim",
  23. -- opts will be merged with the parent spec
  24. opts = { use_diagnostic_signs = true },
  25. },
  26. -- disable trouble
  27. { "folke/trouble.nvim", enabled = false },
  28. -- add symbols-outline
  29. {
  30. "simrat39/symbols-outline.nvim",
  31. cmd = "SymbolsOutline",
  32. keys = { { "<leader>cs", "<cmd>SymbolsOutline<cr>", desc = "Symbols Outline" } },
  33. config = true,
  34. },
  35. -- override nvim-cmp and add cmp-emoji
  36. {
  37. "hrsh7th/nvim-cmp",
  38. dependencies = { "hrsh7th/cmp-emoji" },
  39. ---@param opts cmp.ConfigSchema
  40. opts = function(_, opts)
  41. table.insert(opts.sources, { name = "emoji" })
  42. end,
  43. },
  44. -- change some telescope options and a keymap to browse plugin files
  45. {
  46. "nvim-telescope/telescope.nvim",
  47. keys = {
  48. -- add a keymap to browse plugin files
  49. -- stylua: ignore
  50. {
  51. "<leader>fp",
  52. function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
  53. desc = "Find Plugin File",
  54. },
  55. },
  56. -- change some options
  57. opts = {
  58. defaults = {
  59. layout_strategy = "horizontal",
  60. layout_config = { prompt_position = "top" },
  61. sorting_strategy = "ascending",
  62. winblend = 0,
  63. },
  64. },
  65. },
  66. -- add telescope-fzf-native
  67. {
  68. "telescope.nvim",
  69. dependencies = {
  70. "nvim-telescope/telescope-fzf-native.nvim",
  71. build = "make",
  72. config = function()
  73. require("telescope").load_extension("fzf")
  74. end,
  75. },
  76. },
  77. -- add pyright to lspconfig
  78. {
  79. "neovim/nvim-lspconfig",
  80. ---@class PluginLspOpts
  81. opts = {
  82. ---@type lspconfig.options
  83. servers = {
  84. -- pyright will be automatically installed with mason and loaded with lspconfig
  85. pyright = {},
  86. },
  87. },
  88. },
  89. -- add tsserver and setup with typescript.nvim instead of lspconfig
  90. {
  91. "neovim/nvim-lspconfig",
  92. dependencies = {
  93. "jose-elias-alvarez/typescript.nvim",
  94. init = function()
  95. require("lazyvim.util").on_attach(function(_, buffer)
  96. -- stylua: ignore
  97. vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
  98. vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
  99. end)
  100. end,
  101. },
  102. ---@class PluginLspOpts
  103. opts = {
  104. ---@type lspconfig.options
  105. servers = {
  106. -- tsserver will be automatically installed with mason and loaded with lspconfig
  107. tsserver = {},
  108. },
  109. -- you can do any additional lsp server setup here
  110. -- return true if you don't want this server to be setup with lspconfig
  111. ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
  112. setup = {
  113. -- example to setup with typescript.nvim
  114. tsserver = function(_, opts)
  115. require("typescript").setup({ server = opts })
  116. return true
  117. end,
  118. -- Specify * to use this function as a fallback for any server
  119. -- ["*"] = function(server, opts) end,
  120. },
  121. },
  122. },
  123. -- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
  124. -- treesitter, mason and typescript.nvim. So instead of the above, you can use:
  125. { import = "lazyvim.plugins.extras.lang.typescript" },
  126. -- add more treesitter parsers
  127. {
  128. "nvim-treesitter/nvim-treesitter",
  129. opts = {
  130. ensure_installed = {
  131. "bash",
  132. "html",
  133. "javascript",
  134. "json",
  135. "lua",
  136. "markdown",
  137. "markdown_inline",
  138. "python",
  139. "query",
  140. "regex",
  141. "tsx",
  142. "typescript",
  143. "vim",
  144. "yaml",
  145. },
  146. },
  147. },
  148. -- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
  149. -- would overwrite `ensure_installed` with the new value.
  150. -- If you'd rather extend the default config, use the code below instead:
  151. {
  152. "nvim-treesitter/nvim-treesitter",
  153. opts = function(_, opts)
  154. -- add tsx and treesitter
  155. vim.list_extend(opts.ensure_installed, {
  156. "tsx",
  157. "typescript",
  158. })
  159. end,
  160. },
  161. -- the opts function can also be used to change the default opts:
  162. {
  163. "nvim-lualine/lualine.nvim",
  164. event = "VeryLazy",
  165. opts = function(_, opts)
  166. table.insert(opts.sections.lualine_x, "😄")
  167. end,
  168. },
  169. -- or you can return new options to override all the defaults
  170. {
  171. "nvim-lualine/lualine.nvim",
  172. event = "VeryLazy",
  173. opts = function()
  174. return {
  175. --[[add your custom lualine config here]]
  176. }
  177. end,
  178. },
  179. -- use mini.starter instead of alpha
  180. { import = "lazyvim.plugins.extras.ui.mini-starter" },
  181. -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
  182. { import = "lazyvim.plugins.extras.lang.json" },
  183. -- add any tools you want to have installed below
  184. {
  185. "williamboman/mason.nvim",
  186. opts = {
  187. ensure_installed = {
  188. "stylua",
  189. "shellcheck",
  190. "shfmt",
  191. "flake8",
  192. },
  193. },
  194. },
  195. -- Use <tab> for completion and snippets (supertab)
  196. -- first: disable default <tab> and <s-tab> behavior in LuaSnip
  197. {
  198. "L3MON4D3/LuaSnip",
  199. keys = function()
  200. return {}
  201. end,
  202. },
  203. -- then: setup supertab in cmp
  204. {
  205. "hrsh7th/nvim-cmp",
  206. dependencies = {
  207. "hrsh7th/cmp-emoji",
  208. },
  209. ---@param opts cmp.ConfigSchema
  210. opts = function(_, opts)
  211. local has_words_before = function()
  212. unpack = unpack or table.unpack
  213. local line, col = unpack(vim.api.nvim_win_get_cursor(0))
  214. return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
  215. end
  216. local luasnip = require("luasnip")
  217. local cmp = require("cmp")
  218. opts.mapping = vim.tbl_extend("force", opts.mapping, {
  219. ["<Tab>"] = cmp.mapping(function(fallback)
  220. if cmp.visible() then
  221. cmp.select_next_item()
  222. -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
  223. -- this way you will only jump inside the snippet region
  224. elseif luasnip.expand_or_jumpable() then
  225. luasnip.expand_or_jump()
  226. elseif has_words_before() then
  227. cmp.complete()
  228. else
  229. fallback()
  230. end
  231. end, { "i", "s" }),
  232. ["<S-Tab>"] = cmp.mapping(function(fallback)
  233. if cmp.visible() then
  234. cmp.select_prev_item()
  235. elseif luasnip.jumpable(-1) then
  236. luasnip.jump(-1)
  237. else
  238. fallback()
  239. end
  240. end, { "i", "s" }),
  241. })
  242. end,
  243. },
  244. }