Skip to content

custom on_attach for every server #24

Answered by VonHeikemen
bugabinga asked this question in Q&A
Discussion options

You must be logged in to vote

You can use the .on_attach function.

To use navic, you can try to create a buffer local variable and use that to control the function.

local lsp = require('lsp-zero')
lsp.preset('recommended')

lsp.on_attach(function(client, bufnr)
  if vim.b.lsp_attached then return  end
  vim.b.lsp_attached = true

  require('nvim-navic').attach(client, bufnr)
end)

lsp.setup()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bugabinga
Comment options

Answer selected by bugabinga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants