Arch 2025 rice. Also contains a newly inspired neovim config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
5.0 KiB

2 weeks ago
1 week ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
  1. return {
  2. {
  3. 'williamboman/mason.nvim',
  4. lazy = false,
  5. opts = {},
  6. },
  7. {
  8. "jay-babu/mason-null-ls.nvim",
  9. event = { "BufReadPre", "BufNewFile" },
  10. dependencies = {
  11. "williamboman/mason.nvim",
  12. "nvimtools/none-ls.nvim",
  13. },
  14. config = function()
  15. local null_ls = require('null-ls')
  16. require('mason-null-ls').setup({
  17. ensure_installed = { "black", "gofmt" },
  18. automatic_installation = true,
  19. automatic_setup = true,
  20. })
  21. null_ls.setup({
  22. sources = {
  23. null_ls.builtins.formatting.black,
  24. null_ls.builtins.formatting.gofmt,
  25. },
  26. })
  27. end,
  28. },
  29. -- Autocompletion
  30. {
  31. 'hrsh7th/nvim-cmp',
  32. event = 'InsertEnter',
  33. dependencies = {
  34. { "L3MON4D3/LuaSnip" },
  35. { 'hrsh7th/cmp-nvim-lsp' }, -- Required
  36. { 'hrsh7th/cmp-buffer' }, -- Optional
  37. { 'hrsh7th/cmp-path' }, -- Optional
  38. { 'saadparwaiz1/cmp_luasnip' }, -- Optional
  39. { 'hrsh7th/cmp-nvim-lua' }, -- Optional
  40. },
  41. config = function()
  42. local cmp = require('cmp')
  43. local luasnip = require("luasnip")
  44. local cmp_select = { behavior = cmp.SelectBehavior.Select }
  45. cmp.setup({
  46. sources = cmp.config.sources({
  47. { name = 'nvim_lsp' },
  48. { name = 'luasnip' },
  49. { name = 'path' },
  50. { name = 'buffer' },
  51. { name = 'nvim_lua' },
  52. }, {
  53. { name = 'buffer' },
  54. }),
  55. completion = {
  56. completeopt = 'menu,menuone,noinsert'
  57. },
  58. mapping = cmp.mapping.preset.insert({
  59. ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
  60. ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
  61. ['<Tab>'] = cmp.mapping.select_next_item(cmp_select),
  62. ['<S-Tab>'] = cmp.mapping.abort(),
  63. ["<CR>"] = cmp.mapping({
  64. i = function(fallback)
  65. -- and cmp.get_selected_entry()
  66. if cmp.visible() then
  67. cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
  68. else
  69. fallback()
  70. end
  71. end,
  72. s = cmp.mapping.confirm({ select = true }),
  73. c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
  74. }),
  75. }),
  76. experimental = {
  77. ghost_text = true
  78. },
  79. snippet = {
  80. expand = function(args)
  81. luasnip.lsp_expand(args.body)
  82. end,
  83. },
  84. })
  85. end
  86. },
  87. -- LSP
  88. {
  89. 'neovim/nvim-lspconfig',
  90. cmd = { 'LspInfo', 'LspInstall', 'LspStart' },
  91. event = { 'BufReadPre', 'BufNewFile' },
  92. dependencies = {
  93. { 'hrsh7th/cmp-nvim-lsp' },
  94. { 'williamboman/mason.nvim' },
  95. { 'williamboman/mason-lspconfig.nvim' },
  96. { "L3MON4D3/LuaSnip" }
  97. },
  98. init = function()
  99. -- Reserve a space in the gutter
  100. -- This will avoid an annoying layout shift in the screen
  101. vim.opt.signcolumn = 'yes'
  102. end,
  103. config = function()
  104. local lsp_defaults = require('lspconfig').util.default_config
  105. -- Add cmp_nvim_lsp capabilities settings to lspconfig
  106. -- This should be executed before you configure any language server
  107. lsp_defaults.capabilities = vim.tbl_deep_extend(
  108. 'force',
  109. lsp_defaults.capabilities,
  110. require('cmp_nvim_lsp').default_capabilities()
  111. )
  112. -- LspAttach is where you enable features that only work
  113. -- if there is a language server active in the file
  114. vim.api.nvim_create_autocmd('LspAttach', {
  115. desc = 'LSP actions',
  116. callback = function(event)
  117. local opts = { buffer = event.buf }
  118. vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
  119. vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
  120. vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
  121. vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
  122. vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
  123. vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
  124. vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
  125. vim.keymap.set('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
  126. vim.keymap.set({ 'n', 'x' }, '<leader>ft', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
  127. vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
  128. end,
  129. })
  130. require('mason-lspconfig').setup({
  131. ensure_installed = {
  132. 'tailwindcss',
  133. 'ts_ls',
  134. 'texlab',
  135. 'pyright',
  136. 'ltex',
  137. 'jsonls',
  138. 'bashls',
  139. },
  140. handlers = {
  141. -- this first function is the "default handler"
  142. -- it applies to every language server without a "custom handler"
  143. function(server_name)
  144. require('lspconfig')[server_name].setup({})
  145. end,
  146. }
  147. })
  148. end
  149. }
  150. }