LSP working

This commit is contained in:
Eric Olerud 2025-03-30 23:27:34 -04:00
parent 2086ea6353
commit 61dbec0639
2 changed files with 119 additions and 15 deletions

View File

@ -368,7 +368,8 @@ require('lazy').setup({
--]]
{ -- LSP
{ -- init.lua LSP config
--[[ init.lua LSP config
{
'folke/lazydev.nvim',
ft = 'lua', -- only load on lua files
opts = {
@ -379,6 +380,7 @@ require('lazy').setup({
},
},
},
--]]
{ -- blink autocompletion
'saghen/blink.cmp',
dependencies = { 'rafamadriz/friendly-snippets' },
@ -419,19 +421,8 @@ require('lazy').setup({
},
opts_extend = { 'sources.default' },
},
{ -- Built-in Neovim LSP support
vim.lsp.config('*', {
capabilities = {
textDocument = {
semanticTokens = {
multilineTokenSupport = true,
},
},
},
root_markers = { '.git' },
}),
},
{ -- Mason (LSP package manager)
--[[ Mason (LSP package manager)
{
'williamboman/mason.nvim',
dependencies = { 'WhoIsSethDaniel/mason-tool-installer.nvim' },
config = function()
@ -456,6 +447,7 @@ require('lazy').setup({
require('mason').setup()
end,
},
--]]
{ -- FZF (Telescope replacement)
'ibhagwan/fzf-lua',
@ -476,10 +468,12 @@ require('lazy').setup({
end,
},
{ -- LSP loading info in the bottom-right corner
--[[ LSP loading info in the bottom-right corner
{
'j-hui/fidget.nvim',
opts = {},
},
--]]
},
--[[
@ -965,6 +959,7 @@ require('lazy').setup({
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
{ import = 'custom.plugins' },
{ import = 'misc' },
{ import = 'lsp' },
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the

109
lua/lsp/lsp.lua Normal file
View File

@ -0,0 +1,109 @@
return {
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
'saghen/blink.cmp',
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
{ 'folke/lazydev.nvim', opts = {} },
-- Useful status updates for LSP.
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ 'j-hui/fidget.nvim', opts = {} },
},
config = function()
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
-- Automatically highlight copies of the hovered word and then clear on cursor move
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
callback = vim.lsp.buf.clear_references,
})
end
end,
})
local servers = {
clangd = {},
-- gopls = {},
-- pyright = {},
rust_analyzer = {},
powershell_es = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`tsserver`) will work just fine
-- tsserver = {},
--
lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = 'Replace',
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
},
}
require('mason').setup()
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup {
handlers = {
function(server_name)
local server = servers[server_name] or {}
server.capabilities = require('blink.cmp').get_lsp_capabilities(server.capabilities)
require('lspconfig')[server_name].setup(server)
end,
powershell_es = function()
local lspconfig = require 'lspconfig'
lspconfig.powershell_es.setup {
init_options = { enableProfileLoading = false },
filetypes = { 'ps1' },
on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
end,
settings = { powershell = { codeFormatting = { Preset = 'OTBS' } } },
}
end,
},
}
-- Godot's LSP - Requires Godot to be running
if vim.fn.has 'win32' == 1 then
require('lspconfig')['gdscript'].setup {
cmd = { 'ncat', '127.0.0.1', '6005' },
name = 'godot',
}
else
require('lspconfig')['gdscript'].setup {
cmd = vim.lsp.rpc.connect('127.0.0.1', 6005),
name = 'godot',
}
end
end,
}