Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
neovimconfig
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
codecraft
neovimconfig
Commits
228d55b4
Commit
228d55b4
authored
2 years ago
by
codecraft
Browse files
Options
Downloads
Patches
Plain Diff
Format lsp.lua
parent
18dfa001
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lua/codecraft/plugin/lsp/lsp.lua
+86
-86
86 additions, 86 deletions
lua/codecraft/plugin/lsp/lsp.lua
with
86 additions
and
86 deletions
lua/codecraft/plugin/lsp/lsp.lua
+
86
−
86
View file @
228d55b4
-- LSP settings.
-- LSP settings.
-- This function gets run when an LSP connects to a particular buffer.
-- This function gets run when an LSP connects to a particular buffer.
local
on_attach
=
function
(
_
,
bufnr
)
local
on_attach
=
function
(
_
,
bufnr
)
-- NOTE: Remember that lua is a real programming language, and as such it is possible
-- NOTE: Remember that lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself
-- to define small helper and utility functions so you don't have to repeat yourself
-- many times.
-- many times.
--
--
-- In this case, we create a function that lets us more easily define mappings specific
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
-- for LSP related items. It sets the mode, buffer and description for us each time.
local
nmap
=
function
(
keys
,
func
,
desc
)
local
nmap
=
function
(
keys
,
func
,
desc
)
if
desc
then
if
desc
then
desc
=
'
LSP:
'
..
desc
desc
=
"
LSP:
"
..
desc
end
end
vim
.
keymap
.
set
(
'n'
,
keys
,
func
,
{
buffer
=
bufnr
,
desc
=
desc
})
vim
.
keymap
.
set
(
"n"
,
keys
,
func
,
{
buffer
=
bufnr
,
desc
=
desc
})
end
end
if
_
.
server_capabilities
.
documentSymbolProvider
then
if
_
.
server_capabilities
.
documentSymbolProvider
then
require
(
'
nvim-navic
'
).
attach
(
_
,
bufnr
)
require
(
"
nvim-navic
"
).
attach
(
_
,
bufnr
)
end
end
nmap
(
'
<leader>rn
'
,
vim
.
lsp
.
buf
.
rename
,
'
[R]e[n]ame
'
)
nmap
(
"
<leader>rn
"
,
vim
.
lsp
.
buf
.
rename
,
"
[R]e[n]ame
"
)
nmap
(
'
<leader>ca
'
,
vim
.
lsp
.
buf
.
code_action
,
'
[C]ode [A]ction
'
)
nmap
(
"
<leader>ca
"
,
vim
.
lsp
.
buf
.
code_action
,
"
[C]ode [A]ction
"
)
nmap
(
'
<leader>di
'
,
vim
.
diagnostic
.
open_float
,
'
[D]iagnostic [I]nfo
'
)
nmap
(
"
<leader>di
"
,
vim
.
diagnostic
.
open_float
,
"
[D]iagnostic [I]nfo
"
)
nmap
(
'
<leader>dv
'
,
'
<cmd>Telescope diagnostics<CR>
'
,
'
[D]iagnostic [V]iew
'
)
nmap
(
"
<leader>dv
"
,
"
<cmd>Telescope diagnostics<CR>
"
,
"
[D]iagnostic [V]iew
"
)
nmap
(
'
gd
'
,
vim
.
lsp
.
buf
.
definition
,
'
[G]oto [D]efinition
'
)
nmap
(
"
gd
"
,
vim
.
lsp
.
buf
.
definition
,
"
[G]oto [D]efinition
"
)
nmap
(
'
gr
'
,
require
(
'
telescope.builtin
'
).
lsp_references
,
'
[G]oto [R]eferences
'
)
nmap
(
"
gr
"
,
require
(
"
telescope.builtin
"
).
lsp_references
,
"
[G]oto [R]eferences
"
)
nmap
(
'
gI
'
,
vim
.
lsp
.
buf
.
implementation
,
'
[G]oto [I]mplementation
'
)
nmap
(
"
gI
"
,
vim
.
lsp
.
buf
.
implementation
,
"
[G]oto [I]mplementation
"
)
nmap
(
'
<leader>D
'
,
vim
.
lsp
.
buf
.
type_definition
,
'
Type [D]efinition
'
)
nmap
(
"
<leader>D
"
,
vim
.
lsp
.
buf
.
type_definition
,
"
Type [D]efinition
"
)
nmap
(
'
<leader>ds
'
,
require
(
'
telescope.builtin
'
).
lsp_document_symbols
,
'
[D]ocument [S]ymbols
'
)
nmap
(
"
<leader>ds
"
,
require
(
"
telescope.builtin
"
).
lsp_document_symbols
,
"
[D]ocument [S]ymbols
"
)
nmap
(
'
<leader>ws
'
,
require
(
'
telescope.builtin
'
).
lsp_dynamic_workspace_symbols
,
'
[W]orkspace [S]ymbols
'
)
nmap
(
"
<leader>ws
"
,
require
(
"
telescope.builtin
"
).
lsp_dynamic_workspace_symbols
,
"
[W]orkspace [S]ymbols
"
)
-- See `:help K` for why this keymap
-- See `:help K` for why this keymap
nmap
(
'
<leader>K
'
,
vim
.
lsp
.
buf
.
hover
,
'
Hover Documentation
'
)
nmap
(
"
<leader>K
"
,
vim
.
lsp
.
buf
.
hover
,
"
Hover Documentation
"
)
nmap
(
'
<leader>k
'
,
vim
.
lsp
.
buf
.
signature_help
,
'
Signature Documentation
'
)
nmap
(
"
<leader>k
"
,
vim
.
lsp
.
buf
.
signature_help
,
"
Signature Documentation
"
)
-- Lesser used LSP functionality
-- Lesser used LSP functionality
nmap
(
'
gD
'
,
vim
.
lsp
.
buf
.
declaration
,
'
[G]oto [D]eclaration
'
)
nmap
(
"
gD
"
,
vim
.
lsp
.
buf
.
declaration
,
"
[G]oto [D]eclaration
"
)
nmap
(
'
<leader>wa
'
,
vim
.
lsp
.
buf
.
add_workspace_folder
,
'
[W]orkspace [A]dd Folder
'
)
nmap
(
"
<leader>wa
"
,
vim
.
lsp
.
buf
.
add_workspace_folder
,
"
[W]orkspace [A]dd Folder
"
)
nmap
(
'
<leader>wr
'
,
vim
.
lsp
.
buf
.
remove_workspace_folder
,
'
[W]orkspace [R]emove Folder
'
)
nmap
(
"
<leader>wr
"
,
vim
.
lsp
.
buf
.
remove_workspace_folder
,
"
[W]orkspace [R]emove Folder
"
)
nmap
(
'
<leader>wl
'
,
function
()
nmap
(
"
<leader>wl
"
,
function
()
print
(
vim
.
inspect
(
vim
.
lsp
.
buf
.
list_workspace_folders
()))
print
(
vim
.
inspect
(
vim
.
lsp
.
buf
.
list_workspace_folders
()))
end
,
'
[W]orkspace [L]ist Folders
'
)
end
,
"
[W]orkspace [L]ist Folders
"
)
-- Create a command `:Format` local to the LSP buffer
-- Create a command `:Format` local to the LSP buffer
vim
.
api
.
nvim_buf_create_user_command
(
bufnr
,
'
Format
'
,
function
(
_
)
vim
.
api
.
nvim_buf_create_user_command
(
bufnr
,
"
Format
"
,
function
(
_
)
vim
.
lsp
.
buf
.
format
()
vim
.
lsp
.
buf
.
format
()
end
,
{
desc
=
'
Format current buffer with LSP
'
})
end
,
{
desc
=
"
Format current buffer with LSP
"
})
end
end
-- Enable the following language servers
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
...
@@ -54,61 +54,61 @@ end
...
@@ -54,61 +54,61 @@ end
-- Add any additional override configuration in the following tables. They will be passed to
-- Add any additional override configuration in the following tables. They will be passed to
-- the `settings` field of the server config. You must look up that documentation yourself.
-- the `settings` field of the server config. You must look up that documentation yourself.
local
servers
=
{
local
servers
=
{
clangd
=
{},
clangd
=
{},
html
=
{},
html
=
{},
emmet_ls
=
{},
emmet_ls
=
{},
cssls
=
{},
cssls
=
{},
tsserver
=
{},
tsserver
=
{},
pyright
=
{},
pyright
=
{},
yamlls
=
{},
yamlls
=
{},
rust_analyzer
=
{
rust_analyzer
=
{
imports
=
{
imports
=
{
granularity
=
{
granularity
=
{
group
=
"module"
,
group
=
"module"
,
},
},
prefix
=
"self"
,
prefix
=
"self"
,
},
},
cargo
=
{
cargo
=
{
buildScripts
=
{
buildScripts
=
{
enable
=
true
,
enable
=
true
,
},
},
},
},
procMacro
=
{
procMacro
=
{
enable
=
true
enable
=
true
,
},
},
},
},
marksman
=
{},
marksman
=
{},
lua_ls
=
{
lua_ls
=
{
Lua
=
{
Lua
=
{
workspace
=
{
checkThirdParty
=
false
},
workspace
=
{
checkThirdParty
=
false
},
telemetry
=
{
enable
=
false
},
telemetry
=
{
enable
=
false
},
},
},
},
},
}
}
--
--
require
(
'
completion
'
)
require
(
"
completion
"
)
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local
capabilities
=
vim
.
lsp
.
protocol
.
make_client_capabilities
()
local
capabilities
=
vim
.
lsp
.
protocol
.
make_client_capabilities
()
capabilities
=
require
(
'
cmp_nvim_lsp
'
).
default_capabilities
(
capabilities
)
capabilities
=
require
(
"
cmp_nvim_lsp
"
).
default_capabilities
(
capabilities
)
capabilities
.
textDocument
.
completion
.
completionItem
.
snippetSupport
=
true
capabilities
.
textDocument
.
completion
.
completionItem
.
snippetSupport
=
true
-- Setup mason so it can manage external tooling
-- Setup mason so it can manage external tooling
require
(
'
mason
'
).
setup
()
require
(
"
mason
"
).
setup
()
-- Ensure the servers above are installed
-- Ensure the servers above are installed
local
mason_lspconfig
=
require
'
mason-lspconfig
'
local
mason_lspconfig
=
require
(
"
mason-lspconfig
"
)
mason_lspconfig
.
setup
{
mason_lspconfig
.
setup
(
{
ensure_installed
=
vim
.
tbl_keys
(
servers
),
ensure_installed
=
vim
.
tbl_keys
(
servers
),
}
}
)
mason_lspconfig
.
setup_handlers
{
mason_lspconfig
.
setup_handlers
(
{
function
(
server_name
)
function
(
server_name
)
require
(
'
lspconfig
'
)[
server_name
].
setup
{
require
(
"
lspconfig
"
)[
server_name
].
setup
(
{
capabilities
=
capabilities
,
capabilities
=
capabilities
,
on_attach
=
on_attach
,
on_attach
=
on_attach
,
settings
=
servers
[
server_name
],
settings
=
servers
[
server_name
],
}
})
end
,
end
,
}
}
)
-- Turn on lsp status information
-- Turn on lsp status information
require
(
'
fidget
'
).
setup
()
require
(
"
fidget
"
).
setup
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment