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.

135 lines
4.5 KiB

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