-- set shell to avoid problems with FiSH vim.env.SHELL = "/bin/bash" -- disable mouse vim.opt.mouse = "" -- line numbering vim.opt.number = true vim.opt.relativenumber = true vim.opt.encoding = "utf-8" vim.opt.fileencoding = "utf-8" vim.g.mapleader = " " -- vim.cmd([[ -- syntax on -- filetype indent plugin on -- ]]) vim.opt.wrap = false vim.opt.linebreak = true vim.keymap.set("n", "W", ":set wrap!") vim.keymap.set("n", "-", "/") vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = false vim.opt.list = false vim.opt.hlsearch = true -- vim.opt.listchars=tab:→\ ,space:· vim.opt.undofile = true vim.opt.undodir = vim.fn.expand("~/.local/share/nvim/undo") vim.opt.foldlevel = 99 vim.opt.ignorecase = true vim.opt.smartcase = true vim.keymap.set("n", "", ":echo") vim.keymap.set("i", "", ":echo") function save() vim.cmd(":keeppatterns :%s/\\s\\+$//e") vim.cmd(":up") end function toggle_buffer() local buf = vim.api.nvim_win_get_buf(0) if vim.bo[buf].readonly then vim.cmd(":b#") else save() vim.cmd(":b#") end end vim.keymap.set("n", "", ":lua toggle_buffer()") vim.keymap.set("n", "ZZ", ":lua save():xa") vim.keymap.set("n", "", ":lua save()") vim.keymap.set("i", "", ":lua save()") -- vim.keymap.set("n", "d", ":ALEGoToDefinition") vim.keymap.set("v", "ss", ":!sort -u") vim.keymap.set("v", "ee", ":!numlines") vim.keymap.set("i", "", "") vim.keymap.set("i", "jj", "") vim.keymap.set("n", "j", "gj") vim.keymap.set("n", "k", "gk") vim.keymap.set("n", "X", ":! chmod u+x %") vim.keymap.set("n", "§", "/") vim.keymap.set("n", "", "f|2l") vim.keymap.set("n", "", "2hF|2l") vim.keymap.set("n", "", "j") vim.keymap.set("n", "", "k") vim.keymap.set("n", "ay", '"+y') vim.keymap.set("v", "ay", '"+y') vim.keymap.set("n", "aY", '"+Y') vim.keymap.set("v", "aY", '"+Y') vim.keymap.set("n", "ayy", '"+yy') vim.keymap.set("v", "ayy", '"+yy') vim.keymap.set("n", "ap", '"+p') vim.keymap.set("n", "ad", '"+d') vim.keymap.set("v", "ad", '"+d') vim.keymap.set("n", "add", '"+dd') vim.keymap.set("v", "add", '"+dd') vim.keymap.set("n", "c", ":Commentary") vim.keymap.set("v", "c", ":Commentary") vim.opt.scrolloff = 5 vim.cmd([[ " let g:fzf_files_options = '--preview "(pygmentize {} || cat {}) 2> /dev/null | head -'.&lines.'"' let $FZF_DEFAULT_COMMAND = 'fd --type f --exclude target --exclude Cargo.lock --exclude __pycache__' ]]) vim.keymap.set("n", "b", ":up:Buffers") vim.keymap.set("n", "f", ":up:Files") vim.keymap.set("n", "g", ":Rg") vim.cmd([[ " ALE let g:ale_fixers = { \'lua': ['stylua'], \'rust': ['rustfmt'], \} let g:ale_linters = { \'lua': ['stylua'], \'python': ['flake8'], \'rust': ['rls'], \} ]]) vim.g.ale_fix_on_save = 1 vim.g.ale_sign_error = "✗" vim.g.ale_sign_warning = "⚠" vim.g.ale_rust_cargo_use_clippy = 1 vim.g.ale_set_highlights = 0 vim.g.ale_python_flake8_options = "--max-line-length=99" -- ultisnips vim.g.UltiSnipsExpandTrigger = "" vim.g.UltiSnipsJumpForwardTrigger = "" vim.g.UltiSnipsJumpBackwardTrigger = "" vim.cmd([[ let g:UltiSnipsSnippetDirectory=['$HOME/.config/nvim/ultisnips'] ]]) -- marks require("marks").setup({ -- whether to map keybinds or not. default true default_mappings = true, -- which builtin marks to show. default {} -- builtin_marks = { ".", "<", ">", "^" }, -- whether movements cycle back to the beginning/end of buffer. default true cyclic = true, -- whether the shada file is updated after modifying uppercase marks. default false force_write_shada = false, -- how often (in ms) to redraw signs/recompute mark positions. -- higher values will have better performance but may cause visual lag, -- while lower values may cause performance penalties. default 150. refresh_interval = 250, -- sign priorities for each type of mark - builtin marks, uppercase marks, lowercase -- marks, and bookmarks. -- can be either a table with all/none of the keys, or a single number, in which case -- the priority applies to all marks. -- default 10. sign_priority = { lower = 10, upper = 15, builtin = 8, bookmark = 20 }, -- disables mark tracking for specific filetypes. default {} excluded_filetypes = {}, -- marks.nvim allows you to configure up to 10 bookmark groups, each with its own -- sign/virttext. Bookmarks can be used to group together positions and quickly move -- across multiple buffers. default sign is '!@#$%^&*()' (from 0 to 9), and -- default virt_text is "". -- bookmark_0 = { -- sign = "⚑", -- virt_text = "hello world", -- -- explicitly prompt for a virtual line annotation when setting a bookmark from this group. -- -- defaults to false. -- annotate = false, -- }, mappings = { toggle = "m", next = "n", prev = "N", }, }) -- colours vim.cmd([[ " Start flavours vim " End flavours vim " Start flavours lightline " End flavours lightline ]]) -- base16colorspace = 256 -- vim.cmd([[ -- colorscheme $BASE16_THEME -- let g:lightline = {'colorscheme': $BASE16_THEME_} -- ]]) -- Disable LSP highlighting as it breaks normal syntax highlighting for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do vim.api.nvim_set_hl(0, group, {}) end -- vim.g.table_mode_corner = "|" vim.keymap.set("n", "tr", ":TableModeRealign") vim.keymap.set("n", "ci|", "T|ct|") vim.keymap.set("n", "di|", "T|dt|") vim.keymap.set("n", "yi|", "T|yt|") -- Vimboy vim.api.nvim_create_autocmd({ "bufnewfile", "bufread" }, { pattern = os.getenv("HOME") .. "/wiki/*", callback = function() vim.bo.filetype = "vimboy" end, }) local lspconfig = require("lspconfig") -- lspconfig.rust_analyzer.setup({}) lspconfig.lua_ls.setup({ settings = { Lua = { diagnostics = { -- Get the language server to recognize the `vim` global globals = { "vim" }, }, }, }, }) local cmp = require("cmp") cmp.setup({ -- As currently, i am not using any snippet manager, thus disabled it. -- snippet = { -- expand = function(args) -- require("luasnip").lsp_expand(args.body) -- end, -- }, mapping = { [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() -- elseif snippy.can_expand_or_advance() then -- snippy.expand_or_advance() -- elseif has_words_before() then -- cmp.complete() else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() -- elseif snippy.can_jump(-1) then -- snippy.previous() else fallback() end end, { "i", "s" }), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.close(), [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true, }), }, sources = { { name = "nvim_lsp" }, { name = "path" }, { name = "buffer", keyword_length = 5 }, }, experimental = { ghost_text = true, }, })