feat: configure nvim

This commit is contained in:
Michael Mandl 2022-06-20 15:49:53 +02:00
parent 2f45af6d59
commit 46b64ef66f
12 changed files with 537 additions and 3 deletions

View file

@ -0,0 +1,19 @@
require('bufferline')
-- format as "<id>. <file-name>"
local tabname_format = function (opts)
return string.format('%s.', opts.ordinal)
end
require('bufferline').setup({
options = {
always_show_bufferline = true,
numbers = tabname_format,
show_buffer_icons = true,
show_buffer_close_icons = false,
show_close_icon = false,
--separator_style = 'slant',
},
-- Don't use italic on current buffer
highlights = {buffer_selected = { gui = "bold" },},
})

View file

@ -0,0 +1,61 @@
local has_words_before = function()
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
end
local cmp = require('cmp')
local luasnip = require("luasnip")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end
},
sources = require("cmp").config.sources({
{ name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" },
{ name = "buffer" }, { name = "git" },
{ name = 'nvim_lsp_signature_help' },
{ name = "conventionalcommits" }, { name = "nvim-lua" },
{ name = "calc" }
}),
mapping = cmp.mapping.preset.insert({
['<C-b>'] = 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({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_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" }),
}),
experimental = { ghost_text = true }
})
-- `/` cmdline setup.
cmp.setup.cmdline('/', { sources = { { name = 'buffer' } } })
-- `:` cmdline setup.
cmp.setup.cmdline(':', {
sources = cmp.config
.sources({ { name = 'path' } }, { { name = 'cmdline' } })
})

View file

@ -0,0 +1,64 @@
local lsp_status = require("lsp-status")
lsp_status.config({
current_function = false,
show_filename = false,
diagnostics = true,
})
lsp_status.register_progress()
local utils = require("nvim-lsp-setup.utils")
require("nvim-lsp-setup").setup({
default_mappings = false,
mappings = {
gD = "lua vim.lsp.buf.declaration()",
gd = "Telescope lsp_definitions",
gt = "Telescope lsp_type_definitions",
gi = "Telescope lsp_implementations",
gr = "Telescope lsp_references",
K = "lua vim.lsp.buf.hover()",
["<C-k>"] = "lua vim.lsp.buf.signature_help()",
["<leader>rn"] = "lua vim.lsp.buf.rename()",
["<leader>ca"] = "lua vim.lsp.buf.code_action()",
["<leader>f"] = "lua vim.lsp.buf.formatting()",
["<leader>e"] = "lua vim.lsp.diagnostic.show_line_diagnostics()",
["<leader>d"] = "Telescope diagnostics",
["<C-p>"] = "lua vim.diagnostic.goto_prev()",
["<C-n>"] = "lua vim.diagnostic.goto_next()",
},
on_attach = function(client)
utils.format_on_save(client)
require("illuminate").on_attach(client)
lsp_status.on_attach(client)
end,
capabilities = vim.tbl_extend("keep", vim.lsp.protocol.make_client_capabilities(), lsp_status.capabilities),
servers = {
ansiblels = {},
bashls = {},
dockerls = {},
eslint = {},
jsonls = {},
pylsp = {},
rust_analyzer = require("nvim-lsp-setup.rust-tools").setup({
server = {
settings = {
["rust-analyzer"] = {
cargo = {
loadOutDirsFromCheck = true,
},
checkOnSave = { command = "clippy" },
procMacro = {
enable = true,
},
},
},
},
}),
sumneko_lua = require('lua-dev').setup({}),
taplo = {},
terraformls = {},
tflint = {},
volar = {},
yamlls = {},
},
})

View file

@ -0,0 +1,33 @@
local telescope = require("telescope")
local actions = require("telescope.actions")
local themes = require("telescope.themes")
telescope.setup({
defaults = {
mappings = {
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<ESC>"] = actions.close,
["<C-c>"] = actions.close
},
n = {
["<ESC>"] = actions.close,
["<C-c>"] = actions.close
}
}
},
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true
},
["ui-select"] = {
themes.get_dropdown({})
},
}
})
telescope.load_extension("fzf")
telescope.load_extension("ui-select")

View file

@ -0,0 +1,9 @@
require('nvim-treesitter.configs').setup({
highlight = {enable = true, additional_vim_regex_highlighting = false},
indent = {enable = true},
ensure_installed = {
"bash", "c", "cpp", "css", "dockerfile", "hcl", "html", "javascript",
"json", "latex", "lua", "markdown", "python", "rust", "svelte", "toml",
"tsx", "typescript", "vim", "vue", "yaml"
}
})