neovim config

This commit is contained in:
2025-03-09 20:59:55 +03:00
parent bdab2117f3
commit 972a43b01f
10 changed files with 305 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
-- Set up nvim-cmp
local cmp = require('cmp')
local luasnip = require('luasnip')
local select_opts = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end
},
window = {
documentation = cmp.config.window.bordered(),
completion = { border = 'rounded' }
},
formatting = {
fields = { 'menu', 'abbr', 'kind' },
format = function(entry, item)
local menu_icon = {
nvim_lsp = 'λ',
luasnip = '',
buffer = 'Ω',
path = '🖫',
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
mapping = {
-- Trigger completion menu with <Tab>
['<Tab>'] = cmp.mapping(function(fallback)
local col = vim.fn.col('.') - 1
if cmp.visible() then
cmp.select_next_item(select_opts)
elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
fallback()
else
cmp.complete()
end
end, { 'i', 's' }),
-- Trigger completion menu with <C-Space>
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), -- Open completion menu
-- Navigate completion menu with <C-n> and <C-p>
['<C-n>'] = cmp.mapping.select_next_item(), -- Next item
['<C-p>'] = cmp.mapping.select_prev_item(), -- Previous item
-- Confirm selection with <CR> (Enter)
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Confirm selection
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- LSP source
{ name = 'buffer' }, -- Buffer source
{ name = 'path' }, -- Path source
{ name = 'luasnip' }, -- Path source
}),
})

52
nvim/lua/plugins/init.lua Normal file
View File

@@ -0,0 +1,52 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local plugins = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
{
"neovim/nvim-lspconfig",
dependencies = { 'hrsh7th/cmp-nvim-lsp' }
},
{
'projekt0n/github-nvim-theme',
name = 'github-theme',
lazy = false, -- make sure we load this during startup if it is your main colorscheme
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
require('github-theme').setup({
-- ...
})
vim.cmd('colorscheme github_light_colorblind')
-- vim.cmd('colorscheme github_dark_colorblind')
-- vim.cmd('colorscheme github_dark')
end,
},
{
"nvim-telescope/telescope-file-browser.nvim",
dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }
},
'hrsh7th/nvim-cmp', -- Auto-completion plugin
dependencies = {
'hrsh7th/cmp-nvim-lsp', -- LSP source for nvim-cmp
'hrsh7th/cmp-buffer', -- Buffer source for nvim-cmp
'hrsh7th/cmp-path', -- Path source for nvim-cmp
},
'L3MON4D3/LuaSnip',
}
require("lazy").setup(plugins)
require("plugins/telescope")
require("plugins/completions")

View File

@@ -0,0 +1,20 @@
require("telescope").setup {
extensions = {
file_browser = {
initial_mode = "normal",
-- ...
},
},
}
require("telescope").load_extension "file_browser"
-- require("telescope").load_extension "find_files"
-- vim.keymap.set("n", "<space>fb", ":Telescope file_browser<CR>")
-- open file_browser with the path of the current buffer
vim.keymap.set("n", "<space>fb", ":Telescope file_browser path=%:p:h select_buffer=true<CR>")
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
vim.keymap.set('n', '<leader>b', builtin.buffers, { desc = 'Telescope buffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })