-- 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', { 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' vim.diagnostic.config({signs = false}) buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'gF', 'lua vim.lsp.buf.formatting()', opts) buf_set_keymap('n', 'gR', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'g?', 'lua vim.lsp.buf.code_action()', opts) buf_set_keymap('n', 'gp', 'lua vim.lsp.buf.completion()', opts) buf_set_keymap('n', 'ge', 'lua vim.diagnostic.open_float()', opts) if client.resolved_capabilities.document_formatting then vim.api.nvim_command [[augroup Format]] vim.api.nvim_command [[autocmd! * ]] vim.api.nvim_command [[autocmd BufWritePre 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 } -- 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'}, lualine_c = { { 'diagnostics', symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}, } }, lualine_d = {'filename'}, lualine_w = {'encoding'}, lualine_x = {'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 = {} }