Skip to content

Commit 97a2536

Browse files
committed
fix: lsp-zero and treesitter setup scopes for LSPs
fix: lean4 rice, organize the lazy lua script.
1 parent 9a8f047 commit 97a2536

File tree

6 files changed

+147
-57
lines changed

6 files changed

+147
-57
lines changed

.config/nvim/Dockerfile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ ENV USER="nvim"
55

66
RUN <<EOF
77
apk upgrade && apk update && \
8-
add --no-cache neovim python3 luarocks ripgrep git zig
8+
add --no-cache neovim python3 luarocks ripgrep git zig node
9+
10+
# zig: c compiler
11+
# node: provider for nvim's treesitter
12+
# python: provider for nvim
13+
914
EOF
1015

1116

@@ -28,6 +33,12 @@ pip3 install --no-cache-dir -r pynvim && \
2833

2934
deactivate
3035

36+
# set node provider
37+
# todo: set user for local npm install
38+
npm install -g nvim
39+
npm install -g tree-sitter-cli
40+
41+
3142
EOF
3243

3344

.config/nvim/after/plugin/lean.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-- local lsp_zero = require('lsp-zero')
12
-- Always show sign column.
23
-- The sign column is used by the LSP support to show diagnostics
34
-- (the E, W, etc. characters on the side)
@@ -38,7 +39,8 @@ local function on_attach(_, bufnr)
3839
end
3940

4041
-- Autocomplete using the Lean language server
41-
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
42+
--vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
43+
vim.api.nvim_set_option_value(bufnr, 'omnifunc', {'v:lua.vim.lsp.omnifunc'})
4244

4345
-- Support for triggering code actions (e.g. "Try this:" suggestions from `simp?`)
4446
cmd('n', '<leader>a', vim.lsp.buf.code_action)
@@ -50,7 +52,8 @@ local function on_attach(_, bufnr)
5052
cmd('n', '<leader>N', function() vim.diagnostic.goto_prev{popup_opts = {show_header = false}} end)
5153

5254
-- <leader>K will show all diagnostics for the current line in a popup window
53-
cmd('n', '<leader>K', function() vim.diagnostic.open_float(0, { scope = "line", header = false, focus = false }) end)
55+
-- cmd('n', '<leader>K', function() vim.diagnostic.open_float(0, { scope = "line", header = false, focus = false }) end)
56+
cmd('n', '<leader>K', function() vim.diagnostic.open_float(nil, { scope = "line", header = false, focus = false }) end)
5457

5558
-- <leader>q will load all errors in the current lean file into the location list
5659
-- (and then will open the location list)

.config/nvim/after/plugin/lsp.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
local lsp_zero = require('lsp-zero')
2-
3-
lsp_zero.on_attach(function(client, bufnr)
4-
local opts = {buffer = bufnr, remap = false}
5-
6-
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
7-
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
8-
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
9-
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
10-
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
11-
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
12-
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
13-
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
14-
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
15-
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
16-
end)
2+
--
3+
-- lsp_zero.on_attach(function(client, bufnr)
4+
-- local opts = {buffer = bufnr, remap = false}
5+
--
6+
-- vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
7+
-- vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
8+
-- vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
9+
-- vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
10+
-- vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
11+
-- vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
12+
-- vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
13+
-- vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
14+
-- vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
15+
-- vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
16+
-- end)
1717

1818
require('mason').setup({})
1919
require('mason-lspconfig').setup({

.config/nvim/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ require("settings") -- user.set
99
--require("user.packer")
1010
--require("plugins.packerSpecs") -- Ensure the plugins are loaded.
1111

12+
-- configure treesitter

.config/nvim/lua/config/lazy.lua

Lines changed: 113 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ require("lazy").setup({
3434
},
3535

3636

37-
{ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', },
37+
--{ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', },
38+
39+
{"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"},
3840
{ 'mbbill/undotree' },
3941
{ 'ms-jpq/coq_nvim', branch = 'coq' },
4042

@@ -50,6 +52,116 @@ require("lazy").setup({
5052
-- " - comment banner
5153
-- " - etc
5254

55+
-- lsp-zero
56+
{
57+
'VonHeikemen/lsp-zero.nvim',
58+
branch = 'v3.x',
59+
dependencies = {
60+
--- Uncomment these if you want to manage LSP servers from neovim
61+
{'williamboman/mason.nvim'},
62+
{'williamboman/mason-lspconfig.nvim'},
63+
64+
-- Autocompletion
65+
{
66+
'hrsh7th/nvim-cmp',
67+
event = 'InsertEnter',
68+
config = function()
69+
local cmp = require('cmp')
70+
71+
cmp.setup({
72+
sources = {
73+
{name = 'nvim_lsp'},
74+
},
75+
mapping = cmp.mapping.preset.insert({
76+
['<C-space>'] = cmp.mapping.complete(),
77+
['<C-u>'] = cmp.mapping.scroll_docs(-4),
78+
['<C-d>'] = cmp.mapping.scroll_docs(4),
79+
}),
80+
snippet = {
81+
expand = function(args)
82+
vim.snippet.expand(args.body)
83+
end,
84+
},
85+
})
86+
end
87+
},
88+
89+
-- LSP Support
90+
{
91+
'neovim/nvim-lspconfig',
92+
cmd = "LspInfo",
93+
event = {'BufReadPre', 'BufNewFile'},
94+
dependencies = {
95+
-- Autocompletion
96+
{'hrsh7th/cmp-nvim-lsp'},
97+
},
98+
init = function ()
99+
local lsp_defaults = require('lspconfig').util.default_config
100+
101+
-- add cmp_nvim_lsp capabilities settings to lspconfig
102+
-- this should be executed before you configure any language server
103+
lsp_defaults.capabilities = vim.tbl_deep_extend(
104+
'force',
105+
lsp_defaults.capabilities,
106+
require('cmp_nvim_lsp').default_capabilities()
107+
)
108+
109+
-- LspAttach is used to enable features when
110+
-- there is a language server active for the file
111+
vim.api.nvim_create_autocmd('LspAttach', {
112+
desc = 'LSP actions',
113+
callback = function (event)
114+
local opts = {buffer = event.buf}
115+
116+
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
117+
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
118+
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
119+
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
120+
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
121+
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
122+
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
123+
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
124+
vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
125+
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
126+
127+
end,
128+
})
129+
130+
--require('lspconfig').gleam.setup({})
131+
--require('lspconfig').ocamllsp.setup({})
132+
133+
end
134+
},
135+
136+
-- Snippets
137+
{'L3MON4D3/LuaSnip',lazy = true},
138+
139+
},
140+
},
141+
142+
{'julian/lean.nvim'},
143+
-- -- julian's lean.nvim LSP
144+
-- {
145+
-- 'julian/lean.nvim',
146+
-- dependencies = {
147+
-- 'VonHeikemen/lsp-zero.nvim',
148+
-- --'neovim/nvim-lspconfig',
149+
-- 'nvim-lua/plenary.nvim',
150+
151+
-- -- Autocompletion
152+
-- -- below already is being imported by
153+
-- -- lsp-zero dependency tree
154+
155+
-- --'hrsh7th/nvim-cmp',
156+
-- --'hrsh7th/cmp-nvim-lsp',
157+
-- --'hrsh7th/cmp-buffer',
158+
-- --'hrsh7th/cmp-path',
159+
-- },
160+
-- opts = {
161+
-- mappings = true,
162+
-- }
163+
-- },
164+
53165

54166
-- "=====> https://github.com/andweeb/presence.nvim
55167
-- { 'andweeb/presence.nvim' }
@@ -120,28 +232,7 @@ require("lazy").setup({
120232
-- " Optional: better Rnoweb support (LaTeX completion)
121233
{ 'lervag/vimtex' },
122234

123-
-- lsp-zero
124-
{
125-
'VonHeikemen/lsp-zero.nvim',
126-
branch = 'v3.x',
127-
dependencies = {
128-
--- Uncomment these if you want to manage LSP servers from neovim
129-
{'williamboman/mason.nvim'},
130-
{'williamboman/mason-lspconfig.nvim'},
131235

132-
-- LSP Support
133-
{'neovim/nvim-lspconfig'},
134-
135-
-- Autocompletion
136-
{'hrsh7th/nvim-cmp'},
137-
{'hrsh7th/cmp-nvim-lsp'},
138-
{
139-
'L3MON4D3/LuaSnip',
140-
lazy = true
141-
},
142-
143-
},
144-
},
145236

146237
-- NotebookNavigator for Python REPL
147238
{
@@ -201,24 +292,7 @@ require("lazy").setup({
201292
},
202293
},
203294

204-
-- julian's lean.nvim
205-
{
206-
'julian/lean.nvim',
207-
dependencies = {
208-
'VonHeikemen/lsp-zero.nvim',
209-
--'neovim/nvim-lspconfig',
210-
'nvim-lua/plenary.nvim',
211295

212-
-- Autocompletion
213-
'hrsh7th/nvim-cmp',
214-
--'hrsh7th/cmp-nvim-lsp',
215-
--'hrsh7th/cmp-buffer',
216-
--'hrsh7th/cmp-path',
217-
},
218-
opts = {
219-
mappings = true,
220-
}
221-
}
222296
},
223297
-- Configure any other settings here. See the documentation for more details.
224298
-- colorscheme that will be used when installing plugins.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ luac.out
4444
# -- misc ignore
4545
scripts/brk_*.conf
4646
coq_deps.txt
47+
perlnavigator.txt

0 commit comments

Comments
 (0)