-
Notifications
You must be signed in to change notification settings - Fork 5
/
lsp.lua
113 lines (89 loc) · 3.39 KB
/
lsp.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
local on_attach = function(_, bufnr)
local bufmap = function(keys, func)
vim.keymap.set('n', keys, func, { buffer = bufnr})
end
--
-- vim.api.nvim_set_keymap('n', '<leader>t', '<cmd>NvimTreeToggle<CR>', { noremap=true, silent=true })
--
-- -- bufmap('<F5>', '<cmd>MarkDownPreview<CR>')
--
-- bufmap('<c-/>', require("telescope.builtin").current_buffer_fuzzy_find)
-- bufmap('<leader>ff',require("telescope.builtin").find_files)
-- bufmap('<leader>fg', require("telescope.builtin").live_grep)
-- bufmap('<leader>fh', require("telescope.builtin").help_tags)
-- bufmap('<leader>fc', require("telescope.builtin").commands)
-- bufmap('<leader>fb', require("telescope.builtin").buffers)
--
--
bufmap('<leader>gr', require('telescope.builtin').lsp_references )
bufmap('<leader>s', require('telescope.builtin').lsp_document_symbols)
bufmap('<leader>S', require('telescope.builtin').lsp_dynamic_workspace_symbols)
bufmap('<leader>r', vim.lsp.buf.rename)
bufmap('<leader>a', vim.lsp.buf.code_action)
bufmap('<leader>gd', vim.lsp.buf.definition)
bufmap('<leader>gD', vim.lsp.buf.declaration)
bufmap('<leader>gi', vim.lsp.buf.implementation)
bufmap('<leader>D', vim.lsp.buf.type_definition)
bufmap('K', vim.lsp.buf.hover)
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, {})
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- Mason
require("mason").setup()
require("mason-lspconfig").setup_handlers({
function(server_name)
require("lspconfig")[server_name].setup {
on_attach = on_attach,
capabilities = capabilities
}
end,
["lua_ls"] = function()
require('neodev').setup()
require("lspconfig").lua_ls.setup {
on_attach = on_attach,
capabilities = capabilities,
lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
}
end,
['pyright'] = function()
require("lspconfig").pyright.setup {
on_attach = on_attach,
capabilities = capabilities,
filetypes = {'python'},
}
end,
['tsserver'] = function ()
require('lspconfig').tsserver.setup {
on_attach = on_attach,
capabilities = capabilities,
cmd = {'typescript-language-server', "--stdio"},
filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" },
init_options = { hostInfo = "neovim" },
single_file_support = true,
}
end,
['clangd'] = function ()
require('lspconfig').clangd.setup {
on_attach = on_attach,
capabilities = capabilities,
cmd = { 'clangd' },
filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
single_file_support = true,
}
end,
['marksman'] = function()
require'lspconfig'.marksman.setup{
on_attach = on_attach,
capabilities = capabilities,
cmd = { "marksman", "server" },
filetypes = { "markdown", "markdown.mdx" },
single_file_support = true,
}
end,
})