diff options
Diffstat (limited to 'nvim')
| -rw-r--r-- | nvim/lua/config/filetypes.lua | 27 | ||||
| -rw-r--r-- | nvim/lua/config/treesitter.lua | 5 | ||||
| -rw-r--r-- | nvim/lua/plugins/lsp.lua | 15 |
3 files changed, 45 insertions, 2 deletions
diff --git a/nvim/lua/config/filetypes.lua b/nvim/lua/config/filetypes.lua index 1b85053..0cb9036 100644 --- a/nvim/lua/config/filetypes.lua +++ b/nvim/lua/config/filetypes.lua | |||
| @@ -1,7 +1,30 @@ | |||
| 1 | -- Custom Filetype-Erkennung fuer Dateien, die von der eingebauten Erkennung | 1 | -- Custom Filetype-Erkennung fuer Dateien, die sich nicht allein anhand ihrer |
| 2 | -- abweichen sollen. | 2 | -- Endung unterscheiden lassen (z.B. Ansible-YAML vs. normales YAML). |
| 3 | -- | ||
| 4 | -- "yaml.ansible" wird ausserdem in config.treesitter (Autocmd-Pattern) und in | ||
| 5 | -- plugins/lsp.lua (ansiblels.filetypes) verwendet. | ||
| 3 | 6 | ||
| 7 | -- Ansible-Dateien haben die Endung .yml/.yaml wie normales YAML und sind nur am | ||
| 8 | -- Dateinamen bzw. am Pfad erkennbar. Die Patterns sind mit "$" verankert, damit | ||
| 9 | -- Jinja-Templates (z.B. tasks/main.yml.j2) weiter als jinja gelten. | ||
| 4 | vim.filetype.add({ | 10 | vim.filetype.add({ |
| 11 | filename = { | ||
| 12 | ["playbook.yml"] = "yaml.ansible", | ||
| 13 | ["playbook.yaml"] = "yaml.ansible", | ||
| 14 | ["site.yml"] = "yaml.ansible", | ||
| 15 | ["site.yaml"] = "yaml.ansible", | ||
| 16 | ["requirements.yml"] = "yaml.ansible", | ||
| 17 | ["requirements.yaml"] = "yaml.ansible", | ||
| 18 | }, | ||
| 19 | pattern = { | ||
| 20 | [".*/roles/.*/tasks/.*%.ya?ml$"] = "yaml.ansible", | ||
| 21 | [".*/roles/.*/handlers/.*%.ya?ml$"] = "yaml.ansible", | ||
| 22 | [".*/tasks/.*%.ya?ml$"] = "yaml.ansible", | ||
| 23 | [".*/handlers/.*%.ya?ml$"] = "yaml.ansible", | ||
| 24 | [".*/group_vars/.*%.ya?ml$"] = "yaml.ansible", | ||
| 25 | [".*/host_vars/.*%.ya?ml$"] = "yaml.ansible", | ||
| 26 | [".*/playbooks/.*%.ya?ml$"] = "yaml.ansible", | ||
| 27 | }, | ||
| 5 | extension = { | 28 | extension = { |
| 6 | j2 = "jinja", | 29 | j2 = "jinja", |
| 7 | }, | 30 | }, |
diff --git a/nvim/lua/config/treesitter.lua b/nvim/lua/config/treesitter.lua index 5451c6d..8e4e4ba 100644 --- a/nvim/lua/config/treesitter.lua +++ b/nvim/lua/config/treesitter.lua | |||
| @@ -37,6 +37,11 @@ local extra_filetypes = { | |||
| 37 | -- vim.treesitter.start() keinen Parser und die FileType-Autocmd feuert nicht. | 37 | -- vim.treesitter.start() keinen Parser und die FileType-Autocmd feuert nicht. |
| 38 | sh = "bash", | 38 | sh = "bash", |
| 39 | ps1 = "powershell", | 39 | ps1 = "powershell", |
| 40 | |||
| 41 | -- Zusammengesetzter Dateityp aus config.filetypes: den Parser loest Neovim | ||
| 42 | -- selbst am Punkt auf, der Eintrag sorgt aber fuer das Autocmd-Pattern -- | ||
| 43 | -- Patterns splitten nicht, "yaml" wuerde fuer "yaml.ansible" nicht feuern. | ||
| 44 | ["yaml.ansible"] = "yaml", | ||
| 40 | } | 45 | } |
| 41 | 46 | ||
| 42 | -- Macht die Parser der Filetypes ohne gleichnamigen Parser bekannt. | 47 | -- Macht die Parser der Filetypes ohne gleichnamigen Parser bekannt. |
diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 46892b5..e0ad450 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua | |||
| @@ -93,7 +93,22 @@ return { | |||
| 93 | }, | 93 | }, |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | vim.lsp.config.ansiblels = { | ||
| 97 | filetypes = { "yaml.ansible" }, -- Erkennung: siehe config.filetypes | ||
| 98 | settings = { | ||
| 99 | ansible = { | ||
| 100 | validation = { | ||
| 101 | lint = { | ||
| 102 | enabled = true, | ||
| 103 | path = "ansible-lint", | ||
| 104 | }, | ||
| 105 | }, | ||
| 106 | }, | ||
| 107 | }, | ||
| 108 | } | ||
| 109 | |||
| 96 | vim.lsp.enable({ | 110 | vim.lsp.enable({ |
| 111 | "ansiblels", -- npm install -g @ansible/ansible-language-server & (brew install ansible-lint, pkg install sysutils/py-ansible-lint) | ||
| 97 | "basedpyright", -- npm install -g basedpyright, brew install basedpyright | 112 | "basedpyright", -- npm install -g basedpyright, brew install basedpyright |
| 98 | "bashls", -- npm install -g bash-language-server, pkg install hs-ShellCheck | 113 | "bashls", -- npm install -g bash-language-server, pkg install hs-ShellCheck |
| 99 | "clangd", -- pkg install llvm | 114 | "clangd", -- pkg install llvm |
