|
|
|
|
|
-- 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 |
|
|
|
|
|
-- commands that don't exist in lua yet |
|
|
vim.cmd [[ |
|
|
color molokai |
|
|
]] |
|
|
|
|
|
-- Keybind: use '-' to open the file explorer |
|
|
vim.api.nvim_set_keymap('n', '-', ':Ex<CR>', { noremap=true, silent=true }) |
|
|
|
|
|
-- lsp configuration |
|
|
local nvim_lsp = require('lspconfig') |
|
|
local function buf_set_keymap(...) |
|
|
vim.api.nvim_buf_set_keymap(bufnr, ...) |
|
|
end |
|
|
local opts = { noremap=true, silent=true } |
|
|
|
|
|
local on_attach = function(client, bufnr) |
|
|
-- let's use the lsp filetype attach to set buffer (and window) options |
|
|
vim.bo.expandtab = true |
|
|
vim.bo.tabstop = 4 |
|
|
vim.bo.shiftwidth = 4 |
|
|
vim.bo.softtabstop = 4 |
|
|
vim.bo.textwidth = 79 |
|
|
|
|
|
vim.wo.number = true |
|
|
vim.wo.colorcolumn = '80' |
|
|
|
|
|
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 |
|
|
nvim_lsp.rust_analyzer.setup { |
|
|
on_attach = on_attach |
|
|
} |
|
|
|
|
|
nvim_lsp.pyright.setup { |
|
|
on_attach = on_attach |
|
|
} |
|
|
|
|
|
-- lsp saga improves the display of LSP information |
|
|
local saga = require('lspsaga') |
|
|
saga.init_lsp_saga { |
|
|
error_sign = '>', |
|
|
warn_sign = '#', |
|
|
hint_sign = '!', |
|
|
infor_sign = '?', |
|
|
border_style = "round", |
|
|
} |
|
|
|
|
|
-- treesitter |
|
|
require 'nvim-treesitter.configs'.setup { |
|
|
ensure_installed = 'maintained', |
|
|
sync_install = false, |
|
|
highlight = { |
|
|
enable = true, |
|
|
}, |
|
|
} |
|
|
|
|
|
-- lualine (better statusline) |
|
|
require 'lualine'.setup { |
|
|
options = { |
|
|
icons_enabled = true, |
|
|
-- theme = 'ayu_dark', |
|
|
theme = 'ayu_mirage', |
|
|
component_separators = { left = '', right = ''}, |
|
|
section_separators = { left = '', right = ''}, |
|
|
disabled_filetypes = {}, |
|
|
always_divide_middle = true, |
|
|
}, |
|
|
sections = { |
|
|
lualine_a = {'mode'}, |
|
|
lualine_b = {'branch', 'diff', 'diagnostics'}, |
|
|
lualine_c = {'filename'}, |
|
|
lualine_x = {'encoding', 'fileformat', 'filetype'}, |
|
|
lualine_y = {'progress'}, |
|
|
lualine_z = {'location'} |
|
|
}, |
|
|
inactive_sections = { |
|
|
lualine_a = {}, |
|
|
lualine_b = {}, |
|
|
lualine_c = {'filename'}, |
|
|
lualine_x = {'location'}, |
|
|
lualine_y = {}, |
|
|
lualine_z = {} |
|
|
}, |
|
|
tabline = { |
|
|
lualine_a = {}, |
|
|
lualine_b = {'filename'}, |
|
|
lualine_c = {}, |
|
|
lualine_x = {}, |
|
|
lualine_y = {}, |
|
|
lualine_z = {'tabs'} |
|
|
}, |
|
|
extensions = {} |
|
|
}
|
|
|
|