Comments (9)
I think setting single_file_support = false
in the setup function should solve this
from kickstart.nvim.
I myself stumbled upon this issue today. Turning off single file support does prevent multiple instances of sumneko_lua
from being attached to the file after the sourcing in the auto-command; however, what if we need single_file_support
?
To solve this problem, I wrote a few lines of code that sort of wrap around your require('lspconfig').sumneko_lua.setup{}
logic.
Note that this assumes you are calling the setup{}
function in the same file containing the auto-command. For me, that's inside the plugins.lua
file:
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
...Your other config...
--Setting up language servers
local lspconfig = require("lspconfig")
local start_sumneko_lua = true --boolean defaults to true, otherwise, the server will never start
local current_buf_id = vim.api.nvim_get_current_buf()
local servers_attached_to_current_buf = vim.lsp.get_active_clients({bufnr = current_buf_id})
for _, server in ipairs(servers_attached_to_current_buf) do
if server.name == "sumneko_lua" then --an instance of sumneko_lua is already attached to the buffer
start_sumneko_lua = false
end
end
--After that, all you have to do is to wrap sumneko lua's setup() call inside a conditional using the boolean
if start_sumneko_lua then
lspconfig.sumneko_lua.setup{
-- yada yada yada
}
end
--Other servers don't need this, so their setup can be called as usual
lspconfig.pyright.setup{
}
--yada yada yada...
The idea is simply to use some kind of "flag" to determine whether or not to call the setup() function for sumneko_lua (since the setup function determines the availability of the language server). The flag defaults to true
but will be switched to false
if the current buffer already has an instance of sumneko_lua
attached to it.
Granted, the code is a bit inelegant and 'hackish', but it worked without any issues for me because all my plugin configuration is inside packer.nvim's plugin specification file (plugins.lua
).
I hope this helps.
from kickstart.nvim.
Strange, on my machine it just respawns lua-language-server
but never has more than one instance running at a time. Are you getting multiple instances running concurrently? Seems like an easy enough solution would be to remove this source
that runs every time we save init.lua
.
from kickstart.nvim.
I believe the problem stems from L53
-- Automatically source and re-compile packer whenever you save this init.lua
local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })
vim.api.nvim_create_autocmd('BufWritePost', {
command = 'source <afile> | PackerCompile',
group = packer_group,
pattern = vim.fn.expand '$MYVIMRC',
})
Removing that line makes it so that only 1 client spawns.
from kickstart.nvim.
Strange, on my machine it just respawns lua-language-server but never has more than one instance running at a time. Are you getting multiple instances running concurrently? Seems like an easy enough solution would be to remove this source that runs every time we save init.lua.
Locking at LspInfo
I would say there are multiple instances. Saving also uses increasingly more cpu each consequent time
from kickstart.nvim.
I believe the problem stems from L53
Yes, I know but getting rid of it will also stop auto-sourcing. The offender is the source <afile>
part. I was hoping that there might be a trick to have it lazy init the server.
from kickstart.nvim.
Looks like this prevents the multiple start ups, thx @VonHeikemen!
from kickstart.nvim.
Fix for another config was to comment out workspace = { library = vim.api.nvim_get_runtime_file('', true) },
before that it would be very slowly starting server and it was starting always 2 server at the same time.
from kickstart.nvim.
Problem happens when you source the file more than once. I would just put all the language servers inside an if
that checks the value of a global variable.
if vim.g.user_lsp_setup == nil then
vim.g.user_lsp_setup = true
require('lspconfig').sumneko_lua.setup({
on_attach = on_attach,
capabilities = capabilities,
--- more code.....
})
require('lspconfig').tsserver.setup({
on_attach = on_attach,
capabilities = capabilities,
})
end
from kickstart.nvim.
Related Issues (20)
- Kickstart calls `kickstart-lsp-highlight` augroup regardless of support HOT 8
- I don't know what this error is HOT 17
- Gitsignes errors whenever there is not a git repo in the parent folder. HOT 3
- Error in loading the kickstarter config in kali WSL package. HOT 2
- How to install this HOT 5
- Align color scheme with kitty HOT 5
- Initial start causes OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0 on plugin install on Windows HOT 5
- References highlight blinks every time the cursor is moved HOT 5
- LSP for html config HOT 8
- Telescope bindings don't work. HOT 11
- How do I add language specific LSP keymaps? HOT 6
- Language server does not install using termux on android HOT 1
- Language servers removed from `servers` table still take affect HOT 3
- telescope(?) issue in `init.lua` HOT 6
- Can we please enable DISCUSSIONS on this repo? HOT 4
- Telescope Current Buffer Fuzzy Find is showing last result HOT 4
- Debug Test For Go Not Working HOT 7
- Isnβt `hlsearch` the default option? Iβm missing something?
- Custom location of `lazy-lock.json` file HOT 3
- turn inlay hints on by default? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kickstart.nvim.