Last active
April 21, 2024 02:24
-
-
Save vancanhuit/e316569efb235901ea53783d327a3882 to your computer and use it in GitHub Desktop.
Neovim Lua configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim.opt.number = true | |
vim.opt.mouse = 'a' | |
vim.opt.ignorecase = true | |
vim.opt.smartcase = true | |
vim.opt.wrap = true | |
vim.opt.breakindent = true | |
vim.opt.tabstop = 2 | |
vim.opt.shiftwidth = 2 | |
vim.opt.expandtab = true | |
vim.opt.smarttab = true | |
vim.opt.cursorline = true | |
vim.opt.signcolumn = 'yes' | |
vim.opt.clipboard:append('unnamedplus') | |
vim.g.mapleader = ' ' | |
vim.g.python3_host_prog = '~/workspace/venvs/neovim/.venv/bin/python' | |
vim.g.loaded_ruby_provider = 0 | |
vim.g.loaded_perl_provider = 0 | |
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) | |
require("lazy").setup({ | |
{ | |
"catppuccin/nvim", | |
name = "catppuccin", | |
priority = 1000, | |
}, | |
{ 'nvim-lualine/lualine.nvim' }, | |
{ | |
"lukas-reineke/indent-blankline.nvim", | |
main = "ibl", | |
opts = {}, | |
}, | |
{ | |
"nvim-treesitter/nvim-treesitter", | |
build = ":TSUpdate" | |
}, | |
{ | |
'nvim-telescope/telescope.nvim', | |
tag = '0.1.6', | |
dependencies = { 'nvim-lua/plenary.nvim' }, | |
}, | |
{ 'neovim/nvim-lspconfig' }, | |
{ 'hrsh7th/nvim-cmp' }, | |
{ 'hrsh7th/cmp-nvim-lsp' }, | |
{ 'saadparwaiz1/cmp_luasnip' }, | |
{ | |
'L3MON4D3/LuaSnip', | |
dependencies = { "rafamadriz/friendly-snippets" }, | |
build = "make install_jsregexp", | |
}, | |
{ 'hrsh7th/cmp-buffer' }, | |
{ 'hrsh7th/cmp-path' }, | |
{ | |
'numToStr/Comment.nvim', | |
lazy = false, | |
}, | |
{ 'tpope/vim-surround' }, | |
{ 'lewis6991/gitsigns.nvim' }, | |
}) | |
require('catppuccin').setup({ | |
flavour = 'mocha', | |
term_colors = true, | |
integrations = { | |
cmp = true, | |
treesitter = true, | |
telescope = { | |
enabled = true, | |
}, | |
indent_blankline = { | |
enabled = true, | |
}, | |
native_lsp = { | |
enabled = true, | |
virtual_text = { | |
errors = { "italic" }, | |
hints = { "italic" }, | |
warnings = { "italic" }, | |
information = { "italic" }, | |
}, | |
underlines = { | |
errors = { "underline" }, | |
hints = { "underline" }, | |
warnings = { "underline" }, | |
information = { "underline" }, | |
}, | |
inlay_hints = { | |
background = true, | |
}, | |
}, | |
}, | |
}) | |
vim.opt.termguicolors = true | |
vim.cmd.colorscheme('catppuccin') | |
vim.opt.showmode = false | |
require('lualine').setup({ | |
options = { | |
theme = 'catppuccin', | |
-- icons_enabled = false, | |
-- component_separators = { left = '', right = '' }, | |
-- section_separators = { left = '', right = '' }, | |
} | |
}) | |
require("ibl").setup({}) | |
require('nvim-treesitter.configs').setup({ | |
highlight = { | |
enable = true, | |
additional_vim_regex_highlighting = false, | |
}, | |
ensure_installed = { | |
'c', | |
'vim', | |
'vimdoc', | |
'query', | |
'go', | |
'python', | |
'bash', | |
'yaml', | |
'xml', | |
'toml', | |
'json', | |
'lua', | |
'diff', | |
'dockerfile', | |
'git_config', | |
'gitattributes', | |
'gitignore', | |
'gomod', | |
'gosum', | |
'sql', | |
}, | |
}) | |
local builtin = require('telescope.builtin') | |
vim.keymap.set('n', '<leader>ff', builtin.find_files, {}) | |
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) | |
vim.keymap.set('n', '<leader>fb', builtin.buffers, {}) | |
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {}) | |
vim.opt.completeopt = {'menu', 'menuone', 'noselect'} | |
-- luasnip setup | |
local luasnip = require('luasnip') | |
-- nvim-cmp setup | |
local cmp = require('cmp') | |
cmp.setup({ | |
snippet = { | |
expand = function(args) | |
luasnip.lsp_expand(args.body) | |
end, | |
}, | |
window = { | |
completion = cmp.config.window.bordered(), | |
documentation = cmp.config.window.bordered(), | |
}, | |
mapping = cmp.mapping.preset.insert({ | |
['<C-b>'] = cmp.mapping.scroll_docs(-4), -- Up | |
['<C-f>'] = cmp.mapping.scroll_docs(4), -- Down | |
['<C-Space>'] = cmp.mapping.complete(), | |
['<C-e>'] = cmp.mapping.abort(), | |
['<CR>'] = cmp.mapping.confirm { | |
behavior = cmp.ConfirmBehavior.Replace, | |
select = true, | |
}, | |
['<Tab>'] = cmp.mapping(function(fallback) | |
if cmp.visible() then | |
cmp.select_next_item() | |
elseif luasnip.expand_or_jumpable() then | |
luasnip.expand_or_jump() | |
else | |
fallback() | |
end | |
end, { 'i', 's' }), | |
['<S-Tab>'] = cmp.mapping(function(fallback) | |
if cmp.visible() then | |
cmp.select_prev_item() | |
elseif luasnip.jumpable(-1) then | |
luasnip.jump(-1) | |
else | |
fallback() | |
end | |
end, { 'i', 's' }), | |
}), | |
sources = { | |
{ name = 'nvim_lsp' }, | |
{ name = 'luasnip' }, | |
{ name = 'buffer' }, | |
{ name = 'path' }, | |
}, | |
}) | |
local capabilities = require('cmp_nvim_lsp').default_capabilities() | |
local lspconfig = require('lspconfig') | |
lspconfig['pyright'].setup({ | |
capabilities = capabilities, | |
}) | |
lspconfig['gopls'].setup({ | |
capabilities = capabilities, | |
}) | |
lspconfig['bashls'].setup({ | |
capabilities = capabilities, | |
}) | |
lspconfig['yamlls'].setup({ | |
capabilities = capabilities, | |
}) | |
lspconfig['docker_compose_language_service'].setup({ | |
capabilities = capabilities, | |
}) | |
require("luasnip.loaders.from_vscode").lazy_load() | |
require('Comment').setup({}) | |
require('gitsigns').setup({}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment