diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-06-24 11:10:08 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-06-24 11:10:08 +0200 |
commit | 0aa14ca7e1cd984eed359af6447a2df16e4dd8e1 (patch) | |
tree | 05944264786b2c1c007169f2d997a5379033dba4 | |
parent | b4eec62be82f8e48f3a099fbb321f9af86e07afb (diff) |
[nvim] force attach LSP servers to buffer with filetype set
-rw-r--r-- | .config/nvim/plugins.vim | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.config/nvim/plugins.vim b/.config/nvim/plugins.vim index a333ac1..1be788d 100644 --- a/.config/nvim/plugins.vim +++ b/.config/nvim/plugins.vim @@ -151,6 +151,46 @@ require('lazy').setup({ require('lspconfig')[server_name].setup(lspconfig_setup) end } + + -- fix LSPs not attaching to buffer sometimes + local filetypes = { + { + pattern = '*.php', + filetype = 'php', + }, + { + pattern = '*.js', + filetype = 'javascript', + }, + { + pattern = '*.vue', + filetype = 'vue', + }, + { + pattern = '*.twig', + filetype = 'twig', + }, + { + pattern = '*.lua', + filetype = 'lua', + }, + { + pattern = '*.vim', + filetype = 'vim', + }, + { + pattern = '*.mcfunction', + filetype = 'mcfunction', + }, + } + for _, entry in ipairs(filetypes) do + vim.api.nvim_create_autocmd({ 'BufEnter' }, { + pattern = { entry['pattern'] }, + callback = function(event) + vim.cmd('set filetype=' .. entry['filetype']) + end, + }) + end end, }, |