tangled
alpha
login
or
join now
shailpatels.me
/
nvim
0
fork
atom
nvim dot files
0
fork
atom
overview
issues
pulls
pipelines
format
shailpatels.me
6 months ago
77615ee6
2f74e960
+110
-110
1 changed file
expand all
collapse all
unified
split
lua
plugins
lsp.lua
+110
-110
lua/plugins/lsp.lua
···
1
1
return {
2
2
{
3
3
-
{
4
4
-
"williamboman/mason.nvim",
5
5
-
config = function()
6
6
-
require('mason').setup()
7
7
-
end
8
8
-
},
3
3
+
"williamboman/mason.nvim",
4
4
+
config = function()
5
5
+
require('mason').setup()
6
6
+
end
7
7
+
},
9
8
10
10
-
{
11
11
-
"williamboman/mason-lspconfig.nvim",
12
12
-
dependencies = {
13
13
-
"williamboman/mason.nvim"
14
14
-
},
15
15
-
opts = {
16
16
-
ensure_installed = { "pyright", "rust_analyzer", "zls", "intelephense", "clangd" },
17
17
-
automatic_enable = false,
18
18
-
},
9
9
+
{
10
10
+
"williamboman/mason-lspconfig.nvim",
11
11
+
dependencies = {
12
12
+
"williamboman/mason.nvim"
13
13
+
},
14
14
+
opts = {
15
15
+
ensure_installed = { "pyright", "rust_analyzer", "zls", "intelephense", "clangd", "lua_ls" },
16
16
+
automatic_enable = false,
19
17
},
18
18
+
},
20
19
21
21
-
{
22
22
-
"neovim/nvim-lspconfig",
23
23
-
config = function()
24
24
-
local lspconfig = require('lspconfig')
25
25
-
local capabilities = require('cmp_nvim_lsp').default_capabilities()
20
20
+
{
21
21
+
"neovim/nvim-lspconfig",
22
22
+
config = function()
23
23
+
local lspconfig = require('lspconfig')
24
24
+
local capabilities = require('cmp_nvim_lsp').default_capabilities()
26
25
27
27
-
local on_attach = function(client, bufnr)
28
28
-
local bufopts = { noremap = true, silent = true, buffer = bufnr }
29
29
-
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
30
30
-
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
31
31
-
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
32
32
-
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
33
33
-
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
26
26
+
local on_attach = function(client, bufnr)
27
27
+
local bufopts = { noremap = true, silent = true, buffer = bufnr }
28
28
+
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
29
29
+
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
30
30
+
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
31
31
+
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
32
32
+
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
34
33
35
35
-
vim.keymap.set({'n','v'}, '<space>ca', function()
36
36
-
vim.lsp.buf.code_action()
37
37
-
end, bufopts)
34
34
+
vim.keymap.set({'n','v'}, '<space>ca', function()
35
35
+
vim.lsp.buf.code_action({}, bufnr)
36
36
+
end, bufopts)
38
37
39
39
-
vim.keymap.set({'n','v'}, '<space>f', function()
40
40
-
vim.lsp.buf.format({ async = true })
41
41
-
end, bufopts)
42
42
-
end
38
38
+
vim.keymap.set({'n','v'}, '<space>f', function()
39
39
+
vim.lsp.buf.format({ async = true, bufnr = bufnr })
40
40
+
end, bufopts)
41
41
+
end
43
42
44
44
-
lspconfig.pyright.setup({ on_attach = on_attach, capabilities = capabilities })
45
45
-
lspconfig.tsserver.setup({ on_attach = on_attach, capabilities = capabilities })
46
46
-
lspconfig.intelephense.setup({ on_attach = on_attach, capabilities = capabilities })
47
47
-
lspconfig.clangd.setup({ on_attach = on_attach, capabilities = capabilities })
43
43
+
lspconfig.pyright.setup({ on_attach = on_attach, capabilities = capabilities })
44
44
+
lspconfig.intelephense.setup({ on_attach = on_attach, capabilities = capabilities })
45
45
+
lspconfig.clangd.setup({ on_attach = on_attach, capabilities = capabilities })
46
46
+
lspconfig.lua_ls.setup({ on_attach = on_attach, capabilities = capabilities })
48
47
49
49
-
lspconfig.rust_analyzer.setup({
50
50
-
on_attach = on_attach,
51
51
-
capabilities = capabilities,
52
52
-
settings = {
53
53
-
["rust-analyzer"] = {
54
54
-
imports = {
55
55
-
granularity = {
56
56
-
group = "module",
57
57
-
},
58
58
-
prefix = "self",
48
48
+
lspconfig.rust_analyzer.setup({
49
49
+
on_attach = on_attach,
50
50
+
capabilities = capabilities,
51
51
+
settings = {
52
52
+
["rust-analyzer"] = {
53
53
+
imports = {
54
54
+
granularity = {
55
55
+
group = "module",
59
56
},
60
60
-
cargo = {
61
61
-
buildScripts = {
62
62
-
enable = true,
63
63
-
},
57
57
+
prefix = "self",
58
58
+
},
59
59
+
cargo = {
60
60
+
buildScripts = {
61
61
+
enable = true,
64
62
},
65
65
-
procMacro = {
66
66
-
enable = true
67
67
-
},
68
68
-
}
63
63
+
},
64
64
+
procMacro = {
65
65
+
enable = true
66
66
+
},
69
67
}
70
70
-
})
68
68
+
}
69
69
+
})
71
70
72
72
-
lspconfig.zls.setup({
73
73
-
on_attach = on_attach,
74
74
-
capabilities = capabilities,
75
75
-
settings = {
76
76
-
zls = {
77
77
-
zig_exe_path = (function()
78
78
-
local handle = io.popen('which zig 2> /dev/null')
79
79
-
if handle then
80
80
-
local result = handle:read("*a")
81
81
-
handle:close()
82
82
-
-- Remove trailing newline
83
83
-
return result:gsub("[\n\r]", "")
84
84
-
end
85
85
-
-- Fallback to a default path or return nil if which command fails
86
86
-
return nil
87
87
-
end)(),
88
88
-
}
71
71
+
lspconfig.zls.setup({
72
72
+
on_attach = on_attach,
73
73
+
capabilities = capabilities,
74
74
+
settings = {
75
75
+
zls = {
76
76
+
zig_exe_path = (function()
77
77
+
local handle = io.popen('which zig 2> /dev/null')
78
78
+
if handle then
79
79
+
local result = handle:read("*a")
80
80
+
handle:close()
81
81
+
-- Remove trailing newline
82
82
+
return result:gsub("[\n\r]", "")
83
83
+
end
84
84
+
-- Fallback to a default path or return nil if which command fails
85
85
+
return nil
86
86
+
end)(),
89
87
}
90
90
-
})
91
91
-
end,
92
92
-
},
88
88
+
}
89
89
+
})
90
90
+
end,
91
91
+
},
93
92
94
94
-
{
95
95
-
'hrsh7th/nvim-cmp',
96
96
-
dependencies = {
97
97
-
'hrsh7th/cmp-nvim-lsp',
98
98
-
'hrsh7th/cmp-buffer',
99
99
-
'hrsh7th/cmp-path',
100
100
-
'L3MON4D3/LuaSnip',
101
101
-
},
102
102
-
config = function()
103
103
-
local cmp = require('cmp')
104
104
-
cmp.setup({
105
105
-
snippet = {
106
106
-
expand = function(args)
107
107
-
require('luasnip').lsp_expand(args.body)
108
108
-
end,
109
109
-
},
110
110
-
mapping = cmp.mapping.preset.insert({
111
111
-
['<C-b>'] = cmp.mapping.scroll_docs(-4),
112
112
-
['<C-f>'] = cmp.mapping.scroll_docs(4),
113
113
-
['<C-Space>'] = cmp.mapping.complete(),
114
114
-
['<C-e>'] = cmp.mapping.abort(),
115
115
-
['<CR>'] = cmp.mapping.confirm({ select = true }),
116
116
-
['<C-p>'] = cmp.mapping.select_prev_item(),
117
117
-
['<C-n>'] = cmp.mapping.select_next_item(),
118
118
-
}),
119
119
-
sources = cmp.config.sources({
120
120
-
{name = 'nvim_lsp' },
121
121
-
{name = 'buffer' },
122
122
-
{name = 'path' },
123
123
-
})
124
124
-
})
125
125
-
end,
93
93
+
{
94
94
+
'hrsh7th/nvim-cmp',
95
95
+
dependencies = {
96
96
+
'hrsh7th/cmp-nvim-lsp',
97
97
+
'hrsh7th/cmp-buffer',
98
98
+
'hrsh7th/cmp-path',
99
99
+
'L3MON4D3/LuaSnip',
126
100
},
127
127
-
}
101
101
+
config = function()
102
102
+
local cmp = require('cmp')
103
103
+
local luasnip = require('luasnip')
128
104
105
105
+
cmp.setup({
106
106
+
snippet = {
107
107
+
expand = function(args)
108
108
+
luasnip.lsp_expand(args.body)
109
109
+
end,
110
110
+
},
111
111
+
mapping = cmp.mapping.preset.insert({
112
112
+
['<C-b>'] = cmp.mapping.scroll_docs(-4),
113
113
+
['<C-f>'] = cmp.mapping.scroll_docs(4),
114
114
+
['<C-Space>'] = cmp.mapping.complete(),
115
115
+
['<C-e>'] = cmp.mapping.abort(),
116
116
+
['<CR>'] = cmp.mapping.confirm({ select = true }),
117
117
+
['<C-p>'] = cmp.mapping.select_prev_item(),
118
118
+
['<C-n>'] = cmp.mapping.select_next_item(),
119
119
+
}),
120
120
+
sources = cmp.config.sources({
121
121
+
{name = 'nvim_lsp' },
122
122
+
{name = 'luasnip' },
123
123
+
{name = 'buffer' },
124
124
+
{name = 'path' },
125
125
+
})
126
126
+
})
127
127
+
end,
128
128
+
},
129
129
}