diff options
| author | Thomas Schmucker <ts@its1.de> | 2024-05-17 16:10:35 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2024-05-17 16:10:35 +0200 |
| commit | 90a6a6db7fd29ffe6defc0969011c7288403f074 (patch) | |
| tree | 4dcdba2056ecdf997a3d1bb9afe696beab01acf1 | |
| parent | d2afaa805e1b282867eefc94d27850cffa0ef438 (diff) | |
| download | dotfiles-90a6a6db7fd29ffe6defc0969011c7288403f074.tar.gz dotfiles-90a6a6db7fd29ffe6defc0969011c7288403f074.tar.bz2 dotfiles-90a6a6db7fd29ffe6defc0969011c7288403f074.zip | |
Setup für neue Code-Completion Konfiguration
| -rw-r--r-- | nvim/plugins.vim | 138 |
1 files changed, 53 insertions, 85 deletions
diff --git a/nvim/plugins.vim b/nvim/plugins.vim index 9067c6a..161cffa 100644 --- a/nvim/plugins.vim +++ b/nvim/plugins.vim | |||
| @@ -19,11 +19,15 @@ call plug#begin() | |||
| 19 | Plug 'windwp/nvim-autopairs' | 19 | Plug 'windwp/nvim-autopairs' |
| 20 | Plug 'windwp/nvim-ts-autotag' | 20 | Plug 'windwp/nvim-ts-autotag' |
| 21 | 21 | ||
| 22 | Plug 'hrsh7th/nvim-cmp' | ||
| 23 | Plug 'L3MON4D3/LuaSnip' | ||
| 24 | Plug 'saadparwaiz1/cmp_luasnip' | ||
| 25 | Plug 'rafamadriz/friendly-snippets' | ||
| 26 | |||
| 22 | Plug 'hrsh7th/cmp-nvim-lsp' | 27 | Plug 'hrsh7th/cmp-nvim-lsp' |
| 23 | Plug 'hrsh7th/cmp-buffer' | 28 | Plug 'hrsh7th/cmp-buffer' |
| 24 | Plug 'hrsh7th/cmp-path' | 29 | " Plug 'hrsh7th/cmp-path' |
| 25 | Plug 'hrsh7th/cmp-cmdline' | 30 | " Plug 'hrsh7th/cmp-cmdline' |
| 26 | Plug 'hrsh7th/nvim-cmp' | ||
| 27 | call plug#end() | 31 | call plug#end() |
| 28 | 32 | ||
| 29 | " EMMET | 33 | " EMMET |
| @@ -54,9 +58,9 @@ let g:mundo_width=40 | |||
| 54 | let g:mundo_preview_height=30 | 58 | let g:mundo_preview_height=30 |
| 55 | 59 | ||
| 56 | " Autopairs | 60 | " Autopairs |
| 57 | let b:autopairs_enabled=1 | 61 | " let b:autopairs_enabled=1 |
| 58 | let g:AutoPairsMapBS=1 | 62 | " let g:AutoPairsMapBS=1 |
| 59 | let g:AutoPairsPrefix='<M-P>' | 63 | " let g:AutoPairsPrefix='<M-P>' |
| 60 | 64 | ||
| 61 | " Treesitter | 65 | " Treesitter |
| 62 | lua << EOF | 66 | lua << EOF |
| @@ -72,6 +76,9 @@ require('nvim-treesitter.configs').setup { | |||
| 72 | indent = { | 76 | indent = { |
| 73 | enable = false, | 77 | enable = false, |
| 74 | }, | 78 | }, |
| 79 | autotag = { | ||
| 80 | enable = true, | ||
| 81 | } | ||
| 75 | } | 82 | } |
| 76 | EOF | 83 | EOF |
| 77 | 84 | ||
| @@ -82,10 +89,13 @@ EOF | |||
| 82 | 89 | ||
| 83 | " LSP | 90 | " LSP |
| 84 | lua << EOF | 91 | lua << EOF |
| 92 | local capabilities = require('cmp_nvim_lsp').default_capabilities() | ||
| 93 | |||
| 85 | local lspconfig = require('lspconfig') | 94 | local lspconfig = require('lspconfig') |
| 86 | 95 | ||
| 87 | lspconfig.clangd.setup{ | 96 | lspconfig.clangd.setup{ |
| 88 | cmd = { 'clangd15' } | 97 | cmd = { 'clangd15' }, |
| 98 | capabilities = capabilities | ||
| 89 | } | 99 | } |
| 90 | 100 | ||
| 91 | lspconfig.lua_ls.setup { | 101 | lspconfig.lua_ls.setup { |
| @@ -109,92 +119,50 @@ lspconfig.lua_ls.setup { | |||
| 109 | }, | 119 | }, |
| 110 | }, | 120 | }, |
| 111 | }, | 121 | }, |
| 122 | capabilities = capabilities | ||
| 112 | } | 123 | } |
| 113 | 124 | ||
| 114 | lspconfig.pyright.setup{ | 125 | lspconfig.html.setup{ |
| 115 | settings = { | 126 | capabilities = capabilities |
| 116 | python = { | ||
| 117 | analysis = { | ||
| 118 | autoSearchPaths = true, | ||
| 119 | diagnosticMode = "workspace", | ||
| 120 | useLibraryCodeForTypes = true | ||
| 121 | } | ||
| 122 | } | ||
| 123 | } | ||
| 124 | } | 127 | } |
| 125 | 128 | ||
| 126 | lspconfig.tsserver.setup{} | 129 | lspconfig.tsserver.setup{ |
| 127 | 130 | capabilities = capabilities | |
| 128 | lspconfig.vimls.setup{} | 131 | } |
| 129 | 132 | ||
| 130 | lspconfig.rust_analyzer.setup{ | 133 | lspconfig.vimls.setup{ |
| 131 | settings = { | 134 | capabilities = capabilities |
| 132 | ['rust-analyzer'] = {}, | ||
| 133 | }, | ||
| 134 | } | 135 | } |
| 135 | EOF | 136 | EOF |
| 136 | 137 | ||
| 137 | " Completion | 138 | lua << EOF |
| 138 | lua <<EOF | 139 | require("luasnip.loaders.from_vscode").lazy_load() |
| 139 | -- Set up nvim-cmp. | ||
| 140 | local cmp = require('cmp') | ||
| 141 | |||
| 142 | cmp.setup({ | ||
| 143 | snippet = { | ||
| 144 | -- REQUIRED - you must specify a snippet engine | ||
| 145 | expand = function(args) | ||
| 146 | -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. | ||
| 147 | -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. | ||
| 148 | -- require('snippy').expand_snippet(args.body) -- For `snippy` users. | ||
| 149 | -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. | ||
| 150 | end, | ||
| 151 | }, | ||
| 152 | window = { | ||
| 153 | -- completion = cmp.config.window.bordered(), | ||
| 154 | -- documentation = cmp.config.window.bordered(), | ||
| 155 | }, | ||
| 156 | mapping = cmp.mapping.preset.insert({ | ||
| 157 | ['<C-b>'] = cmp.mapping.scroll_docs(-4), | ||
| 158 | ['<C-f>'] = cmp.mapping.scroll_docs(4), | ||
| 159 | ['<C-Space>'] = cmp.mapping.complete(), | ||
| 160 | ['<C-e>'] = cmp.mapping.abort(), | ||
| 161 | ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. | ||
| 162 | }), | ||
| 163 | sources = cmp.config.sources({ | ||
| 164 | { name = 'nvim_lsp' }, | ||
| 165 | -- { name = 'vsnip' }, -- For vsnip users. | ||
| 166 | -- { name = 'luasnip' }, -- For luasnip users. | ||
| 167 | -- { name = 'ultisnips' }, -- For ultisnips users. | ||
| 168 | -- { name = 'snippy' }, -- For snippy users. | ||
| 169 | }, { | ||
| 170 | { name = 'buffer' }, | ||
| 171 | }) | ||
| 172 | }) | ||
| 173 | |||
| 174 | -- Set configuration for specific filetype. | ||
| 175 | --cmp.setup.filetype('gitcommit', { | ||
| 176 | -- sources = cmp.config.sources({ | ||
| 177 | -- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). | ||
| 178 | -- }, { | ||
| 179 | -- { name = 'buffer' }, | ||
| 180 | -- }) | ||
| 181 | --}) | ||
| 182 | 140 | ||
| 183 | -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). | 141 | local cmp = require('cmp') |
| 184 | --cmp.setup.cmdline({ '/', '?' }, { | ||
| 185 | -- mapping = cmp.mapping.preset.cmdline(), | ||
| 186 | -- sources = { | ||
| 187 | -- { name = 'buffer' } | ||
| 188 | -- } | ||
| 189 | --}) | ||
| 190 | 142 | ||
| 191 | -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). | 143 | cmp.setup({ |
| 192 | --cmp.setup.cmdline(':', { | 144 | snippet = { |
| 193 | -- mapping = cmp.mapping.preset.cmdline(), | 145 | expand = function(args) |
| 194 | -- sources = cmp.config.sources({ | 146 | require('luasnip').lsp_expand(args.body) |
| 195 | -- { name = 'path' } | 147 | end, |
| 196 | -- }, { | 148 | }, |
| 197 | -- { name = 'cmdline' } | 149 | window = { |
| 198 | -- }) | 150 | completion = cmp.config.window.bordered(), |
| 199 | --}) | 151 | documentation = cmp.config.window.bordered(), |
| 152 | }, | ||
| 153 | mapping = cmp.mapping.preset.insert({ | ||
| 154 | ['<C-b>'] = cmp.mapping.scroll_docs(-4), | ||
| 155 | ['<C-f>'] = cmp.mapping.scroll_docs(4), | ||
| 156 | ['<C-Space>'] = cmp.mapping.complete(), | ||
| 157 | ['<C-e>'] = cmp.mapping.abort(), | ||
| 158 | ['<CR>'] = cmp.mapping.confirm({ select = true }), | ||
| 159 | }), | ||
| 160 | sources = cmp.config.sources({ | ||
| 161 | { name = 'nvim_lsp' }, | ||
| 162 | { name = 'luasnip' }, | ||
| 163 | }, { | ||
| 164 | { name = 'buffer' }, | ||
| 165 | }) | ||
| 166 | }) | ||
| 200 | EOF | 167 | EOF |
| 168 | |||
