From 486de7e47f60ff23925b6a807e94e284a15b1c79 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sat, 29 Jul 2023 10:15:36 +0200 Subject: LSP Konfiguration für Python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nvim/ftplugin/c.vim | 1 + nvim/plugins.vim | 124 ++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 111 insertions(+), 14 deletions(-) diff --git a/nvim/ftplugin/c.vim b/nvim/ftplugin/c.vim index fd45dbd..3fc55eb 100644 --- a/nvim/ftplugin/c.vim +++ b/nvim/ftplugin/c.vim @@ -2,6 +2,7 @@ setlocal cinoptions=:0,p0,t0 setlocal cinwords=if,else,while,do,for,switch,case setlocal formatoptions=tcqr setlocal cindent +setlocal indentexpr=nvim_treesitter#indent() setlocal foldenable setlocal foldmethod=expr diff --git a/nvim/plugins.vim b/nvim/plugins.vim index 6c84a23..4e8d45c 100644 --- a/nvim/plugins.vim +++ b/nvim/plugins.vim @@ -18,6 +18,12 @@ call plug#begin() Plug 'neovim/nvim-lspconfig' Plug 'windwp/nvim-autopairs' Plug 'windwp/nvim-ts-autotag' + + Plug 'hrsh7th/cmp-nvim-lsp' + Plug 'hrsh7th/cmp-buffer' + Plug 'hrsh7th/cmp-path' + Plug 'hrsh7th/cmp-cmdline' + Plug 'hrsh7th/nvim-cmp' call plug#end() " EMMET @@ -55,7 +61,7 @@ let g:AutoPairsPrefix='' " Treesitter lua << EOF require'nvim-treesitter.configs'.setup { - ensure_installed = { "c", "cpp", "lua", "vim", "vimdoc", "typescript" }, + ensure_installed = { "c", "cpp", "lua", "vim", "vimdoc", "typescript", "python" }, sync_install = false, auto_install = false, highlight = { @@ -77,28 +83,118 @@ EOF " LSP lua << EOF local lspconfig = require'lspconfig' -lspconfig.clangd.setup { + +lspconfig.clangd.setup{ cmd = { 'clangd15' } } -lspconfig.lua_ls.setup {} -lspconfig.pyright.setup {} -lspconfig.pylsp.setup{ + +lspconfig.lua_ls.setup { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'}, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, +} + +lspconfig.pyright.setup{ settings = { - pylsp = { - plugins = { - pycodestyle = { - ignore = {'W391'}, - maxLineLength = 100 - } + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = "workspace", + useLibraryCodeForTypes = true } } } } -lspconfig.tsserver.setup {} -lspconfig.vimls.setup {} -lspconfig.rust_analyzer.setup { + +lspconfig.tsserver.setup{} + +lspconfig.vimls.setup{} + +lspconfig.rust_analyzer.setup{ settings = { ['rust-analyzer'] = {}, }, } EOF + +" Completion +lua <'] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + -- { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, { + { name = 'buffer' }, + }) + }) + + -- Set configuration for specific filetype. + --cmp.setup.filetype('gitcommit', { + -- sources = cmp.config.sources({ + -- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + -- }, { + -- { name = 'buffer' }, + -- }) + --}) + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + --cmp.setup.cmdline({ '/', '?' }, { + -- mapping = cmp.mapping.preset.cmdline(), + -- sources = { + -- { name = 'buffer' } + -- } + --}) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + --cmp.setup.cmdline(':', { + -- mapping = cmp.mapping.preset.cmdline(), + -- sources = cmp.config.sources({ + -- { name = 'path' } + -- }, { + -- { name = 'cmdline' } + -- }) + --}) +EOF -- cgit v1.3