-
Notifications
You must be signed in to change notification settings - Fork 11
Neovim additional configuration
Dmytro Halichenko edited this page Feb 18, 2025
·
3 revisions
" code actions menu with extract, embed and other code action
nnoremap <leader>m <Cmd>lua vim.lsp.buf.code_action()<CR>
" follow link
nnoremap <silent> gd <Cmd>lua vim.lsp.buf.definition()<CR>
" rename file and update all the notes
nnoremap <silent> <space>c <cmd>lua vim.lsp.buf.rename()<CR>
IWE works well with telescope.
" global search
nnoremap <silent> gs <Cmd>lua require('telescope.builtin').lsp_dynamic_workspace_symbols()<CR>
" to see the notes with no parents
nnoremap <silent> ga <Cmd>lua require('telescope.builtin').lsp_dynamic_workspace_symbols({ symbols = { "namespace" }})<CR>
" backlinks to the current file
nnoremap <silent> gr <Cmd>Telescope lsp_references<CR>
" all headers from current note (including nested notes)
nnoremap <silent> go <Cmd>Telescope lsp_document_symbols<CR>
{
'nvim-telescope/telescope.nvim',
config = function()
local actions = require("telescope.actions")
require('telescope').setup {
defaults = {
mappings = {
i = {
["<esc>"] = actions.close
},
},
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown {
winblend = 30,
border = false,
previewer = false,
prompt_prefix = " ",
layout_strategy = "cursor",
layout_config = {
width = 35,
height = 7,
},
}
}
},
pickers = {
tags = {},
lsp_references = {
show_line = false,
trim_text = false,
include_declaration = true,
include_current_line = true,
theme = "dropdown",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "top",
prompt_height = 1,
results_height = 10,
preview_width = 0.7,
width = 0.9,
height = 0.9,
},
},
},
git_files = {
fname_width = 0,
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.7,
width = 0.9,
height = 0.9,
},
},
},
find_files = {
fname_width = 0,
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.7,
width = 0.9,
height = 0.9,
},
},
},
lsp_document_symbols = {
fname_width = 0,
symbol_width = 100,
symbol_type_width = 0,
symbol_line = false,
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.7,
width = 0.9,
height = 0.9,
},
},
},
lsp_workspace_symbols = {
fname_width = 0,
symbol_width = 100,
symbol_type_width = 0,
symbol_line = false,
layout_config = {
horizontal = {
preview_width = 0.5,
width = 0.9,
height = 0.9,
},
},
}
}
}
require("telescope").load_extension("ui-select")
end
},
{
'hrsh7th/nvim-cmp',
config = function()
local cmp = require'cmp'
cmp.setup({
completion = {
keyword_length = 3,
},
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
mapping = {
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), {'i'}),
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), {'i'}),
['<C-n>'] = cmp.mapping({
c = function()
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
else
vim.api.nvim_feedkeys(t('<Down>'), 'n', true)
end
end,
i = function(fallback)
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
else
fallback()
end
end
}),
['<C-p>'] = cmp.mapping({
c = function()
if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
else
vim.api.nvim_feedkeys(t('<Up>'), 'n', true)
end
end,
i = function(fallback)
if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
else
fallback()
end
end
}),
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = 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 = 'tags' },
{ name = 'vsnip' }
}, {
{ name = 'buffer' },
})
})
end
},
- Neovide is a simple, no-nonsense, cross-platform graphical user interface for Neovim.
- Render markdown