feat: finalized config

This commit is contained in:
Michael Mandl 2022-02-21 15:15:15 +01:00
parent 28057baf5f
commit c341636729
Signed by: mandlm
GPG key ID: 4AA25D647AA54CC7
11 changed files with 333 additions and 67 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" },},
})

97
lua/plugins/lspconfig.lua Normal file
View file

@ -0,0 +1,97 @@
local coq = require("coq")
local lsp_installer = require("nvim-lsp-installer")
local nvim_runtime_path = vim.split(package.path, ';')
table.insert(nvim_runtime_path, "lua/?.lua")
table.insert(nvim_runtime_path, "lua/?/init.lua")
local language_servers = {
"ansiblels",
"bashls",
"dockerls",
"eslint",
"html",
"pyright",
"remark_ls",
"rust_analyzer",
"sumneko_lua",
"svelte",
"taplo",
"tsserver",
"volar",
}
for _, server_name in pairs(language_servers) do
local server_found, server = lsp_installer.get_server(server_name)
if server_found and not server:is_installed() then
print("Installing " .. server_name)
server:install()
end
end
local extra_server_opts = {
["sumneko_lua"] = function(opts)
opts.settings = {
Lua = {
runtime = {
version = 'LuaJIT',
path = nvim_runtime_path,
},
diagnostics = {
globals = {'vim'},
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
telemetry ={
enable = false,
},
},
}
end
}
local function custom_on_attach(client, buffer_nr)
-- Helper function
local opts = {noremap = true, silent = true}
local function bufnnoremap(key, action)
vim.api.nvim_buf_set_keymap(buffer_nr, 'n', key, action, opts)
end
-- Inspect function
bufnnoremap("K", "<Cmd>lua vim.lsp.buf.hover()<CR>")
-- Rename all references of symbol
bufnnoremap("<leader>R", "<Cmd>lua vim.lsp.buf.rename()<CR>")
-- Navigate diagnostics
bufnnoremap("<C-n>", "<Cmd>lua vim.diagnostic.goto_next()<CR>")
bufnnoremap("<C-p>", "<Cmd>lua vim.diagnostic.goto_prev()<CR>")
-- Show line diagnostics
bufnnoremap("<leader>d", '<Cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>')
-- Open local diagnostics in local list
bufnnoremap("<leader>D", "<Cmd>lua vim.diagnostic.setloclist()<CR>")
-- Open all project diagnostics in quickfix list
bufnnoremap("<leader><C-d>", "<Cmd>lua vim.diagnostic.setqflist()<CR>")
if client.resolved_capabilities.document_formatting then
vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()")
end
end
lsp_installer.on_server_ready(function(server)
local opts = coq.lsp_ensure_capabilities({
on_attach = custom_on_attach,
capabilities = vim.lsp.protocol.make_client_capabilities(),
})
if extra_server_opts[server.name] then
extra_server_opts[server.name](opts)
end
server:setup(opts)
end)

12
lua/plugins/telescope.lua Normal file
View file

@ -0,0 +1,12 @@
local actions = require("telescope.actions")
require('telescope').setup({
defaults = {
mappings = {
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
},
},
})

View file

@ -0,0 +1,21 @@
require('nvim-treesitter.configs').setup({
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
ensure_installed = {
"bash",
"c",
"cpp",
"json",
"lua",
"markdown",
"python",
"rust",
"vim",
"yaml",
},
})