summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-06-24 11:10:08 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-06-24 11:10:08 +0200
commit0aa14ca7e1cd984eed359af6447a2df16e4dd8e1 (patch)
tree05944264786b2c1c007169f2d997a5379033dba4 /.config
parentb4eec62be82f8e48f3a099fbb321f9af86e07afb (diff)
[nvim] force attach LSP servers to buffer with filetype set
Diffstat (limited to '.config')
-rw-r--r--.config/nvim/plugins.vim40
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,
},