My own configuration files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.2 KiB

local nvim_lsp = require('lspconfig')
local saga = require('lspsaga')
-- commands that don't exist in lua yet
vim.cmd [[
]]
-- general configuration
vim.opt.background = 'dark' -- the theme background is dark
vim.opt.termguicolors = true
vim.opt.cursorline = true -- highlight the line with the cursor
vim.opt.wrap = false -- do not wrap long lines
vim.opt.foldmethod = 'marker' -- when folding, use the marker
vim.opt.laststatus = 2 -- always show the status line
vim.opt.showtabline = 2 -- always show the tab bar
vim.opt.scrolloff = 2 -- number of lines to always have around cursor
vim.opt.splitright = true -- vertical splits open on the right
vim.opt.splitbelow = true -- horizontal splits open on the bottom
vim.g.mapleader = ' ' -- space is the leader character
-- Keybind: use '-' to open the file explorer
vim.api.nvim_set_keymap('n', '-', ':Ex<CR>', { noremap=true, silent=true })
-- Rainbow braket configuration
vim.g['rainbow_active'] = true
-- lsp saga improves the display of LSP information
saga.init_lsp_saga {
error_sign = '',
warn_sign = '',
hint_sign = '',
infor_sign = '',
border_style = "round",
}
-- lsp configuration
local on_attach = function(client, bufnr)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local opts = { noremap=true, silent=true }
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>Lspsaga hover_doc<CR>', opts)
buf_set_keymap('n', 'C-K', '<Cmd>Lspsaga signature_help<CR>', opts)
if client.resolved_capabilities.document_formatting then
vim.api.nvim_command [[augroup Format]]
vim.api.nvim_command [[autocmd! * <buffer>]]
vim.api.nvim_command [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
vim.api.nvim_command [[augroup END]]
end
end
-- attach the keymaps
-- lsp servers/languages configuration
require 'lspconfig'.rust_analyzer.setup {
on_attach = on_attach
}
require 'lspconfig'.pyright.setup {
on_attach = on_attach
}
-- treesitter
require 'nvim-treesitter.configs'.setup {
ensure_installed = 'maintained',
sync_install = false,
highlight = {
enable = true,
},
}