myconfigfiles/.config/nvim/init.lua

113 lines
3.9 KiB
Lua
Raw Normal View History

2024-10-19 11:19:48 +02:00
local map = vim.api.nvim_set_keymap
vim.g.mapleader = " "
require("config.lazy")
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
require("core.options")
2024-10-19 11:19:48 +02:00
options = { noremap = true }
map('n', '<Leader>ff', ':Telescope find_files<Enter>', options)
map('n', '<Leader>fg', ':Telescope git_files<Enter>', options)
2024-10-20 10:24:04 +02:00
map('n', '<Leader>fc', ':Telescope git_commits<Enter>', options)
map('n', '<Leader>fl', ':Telescope live_grep<Enter>', options)
2024-10-19 11:19:48 +02:00
map('n', '<Leader><Space>', ':Telescope buffers<Enter>', options)
map('n', '<Leader>t', ':TagbarToggle<Enter>', options)
2024-10-20 10:24:04 +02:00
map('n', '<Leader>nv', ':Telescope find_files cwd=~/.config/nvim<Enter>', options)
map('n', '<Leader>nc', ':Telescope find_files cwd=~/.config<Enter>', options)
2024-10-19 11:19:48 +02:00
2024-10-20 10:24:04 +02:00
map('n', '<Leader>gd', ':Telescope lsp_definitions<Enter>', options)
map('n', '<Leader>gr', ':Telescope lsp_references<Enter>', options)
map('n', '<Leader>gs', ':Telescope lsp_workspace_symbols<Enter>', options)
map('n', '<Leader>gS', ':Telescope lsp_dynamic_workspace_symbols<Enter>', options)
2024-10-19 16:26:07 +02:00
--------------------------------------------------
-- Telescope
--------------------------------------------------
require('telescope').setup{
defaults = {
prompt_prefix = "> ",
}
}
2024-10-19 16:26:07 +02:00
--------------------------------------------------
2024-10-19 11:19:48 +02:00
-- LSP
--------------------------------------------------
2024-10-19 11:19:48 +02:00
-- Reserve a space in the gutter
-- This will avoid an annoying layout shift in the screen
vim.opt.signcolumn = 'yes'
-- Add cmp_nvim_lsp capabilities settings to lspconfig
-- This should be executed before you configure any language server
local lspconfig_defaults = require('lspconfig').util.default_config
lspconfig_defaults.capabilities = vim.tbl_deep_extend(
'force',
lspconfig_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
)
-- This is where you enable features that only work
-- if there is a language server active in the file
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function(event)
local opts = {buffer = event.buf}
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
2024-10-20 10:24:04 +02:00
--vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
2024-10-19 11:19:48 +02:00
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
2024-10-20 10:24:04 +02:00
--vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
2024-10-19 11:19:48 +02:00
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
end,
})
require('lspconfig').clangd.setup({})
local cmp = require('cmp')
cmp.setup({
sources = {
{name = 'nvim_lsp'},
},
2024-10-19 16:26:07 +02:00
completion = {
autocomplete = false
},
mapping = cmp.mapping.preset.insert({
-- Navigate between completion items
['<C-p>'] = cmp.mapping.select_prev_item({behavior = 'select'}),
['<C-n>'] = cmp.mapping.select_next_item({behavior = 'select'}),
-- `Enter` key to confirm completion
['<CR>'] = cmp.mapping.confirm({select = false}),
-- Ctrl+Space to trigger completion menu
['<C-Space>'] = cmp.mapping.complete(),
-- Scroll up and down in the completion documentation
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
}),
2024-10-19 11:19:48 +02:00
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({}),
})