Change Lua indentation to 3

This commit is contained in:
Sam A. 2023-05-12 20:06:47 +02:00
parent f5dd78b550
commit 9bb19ce86a
Signed by: samsapti
GPG key ID: CBBBE7371E81C4EA

View file

@ -1,31 +1,31 @@
-- plugins -- plugins
require('packer').startup(function(use) require('packer').startup(function(use)
use 'wbthomason/packer.nvim' use 'wbthomason/packer.nvim'
use 'ii14/onedark.nvim' use 'ii14/onedark.nvim'
use { use {
'mengelbrecht/lightline-bufferline', 'mengelbrecht/lightline-bufferline',
requires = { requires = {
'itchyny/lightline.vim' 'itchyny/lightline.vim'
} }
} }
use 'kyazdani42/nvim-web-devicons' use 'kyazdani42/nvim-web-devicons'
use 'sheerun/vim-polyglot' use 'sheerun/vim-polyglot'
use 'editorconfig/editorconfig-vim' use 'editorconfig/editorconfig-vim'
use { use {
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
requires = { requires = {
'williamboman/mason.nvim', 'williamboman/mason.nvim',
'neovim/nvim-lspconfig' 'neovim/nvim-lspconfig'
} }
} }
use { use {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
requires = { requires = {
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
'saadparwaiz1/cmp_luasnip', 'saadparwaiz1/cmp_luasnip',
'L3MON4D3/LuaSnip' 'L3MON4D3/LuaSnip'
} }
} }
end) end)
-- basics -- basics
@ -43,17 +43,24 @@ vim.cmd.colorscheme('onedark')
-- settings for specific filetypes -- settings for specific filetypes
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
pattern = { 'html', 'css', 'scss', 'lua', 'json', 'yaml', 'yaml.*' }, pattern = { 'html', 'css', 'scss', 'json', 'yaml', 'yaml.*' },
callback = function() callback = function()
vim.opt_local.tabstop = 2 vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2 vim.opt_local.shiftwidth = 2
end end
})
vim.api.nvim_create_autocmd('FileType', {
pattern = 'lua',
callback = function()
vim.opt_local.tabstop = 3
vim.opt_local.shiftwidth = 3
end
}) })
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, { vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
pattern = { 'zsh*', '.zsh*', '*.zsh' }, pattern = { 'zsh*', '.zsh*', '*.zsh' },
callback = function() callback = function()
vim.opt.filetype = 'sh' vim.opt.filetype = 'sh'
end end
}) })
-- appearance -- appearance
@ -62,17 +69,17 @@ vim.g.background = 'dark'
-- lightline config -- lightline config
vim.g.lightline = { vim.g.lightline = {
colorscheme = 'one', colorscheme = 'one',
tabline = { tabline = {
left = { { 'buffers' } }, left = { { 'buffers' } },
right = { { 'relativepath' } } right = { { 'relativepath' } }
}, },
component_expand = { component_expand = {
buffers = 'lightline#bufferline#buffers' buffers = 'lightline#bufferline#buffers'
}, },
component_type = { component_type = {
buffers = 'tabsel' buffers = 'tabsel'
} }
} }
-- lightline-bufferline config -- lightline-bufferline config
@ -90,125 +97,125 @@ local luasnip = require('luasnip')
luasnip.config.setup {} luasnip.config.setup {}
cmp.setup { cmp.setup {
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
end
},
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<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
end, { 'i', 's' }), },
['<S-Tab>'] = cmp.mapping(function(fallback) mapping = {
if cmp.visible() then ['<C-d>'] = cmp.mapping.scroll_docs(-4),
cmp.select_prev_item() ['<C-f>'] = cmp.mapping.scroll_docs(4),
elseif luasnip.jumpable(-1) then ['<C-Space>'] = cmp.mapping.complete(),
luasnip.jump(-1) ['<C-e>'] = cmp.mapping.abort(),
else ['<CR>'] = cmp.mapping.confirm {
fallback() behavior = cmp.ConfirmBehavior.Replace,
end select = true
end, { 'i', 's' }) },
}, ['<Tab>'] = cmp.mapping(function(fallback)
sources = { if cmp.visible() then
{ name = 'nvim_lsp' }, cmp.select_next_item()
{ name = 'luasnip' } 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' }
}
} }
cmp.setup.cmdline('/', { cmp.setup.cmdline('/', {
sources = { sources = {
{ name = 'buffer' } { name = 'buffer' }
} }
}) })
cmp.setup.cmdline(':', { cmp.setup.cmdline(':', {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'path' } { name = 'path' }
}, },
{ {
{ name = 'cmdline' } { name = 'cmdline' }
}) })
}) })
-- lsp config -- lsp config
require('mason').setup {} require('mason').setup {}
require("mason-registry").refresh() require("mason-registry").refresh()
require('mason-lspconfig').setup { require('mason-lspconfig').setup {
automatic_installation = true automatic_installation = true
} }
local lsp = require('lspconfig') local lsp = require('lspconfig')
local capabilities = require('cmp_nvim_lsp').default_capabilities() local capabilities = require('cmp_nvim_lsp').default_capabilities()
lsp.ansiblels.setup { lsp.ansiblels.setup {
capabilities = capabilities capabilities = capabilities
} }
lsp.bashls.setup { lsp.bashls.setup {
capabilities = capabilities capabilities = capabilities
} }
lsp.clangd.setup { lsp.clangd.setup {
capabilities = capabilities capabilities = capabilities
} }
lsp.dockerls.setup { lsp.dockerls.setup {
capabilities = capabilities capabilities = capabilities
} }
lsp.gopls.setup { lsp.gopls.setup {
capabilities = capabilities capabilities = capabilities
} }
lsp.lua_ls.setup { lsp.lua_ls.setup {
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
Lua = { Lua = {
runtime = { runtime = {
version = 'LuaJIT' version = 'LuaJIT'
}, },
diagnostics = { diagnostics = {
globals = { 'vim' } globals = { 'vim' }
}, },
telemetry = { telemetry = {
enable = false enable = false
}
} }
} }
}
} }
lsp.pylsp.setup { lsp.pylsp.setup {
capabilities = capabilities capabilities = capabilities
} }
lsp.vimls.setup { lsp.vimls.setup {
capabilities = capabilities, capabilities = capabilities,
init_options = { init_options = {
diagnostic = { diagnostic = {
enable = false enable = false
}, },
isNeovim = true isNeovim = true
} }
} }
lsp.yamlls.setup { lsp.yamlls.setup {
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
redhat = { redhat = {
telemetry = { telemetry = {
enabled = false enabled = false
}
},
yaml = {
keyOrdering = false
} }
}, }
yaml = {
keyOrdering = false
}
}
} }
-- keyboard mappings -- keyboard mappings