nvim-config

Log | Files | Refs | Submodules | README

init.lua (3333B)


      1 vim.loader.enable()
      2 
      3 vim.g.loaded_matchparen = 1
      4 vim.g.loaded_matchit = 1
      5 
      6 vim.g.python_host_prog = "/bin/python"
      7 vim.g.oak_statusline = 1
      8 
      9 if jit.os == "Linux" then
     10   vim.g.python3_host_prog = "/bin/python3"
     11 elseif jit.os == "Darwin" then
     12   vim.g.python3_host_prog = "/usr/bin/python3"
     13 end
     14 
     15 local o = vim.opt
     16 -- o.debug = "msg"
     17 o.number = true
     18 o.relativenumber = true
     19 o.hidden = true
     20 o.termguicolors = true
     21 o.splitright = true
     22 o.lazyredraw = true
     23 o.foldenable = false
     24 o.textwidth = 100
     25 o.colorcolumn = "+0"
     26 o.signcolumn = "yes:1"
     27 o.scrolloff = 5
     28 o.winblend = 10
     29 o.updatetime = 500
     30 o.cursorline = false
     31 o.mouse = "nvr"
     32 o.mousemodel = 'extend'
     33 o.previewheight = 10
     34 o.title = true
     35 o.cursorline = true
     36 o.cursorlineopt = { "number" }
     37 o.wrap = true
     38 o.linebreak = true
     39 o.breakindent = true
     40 o.showbreak = "> "
     41 o.laststatus = 3
     42 
     43 -- Completion and ui
     44 o.inccommand = "nosplit"
     45 o.completeopt = { "menuone", "noinsert" }
     46 o.list = true
     47 o.listchars = {
     48   tab = "|-",
     49   trail = "•",
     50   nbsp = "!",
     51   conceal = ":",
     52   precedes = "<",
     53   extends = ">"
     54 }
     55 o.tags = ".tags;/"
     56 o.undofile = true
     57 o.grepprg = "rg --vimgrep"
     58 o.grepformat = "%f:%l:%c:%m"
     59 
     60 -- Conceal
     61 o.conceallevel = 1
     62 o.concealcursor = "niv"
     63 
     64 -- Tabs
     65 o.tabstop = 2
     66 o.shiftwidth = 2
     67 o.softtabstop = 2
     68 o.expandtab = true
     69 
     70 o.shortmess:append "c"
     71 o.sessionoptions:remove "buffers"
     72 
     73 -- Those damn temporary files cloberring the search for a filename
     74 o.suffixes:prepend {
     75   ".aux",
     76   ".bbl",
     77   ".pdf",
     78   ".nav",
     79   ".run.xml",
     80   ".bcf",
     81   ".blg",
     82   ".fdb_latexmk",
     83   ".fls",
     84   ".log",
     85   ".out",
     86   ".snm"
     87 }
     88 
     89 o.foldmethod = "expr"
     90 o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
     91 o.foldtext = 'v:lua.vim.treesitter.foldtext()'
     92 
     93 vim.g.mapleader = " "
     94 vim.g.maplocalleader = "$"
     95 
     96 require "plugins" -- Load all plugins
     97 
     98 vim.api.nvim_create_autocmd("TextYankPost", {
     99   callback = function()
    100     pcall(vim.highlight.on_yank, { higroup = "Visual", timeout = 250 })
    101   end
    102 })
    103 vim.cmd [[language en_US.utf8]]
    104 vim.cmd [[language time POSIX]]
    105 
    106 -- Now load plugins and such
    107 require "mappings".set_mappings()
    108 require "neogit-config"
    109 
    110 -- Set up some useful diagnostics stuff
    111 vim.api.nvim_create_autocmd("InsertEnter", {
    112   callback = function()
    113     -- Force off lsp_lines on enter
    114     vim.diagnostic.config { virtual_lines = false }
    115   end
    116 })
    117 vim.api.nvim_create_autocmd("CursorHold", {
    118   callback = function()
    119     if not vim.diagnostic.config().virtual_lines then
    120       vim.diagnostic.open_float { focusable = false, scope = 'line' }
    121     end
    122   end
    123 })
    124 
    125 do
    126   local filetypes = {
    127     gitcommit = true,
    128     gitrebase = true,
    129   }
    130 
    131   local secs_in_day = 24 * 60 * 60
    132 
    133   local function handle(opts)
    134     local mark = require'shadautls'.mark_for_path(vim.fn.fnamemodify(opts.file, ":p"))
    135     if mark and mark.time <= secs_in_day and not filetypes[opts.match] then
    136       vim.cmd [[normal! g`"]]
    137     end
    138     return true
    139   end
    140 
    141   vim.api.nvim_create_autocmd("BufRead", {
    142     callback = function(opts)
    143       vim.api.nvim_create_autocmd("FileType", {
    144         callback = handle,
    145         once = true,
    146         buffer = opts.buf,
    147       })
    148     end
    149   })
    150 end
    151 
    152 vim.fn.digraph_setlist {
    153   { "</", "⟨" },
    154   { "/>", "⟩"}
    155 }
    156 
    157 function ReloadModule()
    158   vim.ui.select(vim.tbl_keys(package.loaded), {
    159     prompt = "Module:",
    160   }, function(choice)
    161     if choice then
    162       package.loaded[choice] = nil
    163       require(choice)
    164     end
    165   end)
    166 end