-- Options ---------- vim.o.undofile = true vim.o.backup = true vim.cmd "set backupdir-=." vim.o.mouse = "a" vim.o.ignorecase = true vim.o.smartcase = true vim.o.smartindent = true vim.o.tabstop = 4 vim.o.shiftwidth = 4 vim.o.inccommand = "split" vim.o.scrolloff = 1 vim.o.sidescrolloff = 5 vim.o.colorcolumn = "80" vim.o.cursorline = true vim.o.title = true vim.o.wildmode = "longest:full,full" vim.o.completeopt = "menu,menuone,preview,noinsert,noselect" -- Use ripgrep vim.o.grepprg = vim.g.ripgrep_path .. " --vimgrep --smart-case" vim.o.grepformat = "%f:%l:%c:%m," .. vim.o.grepformat vim.o.termguicolors = true vim.o.background = "dark" -- Mode already shown by the status line vim.o.showmode = false -- Do not set "trail:-" because it messes up the highlighting vim.o.listchars = "tab:│ ,extends:>,precedes:<,nbsp:+" vim.wo.list = true vim.o.fillchars = "fold:─,vert:│" -- Leaders ---------- vim.g.maplocalleader = "," vim.g.mapleader = ";" -- Misc ------- -- From neovim#14420 -- Restores the position of previously opened files vim.cmd [[ augroup LastCursorPos autocmd! autocmd BufReadPost * if @% !~# "\.git[\/\\]COMMIT_EDITMSG$" && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif augroup end ]] -- Highlight yanked text vim.cmd "autocmd TextYankPost * silent! lua vim.highlight.on_yank()" vim.g.tex_flavor = "latex" vim.cmd "colorscheme gruvbox" -- Mappings ----------- local map = vim.api.nvim_set_keymap local mapopts = { noremap = true, silent = true } vim.fn["camelcasemotion#CreateMotionMappings"] "" map("n", "=of", [[:set =(&formatoptions =~ "a") ? 'formatoptions-=a' : 'formatoptions+=a']], mapopts) -- Plugins ---------- -- Gitsigns require('gitsigns').setup { keymaps = { noremap = true, buffer = true, silent = true, ['n ]c'] = { expr = true, "&diff ? ']c' : 'lua require\"gitsigns\".next_hunk()'"}, ['n [c'] = { expr = true, "&diff ? '[c' : 'lua require\"gitsigns\".prev_hunk()'"}, ['n hs'] = 'lua require"gitsigns".stage_hunk()', ['n hu'] = 'lua require"gitsigns".undo_stage_hunk()', ['n hr'] = 'lua require"gitsigns".reset_hunk()', ['n hR'] = 'lua require"gitsigns".reset_buffer()', ['n hp'] = 'lua require"gitsigns".preview_hunk()', ['n hb'] = 'lua require"gitsigns".blame_line()', -- Text objects ['o ih'] = ':lua require"gitsigns".select_hunk()', ['x ih'] = ':lua require"gitsigns".select_hunk()', } } -- Treesitter require('nvim-treesitter.configs').setup { highlight = { enable = true, }, incremental_selection = { enable = true, keymaps = { init_selection = "gnn", node_incremental = "grn", scope_incremental = "grc", node_decremental = "grm", }, }, indent = { enable = true, }, matchup = { enable = true, }, textobjects = { select = { enable = true, keymaps = { -- You can use the capture groups defined in textobjects.scm ["af"] = "@function.outer", ["if"] = "@function.inner", ["ac"] = "@class.outer", ["ic"] = "@class.inner", }, }, move = { enable = true, goto_next_start = { ["]m"] = "@function.outer", ["]]"] = "@class.outer", }, goto_next_end = { ["]M"] = "@function.outer", ["]["] = "@class.outer", }, goto_previous_start = { ["[m"] = "@function.outer", ["[["] = "@class.outer", }, goto_previous_end = { ["[M"] = "@function.outer", ["[]"] = "@class.outer", }, }, }, } vim.o.foldmethod = 'expr' vim.o.foldexpr = 'nvim_treesitter#foldexpr()' -- Completion-nvim vim.g.completion_chain_complete_list = { default = { { complete_items = { 'lsp', 'ts', 'path', 'snippet', 'buffers', 'tmux', }, } }, } vim.cmd [[autocmd BufEnter * lua require'completion'.on_attach()]] local map = vim.api.nvim_set_keymap vim.g.completion_enable_snippet = "snippets.nvim" -- Telescope map("n", "fb", "Telescope buffers", mapopts) map("n", "ff", "Telescope find_files", mapopts) map("n", "fg", "Telescope live_grep", mapopts) map("n", "fh", "Telescope help_tags", mapopts) map("n", "ft", "Telescope treesitter", mapopts) -- Lualine local lsp_status = require('lsp-status') lsp_status.config { indicator_errors = "err:", indicator_hint = "hint:", indicator_info = "info:", indicator_ok = "ok", indicator_warnings = "warn:", spinner_frames = {""}, status_symbol = "lsp:", } lsp_status.register_progress() function LspStatus() if #vim.lsp.buf_get_clients() < 1 then return "" end return lsp_status.status() end require("lualine").setup { options = { component_separators = "", icons_enabled = false, section_separators = "", }, sections = { lualine_c = {'filename', LspStatus}, }, } -- Snippets.nvim require("snippets").use_suggested_mappings() -- OSCyank -- Text yanked into the "t register gets copied using OSC52 escape sequences -- (e.g. goes through SSH) vim.cmd "autocmd TextYankPost * if v:event.regname is 't' | OSCYankReg t | endif"