Skip to content

Transition guide to lua configuration

David Granström edited this page Jul 1, 2022 · 6 revisions

All global options have been removed (e.g. g:scnvim_postwin_direction) these are instead set using the scnvim.setup function. The configuration object used is a lua table (i.e. Dictionary) with keys matching the same naming convention as the global variables used before.

If you had let g:scnvim_postwin_direction = 'left' in your init.vim before, you can use postwin.direction = 'left' instead

lua << EOF
local scnvim = require 'scnvim'
scnvim.config({
  postwin = {
    direction = 'left',
  },
})
EOF

The lua << EOF line above is to tell nvim that we will evaluate a block of lua code inside a vim script file (init.vim in this case).

See the configuration page for all available options.

Configuration example

This configuration sets up mappings, configures the eval "flash" color to be the same highlight group as hl-IncSearch and displays the post window as a floating window.

lua << EOF
local scnvim = require 'scnvim'
local map = scnvim.map
local map_expr = scnvim.map_expr
scnvim.setup {
  keymaps = {
    ['<M-e>'] = map('editor.send_line', {'i', 'n'}),
    ['<C-e>'] = {
      map('editor.send_block', {'i', 'n'}),
      map('editor.send_selection', 'x'),
    },
    ['<CR>'] = map('postwin.toggle'),
    ['<M-CR>'] = map('postwin.toggle', 'i'),
    ['<M-L>'] = map('postwin.clear', {'n', 'i'}),
    ['<C-k>'] = map('signature.show', {'n', 'i'}),
    ['<F12>'] = map('sclang.hard_stop', {'n', 'x', 'i'}),
    ['<leader>st'] = map('sclang.start'),
    ['<leader>sk'] = map('sclang.recompile'),
    ['<F1>'] = map_expr('s.boot'),
    ['<F2>'] = map_expr('s.meter'),
  },
  editor = {
    highlight = {
      color = 'IncSearch',
    },
  },
  postwin = {
    float = {
      enabled = true,
    },
  },
}
EOF