1234567891011121314151617181920212223242526272829303132333435363738394041 |
- local lsp = require("lsp-zero")
- lsp.preset("recommended")
- lsp.ensure_installed({
- 'tsserver',
- 'eslint',
- 'sumneko_lua',
- 'rust_analyzer',
- 'pylsp',
- 'nimls',
- 'bashls',
- 'jsonls',
- })
- local cmp = require('cmp')
- local cmp_select = {behavior = cmp.SelectBehavior.Select}
- local cmp_mappings = lsp.defaults.cmp_mappings({
- ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
- ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
- ['<C-y>'] = cmp.mapping.confirm({select =true}),
- ['<C-Space>'] = cmp.mapping.complete(),
- })
- lsp.set_preferences({
- sign_icons = {}
- })
- lsp.on_attach(function(client, bufnr)
- local opts = {buffer = bufnr, remap = false}
- vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
- vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
- vim.keymap.set("n", "gt", function() vim.lsp.buf.type_definition() end, opts)
- vim.keymap.set("n", "gi", function() vim.lsp.buf.implementation() end, opts)
- vim.keymap.set("n", "<leader>r", function() vim.lsp.buf.rename() end, opts)
- end)
- lsp.setup()
|