118 lines
3.7 KiB
Lua
118 lines
3.7 KiB
Lua
-- Initialize Mason and specify which language servers to install
|
|
--require("mason").setup()
|
|
--require("mason-lspconfig").setup({
|
|
-- ensured_installed = { "rust_analyzer" }
|
|
--})
|
|
--
|
|
---- Define lspconfig settings for rust_analyzer
|
|
--local on_attach = function(_, _)
|
|
-- local opts = { buffer = bufnr, remap = false }
|
|
-- vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
|
--end
|
|
--
|
|
--local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
--
|
|
---- Configure autocomplete using nvim-cmp
|
|
--local cmp = require("cmp")
|
|
--cmp.setup({
|
|
-- mapping = {
|
|
-- ["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
-- ["<C-n>"] = cmp.mapping.select_next_item(),
|
|
-- ["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
-- ["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
-- ["<C-Space>"] = cmp.mapping.complete(),
|
|
-- ["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
|
-- ["<CR>"] = cmp.mapping.confirm({ select = true }),
|
|
-- },
|
|
-- sources = {
|
|
-- { name = 'nvim_lsp' },
|
|
-- { name = 'buffer' },
|
|
-- { name = 'path' },
|
|
-- },
|
|
-- experimental = { ghost_text = false },
|
|
-- formatting = { fields = { 'menu', 'abbr', 'kind' } },
|
|
-- confirm_opts = { behavior = cmp.ConfirmBehavior.Replace, select = false },
|
|
-- window = {
|
|
-- --completion = cmp.config.window.bordered(),
|
|
-- --documentation = cmp.config.window.bordered(),
|
|
-- },
|
|
-- capabilities = capabilities,
|
|
--})
|
|
--
|
|
---- Set up Rust Analyzer
|
|
--local lspconfig = require('lspconfig')
|
|
--lspconfig.rust_analyzer.setup {
|
|
-- capabilities = capabilities,
|
|
-- on_attach = on_attach
|
|
--}
|
|
--vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
|
|
--vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
|
--vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
|
---- vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
|
|
|
|
|
|
-- old
|
|
--require("mason").setup()
|
|
--require("mason-lspconfig").setup({
|
|
-- ensure_installed = { "rust_analyzer" }
|
|
--})
|
|
--
|
|
--local on_attach = function(_, _)
|
|
-- local opts = {buffer = bufnr, remap = false}
|
|
-- vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
|
--end
|
|
--
|
|
--local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
--require("configs.nvim-cmp")
|
|
--require('nvim-cmp').setup{}
|
|
--require('cmp').setup({
|
|
-- mapping = {
|
|
-- ['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
-- ['<C-n>'] = cmp.mapping.select_next_item(),
|
|
-- ['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
-- ['<C-Space>'] = cmp.mapping.complete(),
|
|
-- ['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
-- },
|
|
-- sources = {
|
|
-- { name = 'nvim_lsp' },
|
|
-- { name = 'buffer' },
|
|
-- { name = 'path' },
|
|
-- },
|
|
-- experimental = { ghost_text = false },
|
|
-- formatting = { fields = { 'menu', 'abbr', 'kind' } },
|
|
-- confirm_opts = { behavior = cmp.ConfirmBehavior.Replace, select = false },
|
|
-- window = {
|
|
-- completion = cmp.config.window.bordered(),
|
|
-- documentation = cmp.config.window.bordered(),
|
|
-- },
|
|
-- capabilities = capabilities,
|
|
--})
|
|
--
|
|
--
|
|
--require("lspconfig").rust_analyzer.setup {
|
|
-- capabilities = capabilities
|
|
-- on_attach = on_attach
|
|
--}
|
|
|
|
--local lsp = require('lsp-zero').preset({})
|
|
--
|
|
-- lsp.on_attach(function(client, bufnr)
|
|
-- local opts = {buffer = bufnr, remap = false}
|
|
--
|
|
-- vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
|
-- end)
|
|
--
|
|
----lsp['rust_analyzer'].setup({
|
|
---- capabilities = capabilities,
|
|
---- on_attach = on_attach
|
|
----})
|
|
--
|
|
--lsp.ensure_installed({
|
|
-- 'tsserver',
|
|
-- 'eslint',
|
|
-- 'rust_analyzer'
|
|
--})
|
|
--lsp.setup()
|
|
----lsp.rust_analyzer.setup()
|