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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
return {
"VonHeikemen/lsp-zero.nvim",
dependencies = {
{'williamboman/mason.nvim'},
{'williamboman/mason-lspconfig.nvim'},
{'neovim/nvim-lspconfig'},
{'hrsh7th/nvim-cmp'},
{'hrsh7th/cmp-nvim-lsp'},
},
config = function()
-- "Avoids annoying layout shift in the screen"
vim.opt.signcolumn = 'yes'
-- Adds cmp_nvim_lsp capabilities settings to lspconfig
local lspconfig_defaults = require('lspconfig').util.default_config
lspconfig_defaults.capabilities = vim.tbl_deep_extend(
'force',
lspconfig_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
)
-- This is where you enable features that only work
-- if there is a language server active in the file
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function(event)
local opts = {buffer = event.buf}
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
end,
})
-- to learn how to use mason.nvim
-- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md
require('mason').setup({})
require('mason-lspconfig').setup({
ensure_installed = {},
handlers = {
function(server_name)
require('lspconfig')[server_name].setup({})
end,
},
})
require('lspconfig').harper_ls.setup {
settings = {
["harper-ls"] = {
linters = {
spell_check = false,
spelled_numbers = false,
an_a = true,
sentence_capitalization = false,
unclosed_quotes = true,
wrong_quotes = false,
long_sentences = false,
repeated_words = false,
spaces = true,
matcher = true,
correct_number_suffix = true,
number_suffix_capitalization = true,
multiple_sequential_pronouns = true,
linking_verbs = false,
avoid_curses = false,
terminating_conjunctions = true
}
}
},
}
local cmp = require('cmp')
cmp.setup({
sources = {
{name = 'nvim_lsp'},
},
snippet = {
expand = function(args)
-- You need Neovim v0.10 to use vim.snippet
vim.snippet.expand(args.body)
end,
},
-- mapping = cmp.mapping.preset.insert({}),
mapping = {
["<Tab>"] = cmp.mapping.select_next_item(),
["<S-Tab>"] = cmp.mapping.select_prev_item(),
["<C-Tab>"] = cmp.mapping.complete(),
}
})
end,
-- "VonHeikemen/lsp-zero.nvim",
-- dependencies = {
-- {'williamboman/mason.nvim'},
-- {'williamboman/mason-lspconfig.nvim'},
--
-- {'neovim/nvim-lspconfig'},
-- {'hrsh7th/nvim-cmp'},
-- {'hrsh7th/cmp-nvim-lsp'},
--
-- {'L3MON4D3/LuaSnip'},
-- },
--
-- config = function()
-- local lsp_zero = require('lsp-zero')
--
-- lsp_zero.on_attach(function(client, bufnr)
-- -- see :help lsp-zero-keybindings
-- -- to learn the available actions
-- lsp_zero.default_keymaps({buffer = bufnr})
-- end)
--
--
-- -- to learn how to use mason.nvim
-- -- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md
-- require('mason').setup({})
--
-- require('mason-lspconfig').setup({
-- ensure_installed = {},
-- handlers = {
-- function(server_name)
-- require('lspconfig')[server_name].setup({})
-- end,
-- },
-- })
--
-- require('lspconfig').harper_ls.setup {
-- settings = {
-- ["harper-ls"] = {
-- linters = {
-- spell_check = false,
-- spelled_numbers = false,
-- an_a = true,
-- sentence_capitalization = false,
-- unclosed_quotes = true,
-- wrong_quotes = false,
-- long_sentences = false,
-- repeated_words = false,
-- spaces = true,
-- matcher = true,
-- correct_number_suffix = true,
-- number_suffix_capitalization = true,
-- multiple_sequential_pronouns = true,
-- linking_verbs = false,
-- avoid_curses = false,
-- terminating_conjunctions = true
-- }
-- }
-- },
-- }
-- end
}
|