tabs vs spaces

This commit is contained in:
Daniel Lundin 2022-01-09 22:42:43 +01:00
parent 6943f77d30
commit ffad55c60a

View file

@ -3,158 +3,156 @@ return require('packer').startup(function()
use 'pierreglaser/folding-nvim' use 'pierreglaser/folding-nvim'
use 'tjdevries/colorbuddy.vim' use 'tjdevries/colorbuddy.vim'
use 'wbthomason/packer.nvim' use 'wbthomason/packer.nvim'
use 'ray-x/lsp_signature.nvim' use 'ray-x/lsp_signature.nvim'
use 'jose-elias-alvarez/nvim-lsp-ts-utils' use 'jose-elias-alvarez/nvim-lsp-ts-utils'
use 'rafamadriz/friendly-snippets' use 'rafamadriz/friendly-snippets'
use { use {
'b3nj5m1n/kommentary', 'b3nj5m1n/kommentary',
config = function() config = function()
require('kommentary.config').use_extended_mappings() require('kommentary.config').use_extended_mappings()
vim.api.nvim_set_keymap("n", "", "<Plug>kommentary_line_default", {}) -- C-/ vim.api.nvim_set_keymap("n", "", "<Plug>kommentary_line_default", {}) -- C-/
vim.api.nvim_set_keymap("v", "", "<Plug>kommentary_visual_default", {}) -- C-/ vim.api.nvim_set_keymap("v", "", "<Plug>kommentary_visual_default", {}) -- C-/
require('kommentary.config').configure_language("default", { require('kommentary.config').configure_language("default", {
prefer_single_line_comments = true, prefer_single_line_comments = true,
}) })
end end
} }
use { use {
'L3MON4D3/LuaSnip', 'L3MON4D3/LuaSnip',
config = function() config = function()
require("luasnip/loaders/from_vscode").lazy_load() require("luasnip/loaders/from_vscode").lazy_load()
end end
} }
use { use {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
requires = { requires = {
'andersevenrud/cmp-tmux', 'andersevenrud/cmp-tmux',
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer', 'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path', 'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-cmdline',
'L3MON4D3/LuaSnip', 'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip', 'saadparwaiz1/cmp_luasnip',
}, },
config = function() config = function()
local cmp = require'cmp' local cmp = require'cmp'
local luasnip = require'luasnip' local luasnip = require'luasnip'
local has_words_before = function() local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
end end
cmp.setup({ cmp.setup({
formatting = { formatting = {
format = require('lspkind').cmp_format({ format = require('lspkind').cmp_format({
with_text = true, with_text = true,
menu = { menu = {
buffer = "[Buffer]", buffer = "[Buffer]",
tmux = "[Tmux]", tmux = "[Tmux]",
luasnip = "[LuaSnip]", luasnip = "[LuaSnip]",
nvim_lsp = "[LSP]", nvim_lsp = "[LSP]",
nvim_lua = "[Lua]", nvim_lua = "[Lua]",
path = "[Path]", path = "[Path]",
}, },
}), }),
}, },
documentation = { documentation = {
border = 'rounded' border = 'rounded'
}, },
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
snippet = { mapping = {
expand = function(args) ['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
luasnip.lsp_expand(args.body) ['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
end, ["<C-d>"] = cmp.mapping.scroll_docs(-4),
}, ["<C-u>"] = cmp.mapping.scroll_docs(4),
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }),
['<C-y>'] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
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 = cmp.config.sources({
{
name = 'buffer',
priority = 1,
mapping = { },
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), {
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), name = 'luasnip',
["<C-d>"] = cmp.mapping.scroll_docs(-4), priority = 4,
["<C-u>"] = cmp.mapping.scroll_docs(4), },
['<C-e>'] = cmp.mapping({ {
i = cmp.mapping.abort(), name = 'tmux',
c = cmp.mapping.close(), priority = 2,
}), option = {
['<CR>'] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), all_panes = true,
['<C-y>'] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), trigger_characters = {},
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), }
["<Tab>"] = cmp.mapping(function(fallback) },
if cmp.visible() then {
cmp.select_next_item() name = 'nvim_lsp',
elseif luasnip.expand_or_locally_jumpable() then priority = 3,
luasnip.expand_or_jump() },
elseif has_words_before() then })
cmp.complete() })
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 = cmp.config.sources({ end
{ }
name = 'buffer',
priority = 1,
},
{
name = 'luasnip',
priority = 4,
},
{
name = 'tmux',
priority = 2,
option = {
all_panes = true,
trigger_characters = {},
}
},
{
name = 'nvim_lsp',
priority = 3,
},
})
})
end
}
use { use {
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
requires = { requires = {
'nvim-lua/plenary.nvim' 'nvim-lua/plenary.nvim'
}, },
config = function() config = function()
require('gitsigns').setup { require('gitsigns').setup {
numhl = true, numhl = true,
signs = { signs = {
add = {hl = 'GitSignsAdd' , text = '', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, add = {hl = 'GitSignsAdd' , text = '', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
change = {hl = 'GitSignsChange', text = '', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, change = {hl = 'GitSignsChange', text = '', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
delete = {hl = 'GitSignsDelete', text = '', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, delete = {hl = 'GitSignsDelete', text = '', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
topdelete = {hl = 'GitSignsDelete', text = '', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, topdelete = {hl = 'GitSignsDelete', text = '', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
}, },
} }
end end
} }
use { use {
@ -238,24 +236,24 @@ return require('packer').startup(function()
end end
} }
use { use {
"ray-x/go.nvim", "ray-x/go.nvim",
config = function() config = function()
require('go').setup({ require('go').setup({
comment_placeholder = '' comment_placeholder = ''
}) })
vim.cmd("autocmd FileType go nmap <Leader>c :lua require('go.comment').gen()<cr>") vim.cmd("autocmd FileType go nmap <Leader>c :lua require('go.comment').gen()<cr>")
vim.cmd("autocmd BufWritePre *.go :silent! lua require('go.format').gofmt()") vim.cmd("autocmd BufWritePre *.go :silent! lua require('go.format').gofmt()")
vim.cmd('autocmd BufWritePre (InsertLeave?) <buffer> lua vim.lsp.buf.formatting_sync(nil,500)') vim.cmd('autocmd BufWritePre (InsertLeave?) <buffer> lua vim.lsp.buf.formatting_sync(nil,500)')
end end
} }
use { use {
"onsails/lspkind-nvim", "onsails/lspkind-nvim",
config = function() config = function()
require('lspkind').init({ require('lspkind').init({
}) })
end end
} }
use { use {
@ -266,15 +264,15 @@ return require('packer').startup(function()
end end
} }
-- use { -- use {
-- "cuducos/yaml.nvim", -- "cuducos/yaml.nvim",
-- ft = {"yaml"}, -- ft = {"yaml"},
-- requires = { -- requires = {
-- "nvim-treesitter/nvim-treesitter", -- "nvim-treesitter/nvim-treesitter",
-- -- "nvim-telescope/telescope.nvim" -- optional -- -- "nvim-telescope/telescope.nvim" -- optional
-- }, -- },
-- config = function () -- config = function ()
-- require("yaml_nvim").init() -- require("yaml_nvim").init()
-- end -- end
-- } -- }
end) end)