CONFIG

init.lua

#org-config #neovim
Published — Updated

Here’s where the important work happens, loading plugins and making sure everything is in order.

Setup

I pull a few pieces of the vim library into the local namespace. Saves typing.

tools = require('tools')
local map = tools.map

local cmd = vim.cmd  -- vim commands (eg cmd('pwd'))
local fn = vim.fn    -- vim functions (eg fn.buffer())
local g = vim.g      -- a table for global variables
local opt = vim.opt  -- to set options

General options

Not all of the VimL options translate directly to Lua. We use vim.cmd for those.

cmd[[filetype plugin on]]
cmd[[autocmd FileType * setlocal formatoptions-=cro]]

But I use vim.opt to specify everything else.

opt.background = 'dark'
opt.completeopt = {'menuone', 'noinsert', 'noselect'}  -- completion options (for deoplete)
opt.cursorline = true               -- highlight current line
opt.encoding = "utf-8"
opt.expandtab = true                -- spaces instead of tabs
opt.hidden = true                   -- enable background buffers
opt.ignorecase = true               -- ignore case in search
opt.joinspaces = false              -- no double spaces with join
opt.list = true                     -- show some invisible characters
opt.maxmempattern = 1000            -- for Riv
opt.mouse = "nv"                    -- Enable mouse in normal and visual modes
opt.number = true                   -- show line numbers
opt.relativenumber = true           -- number relative to current line
opt.scrolloff = 4                   -- lines of context
opt.shiftround = true               -- round indent
opt.shiftwidth = 2                  -- size of indent
opt.sidescrolloff = 8               -- columns of context
opt.smartcase = true                -- do not ignore case with capitals
opt.smartindent = true              -- insert indents automatically
opt.splitbelow = true              -- put new windows below current
opt.splitright = true               -- put new vertical splits to right
opt.termguicolors = true            -- truecolor support
opt.wildmode = {'list', 'longest'}  -- command-line completion mode
opt.wrap = false  -- disable line wrap

g.mapleader = ' '
g.maplocalleader = ','
g.python3_host_prog = 'python'
g.rst_syntax_code_list = { "python" }

Putting it all together

require("plugins")

<<config-nvim-locals>>

<<config-nvim-cmd-options>>

<<config-nvim-options>>

<<config-nvim-keys-telescope>>