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.

101 lines
3.2 KiB

2 weeks ago
  1. return {
  2. {
  3. 'williamboman/mason.nvim',
  4. lazy = false,
  5. opts = {},
  6. },
  7. -- Autocompletion
  8. {
  9. 'hrsh7th/nvim-cmp',
  10. event = 'InsertEnter',
  11. config = function()
  12. local cmp = require('cmp')
  13. cmp.setup({
  14. sources = {
  15. { name = 'nvim_lsp' },
  16. },
  17. mapping = cmp.mapping.preset.insert({
  18. ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
  19. ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
  20. ['<C-s>'] = cmp.mapping.confirm({ select = true }),
  21. ["<C-Space>"] = cmp.mapping.complete(),
  22. ['<Tab>'] = nil,
  23. ['<S-Tab>'] = nil,
  24. }),
  25. snippet = {
  26. expand = function(args)
  27. vim.snippet.expand(args.body)
  28. end,
  29. },
  30. })
  31. end
  32. },
  33. -- LSP
  34. {
  35. 'neovim/nvim-lspconfig',
  36. cmd = { 'LspInfo', 'LspInstall', 'LspStart' },
  37. event = { 'BufReadPre', 'BufNewFile' },
  38. dependencies = {
  39. { 'hrsh7th/cmp-nvim-lsp' },
  40. { 'williamboman/mason.nvim' },
  41. { 'williamboman/mason-lspconfig.nvim' },
  42. },
  43. init = function()
  44. -- Reserve a space in the gutter
  45. -- This will avoid an annoying layout shift in the screen
  46. vim.opt.signcolumn = 'yes'
  47. end,
  48. config = function()
  49. local lsp_defaults = require('lspconfig').util.default_config
  50. -- Add cmp_nvim_lsp capabilities settings to lspconfig
  51. -- This should be executed before you configure any language server
  52. lsp_defaults.capabilities = vim.tbl_deep_extend(
  53. 'force',
  54. lsp_defaults.capabilities,
  55. require('cmp_nvim_lsp').default_capabilities()
  56. )
  57. -- LspAttach is where you enable features that only work
  58. -- if there is a language server active in the file
  59. vim.api.nvim_create_autocmd('LspAttach', {
  60. desc = 'LSP actions',
  61. callback = function(event)
  62. local opts = { buffer = event.buf }
  63. vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
  64. vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
  65. vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
  66. vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
  67. vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
  68. vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
  69. vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
  70. vim.keymap.set('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
  71. vim.keymap.set({ 'n', 'x' }, '<leader>ft', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
  72. vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
  73. end,
  74. })
  75. require('mason-lspconfig').setup({
  76. ensure_installed = {
  77. 'tailwindcss',
  78. 'ts_ls',
  79. 'texlab',
  80. 'pyright',
  81. 'ltex',
  82. 'jsonls'
  83. },
  84. handlers = {
  85. -- this first function is the "default handler"
  86. -- it applies to every language server without a "custom handler"
  87. function(server_name)
  88. require('lspconfig')[server_name].setup({})
  89. end,
  90. }
  91. })
  92. end
  93. }
  94. }