feat: Neovim config mit LSP, Treesitter und PlatformIO
This commit is contained in:
parent
c2b9c8f3c9
commit
824ff44370
9 changed files with 345 additions and 0 deletions
106
nvim/lua/plugins/lsp.lua
Normal file
106
nvim/lua/plugins/lsp.lua
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
return {
|
||||
-- Syntax Highlighting
|
||||
{
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
build = ':TSUpdate',
|
||||
config = function()
|
||||
vim.treesitter.language.register('markdown', 'mdx')
|
||||
-- Parser installieren
|
||||
local parsers = { 'lua', 'python', 'c', 'cpp', 'json', 'yaml', 'markdown', 'bash' }
|
||||
for _, parser in ipairs(parsers) do
|
||||
pcall(function()
|
||||
vim.treesitter.start(0, parser)
|
||||
end)
|
||||
end
|
||||
-- Highlight aktivieren
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
pcall(vim.treesitter.start)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- Mason für LSP Installation
|
||||
{
|
||||
'williamboman/mason.nvim',
|
||||
config = function()
|
||||
require('mason').setup()
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
dependencies = { 'williamboman/mason.nvim' },
|
||||
config = function()
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = { 'pyright', 'lua_ls', 'clangd' },
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- LSP Config (mit neuer API für nvim 0.11)
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = { 'williamboman/mason-lspconfig.nvim' },
|
||||
config = function()
|
||||
-- Keymaps wenn LSP attached
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
local opts = { buffer = args.buf }
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
-- LSP Server aktivieren
|
||||
vim.lsp.enable('pyright')
|
||||
vim.lsp.enable('lua_ls')
|
||||
vim.lsp.enable('clangd')
|
||||
end,
|
||||
},
|
||||
|
||||
-- Autovervollständigung
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
dependencies = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'L3MON4D3/LuaSnip',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
},
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
}),
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue