2023-02-17 09:59:38 +00:00
|
|
|
-- install packer if not already there
|
2023-02-19 12:10:56 +00:00
|
|
|
local is_bootstrap = false
|
2022-12-23 09:15:39 +00:00
|
|
|
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
|
|
|
|
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
|
|
|
is_bootstrap = true
|
2023-02-17 09:59:38 +00:00
|
|
|
vim.fn.system{'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }
|
2022-12-23 09:15:39 +00:00
|
|
|
vim.cmd [[packadd packer.nvim]]
|
|
|
|
end
|
2023-02-24 06:35:46 +00:00
|
|
|
|
2023-02-17 09:59:38 +00:00
|
|
|
-- Install Plugins
|
|
|
|
require('packer').startup(function(use)
|
|
|
|
use 'wbthomason/packer.nvim'
|
|
|
|
use 'neovim/nvim-lspconfig'
|
|
|
|
use 'nvim-treesitter/nvim-treesitter'
|
2023-02-23 21:39:29 +00:00
|
|
|
use 'folke/neodev.nvim'
|
2023-02-23 14:56:28 +00:00
|
|
|
use { "catppuccin/nvim", as = "catppuccin" }
|
2023-02-17 09:59:38 +00:00
|
|
|
use {
|
|
|
|
'hrsh7th/nvim-cmp',
|
2023-02-19 12:10:56 +00:00
|
|
|
requires = { 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lua', 'onsails/lspkind.nvim', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }
|
2023-02-17 09:59:38 +00:00
|
|
|
}
|
2023-02-23 21:39:29 +00:00
|
|
|
use {
|
|
|
|
'j-morano/buffer_manager.nvim',
|
|
|
|
requires = { 'nvim-lua/plenary.nvim'}
|
|
|
|
}
|
2023-02-17 09:59:38 +00:00
|
|
|
if is_bootstrap then
|
|
|
|
require('packer').sync()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Don't run additional config if installing packer
|
2022-12-23 09:15:39 +00:00
|
|
|
if is_bootstrap then
|
|
|
|
print '=================================='
|
|
|
|
print ' Plugins are being installed'
|
|
|
|
print ' Wait until Packer completes,'
|
|
|
|
print ' then restart nvim'
|
|
|
|
print '=================================='
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2023-02-23 21:39:29 +00:00
|
|
|
-- load plugins
|
|
|
|
local bufferManager = require('buffer_manager.ui')
|
2023-02-23 14:56:28 +00:00
|
|
|
|
2023-02-23 21:39:29 +00:00
|
|
|
-- colorscheme
|
2023-02-23 14:56:28 +00:00
|
|
|
require("catppuccin").setup({
|
|
|
|
flavour = "frappe",
|
|
|
|
transparent_background = true,
|
|
|
|
})
|
|
|
|
|
|
|
|
vim.cmd.colorscheme 'catppuccin'
|
|
|
|
|
2023-02-17 09:59:38 +00:00
|
|
|
-- Some basic settings
|
2022-12-23 11:57:25 +00:00
|
|
|
vim.wo.number = true
|
2023-02-17 09:59:38 +00:00
|
|
|
vim.wo.relativenumber = true
|
2023-02-17 11:34:39 +00:00
|
|
|
vim.o.pumheight = 20
|
2022-12-23 11:57:25 +00:00
|
|
|
|
2023-02-23 14:56:28 +00:00
|
|
|
-- Netrw
|
|
|
|
vim.g.netrw_banner = 0
|
|
|
|
vim.g.netrw_liststyle = 3
|
|
|
|
|
2023-02-23 21:39:29 +00:00
|
|
|
-- leader
|
|
|
|
vim.g.mapleader = ' '
|
|
|
|
|
|
|
|
-- keybinds
|
|
|
|
vim.keymap.set('n', '<leader>bs', bufferManager.toggle_quick_menu, {})
|
|
|
|
vim.keymap.set('n', '<leader>ps', require('packer').sync, {})
|
2023-02-23 14:56:28 +00:00
|
|
|
|
2023-02-17 09:59:38 +00:00
|
|
|
-- Additional keybinds if lsp running
|
|
|
|
local on_attach = function(client, bufnr)
|
|
|
|
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
|
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
|
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
|
|
|
end
|
2022-12-23 14:52:20 +00:00
|
|
|
|
2023-02-17 09:59:38 +00:00
|
|
|
local lsp_flags = {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-19 12:10:56 +00:00
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
-- capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
|
|
|
|
2023-02-23 21:39:29 +00:00
|
|
|
require("neodev").setup({
|
|
|
|
-- add any options here, or leave empty to use the default settings
|
|
|
|
})
|
|
|
|
|
2023-02-24 06:35:46 +00:00
|
|
|
local lspconfig = require('lspconfig')
|
|
|
|
|
2023-02-17 09:59:38 +00:00
|
|
|
-- lsp configs
|
2023-02-24 06:35:46 +00:00
|
|
|
lspconfig.tsserver.setup{
|
2023-02-17 09:59:38 +00:00
|
|
|
on_attach = on_attach,
|
|
|
|
flags = lsp_flags
|
|
|
|
}
|
|
|
|
|
2023-02-24 06:35:46 +00:00
|
|
|
lspconfig.lua_ls.setup{
|
2023-02-17 09:59:38 +00:00
|
|
|
on_attach = on_attach,
|
2023-02-23 21:39:29 +00:00
|
|
|
flags = lsp_flags,
|
|
|
|
capabilities = capabilities,
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
completion = {
|
|
|
|
callSnippet = "Replace"
|
2023-02-24 06:35:46 +00:00
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
globals = {'vim'},
|
2023-02-23 21:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-17 09:59:38 +00:00
|
|
|
}
|
|
|
|
|
2023-02-24 06:35:46 +00:00
|
|
|
lspconfig.gopls.setup{
|
2023-02-17 09:59:38 +00:00
|
|
|
on_attach = on_attach,
|
|
|
|
flags = lsp_flags
|
|
|
|
}
|
|
|
|
|
2023-02-24 06:35:46 +00:00
|
|
|
lspconfig.emmet_ls.setup{
|
2023-02-19 12:10:56 +00:00
|
|
|
on_attach = on_attach,
|
|
|
|
flags = lsp_flags,
|
|
|
|
capabilities = capabilities
|
|
|
|
}
|
|
|
|
|
2023-02-24 06:35:46 +00:00
|
|
|
lspconfig.cssls.setup{
|
2023-02-23 21:39:29 +00:00
|
|
|
on_attach = on_attach,
|
|
|
|
flags = lsp_flags,
|
|
|
|
capabilities = capabilities
|
|
|
|
}
|
|
|
|
|
2023-02-24 06:35:46 +00:00
|
|
|
lspconfig.docker_compose_language_service.setup{
|
2023-02-20 06:10:30 +00:00
|
|
|
on_attach = on_attach,
|
|
|
|
flags = lsp_flags,
|
|
|
|
capabilities = capabilities
|
|
|
|
}
|
|
|
|
|
2023-02-17 09:59:38 +00:00
|
|
|
-- TreeSitter Config
|
|
|
|
require('nvim-treesitter.configs').setup{
|
2023-02-20 14:46:48 +00:00
|
|
|
ensure_installed = {'go', 'toml', 'json', 'yaml', 'vim', 'typescript', 'help', 'lua', 'javascript', 'python'},
|
2023-02-17 09:59:38 +00:00
|
|
|
highlight = {
|
|
|
|
enable = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-- autocompletion
|
|
|
|
local cmp = require 'cmp'
|
2023-02-17 11:34:39 +00:00
|
|
|
local lspkind = require 'lspkind'
|
2023-02-19 12:10:56 +00:00
|
|
|
local luasnip = require 'luasnip'
|
|
|
|
|
|
|
|
luasnip.config.setup {}
|
|
|
|
|
2023-02-17 09:59:38 +00:00
|
|
|
cmp.setup {
|
2023-02-17 11:34:39 +00:00
|
|
|
formatting = {
|
|
|
|
format = lspkind.cmp_format()
|
|
|
|
},
|
2023-02-19 12:10:56 +00:00
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
luasnip.lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
},
|
2023-02-17 11:34:39 +00:00
|
|
|
mapping = cmp.mapping.preset.insert {
|
2023-02-19 12:10:56 +00:00
|
|
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
|
|
['<C-Space>'] = cmp.mapping.complete {},
|
|
|
|
['<CR>'] = cmp.mapping.confirm {
|
|
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
|
|
select = true,
|
|
|
|
},
|
2023-02-17 11:34:39 +00:00
|
|
|
['<Tab>'] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
2023-02-19 12:10:56 +00:00
|
|
|
elseif luasnip.expand_or_jumpable() then
|
|
|
|
luasnip.expand_or_jump()
|
2023-02-17 11:34:39 +00:00
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
2023-02-19 12:10:56 +00:00
|
|
|
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' },
|
|
|
|
},
|
2023-02-17 09:59:38 +00:00
|
|
|
}
|