Coder Social home page Coder Social logo

config.nvim's Introduction

Config file loader for Neovim

This replaces the need to use Vimscript or Lua for parts of the configuration e.g. keybindings.

Installation

Using a package manager

For the installation the install(install.bat) script can be used.

Using packer this looks like this:

Using the binary

{
    'ModProg/config.nvim',
    run = function(plugin)
        local await = require 'packer.async'.wait
        local jobs = require 'packer.jobs'

        local neovim_version = vim.version().major .. '.' .. vim.version().minor
        local os
        if jit.os == "Linux" then
            os = "linux"
        elseif jit.os == "Windows" then
            os = "windows"
        else
            os = "macos"
        end
        await(jobs.run({ "./install", "download", os, neovim_version, "latest" }, { cwd = plugin.install_path }))
    end,
}

Building from source

{
    'ModProg/config.nvim',
    run = function(plugin)
        local await = require 'packer.async'.wait
        local jobs = require 'packer.jobs'

        local neovim_version = vim.version().major .. '.' .. vim.version().minor
        await(jobs.run({ "./install", "build", neovim_version}, { cwd = plugin.install_path }))
    end,
}

Manually

Using the binary

Download the correct version from the latest release, i.e. linux-0.8.zip for Linux and Neovim version 0.8. Extract that folder to somewhere on your runtime path. Make sure the config.so stays in the lua folder.

For Linux/OSX you could put it into:

~/.local/share/nvim/site/pack/build/start/config.nvim/lua/config.so

or

~/.config/nvim/lua/pack/plugins/start/config.so

or

~/.config/nvim/lua/config.so

For Windows:

~/AppData/Local/nvim/pack/plugins/start/config.nvim/lua/config.dll

or

~/AppData/Local/nvim/lua/config.dll

Building from source

With go-task
task install

Without go-task

Replace NEOVIM_VERSION with your version e.g. 0.8

cargo build --release -F NEOVIM_VERSION --no-default-features

Then take the correct file acordion to your operating system and put it in the directory explained above:

# On Linux
target/release/libconfig.so -> lua/config.so
# On Windows
target/release/libconfig.dll -> lua/config.dll
# On OSX
target/release/libconfig.dylib -> lua/config.so

Confiuration

User configuration are placed in ~/.config/nvim/config/*.{yaml,toml}

Keys

The configuration for keybindings are in the array keys. Using toml they can be defined like that:

[[keys]]
modes = [] # list of modes `modes = ["i", "n", "!"]` or for a single mode also `modes = "n"`
recursive = true # false means `noremap`
command = false # wrapps all bindings in `<CMD>...<CR>`
silent = false # make mappings silent
unique = false # error on duplicate mappings
expression = false # make rhs of mappings evaluated as an expression
leader = "" # prefixes all lhs mappings
# And than add the mappings
j = "gj"
# Should you want to map one of the above, you can put it in the field `mappings`
[keys.mappings]
silent = "supper silent"

And in yaml

keys:
  - modes:
      - n
      - i
    recursive: true
    command: false
    silent: false
    unique: false
    expression: false
    leader: ""
    j: gj
    mappings:
      silent: super silent

Sets

There are a multitude of possibilities to define set configurations.

The simplest way is as a list, exspecially in yaml:

set:
  - expandtab # Configuring flags like so
  - nonumber # "false" by "no" is also supported
  - number: false # same as this
  - mouse: a # You can directly set values
    completeopt: ["menuone"] # Even multiple in one list item
  - shortmess: # or modify
      append: c
      "+": c
      prepend: c
      "^": c
      remove: c
      "-": c
      # To assign a map there are two ways, either just specify the keys directly
  - listchars:
      # if one of the keys does not match the special keys
      # [append, +, prepend, ^ remove, -, assign, value, =]
      # it will automaticly be assigned as a map
      tab: "<->"
      # The alternative would be to assign using one of the `assign` keys
      assign: {tab: "<->"}
      value: {tab: "<->"}
      "=": {tab: "<->"}

In toml that would look like this:

set = [
    "expandtab",
    "nonumber",
    {mouse = "a", completeopt = ["menuone"]},
    {shortmess = {append = "c", "+": ...}},
]

therefor the prefered syntax in toml would be:

[set]
flags = [
    "expandtab", # Configuring flags like so
    "nonumber" # "false" by "no" is also supported
]
number = false # same as this
mouse = "a" # You can directly set values
completeopt = ["menuone"]

[set.shortmess] # or modify
append = "c"
"+" = "c"
prepend = "c"
"^" = "c"
remove = "c"
"-" = "c"

# As you normally only want to modify a value once, you can use punctuated keys
# and avoid the extra table
set.shortmess.append = "c"

# To assign a map there are two ways, either just specify the keys directly
[set.listchars]
# if one of the keys does not match the special keys
# [append, +, prepend, ^ remove, -, assign, value, =]
# it will automaticly be assigned as a map
tab = "<->"
# The alternative would be to assign using one of the `assign` keys
assign = { tab = "<->" }
value = { tab = "<->" }
"=" = { tab = "<->" }
# Or using a punctuated header to set `value` directly
[set.listchars.value]
tab = "<->"

config.nvim's People

Contributors

modprog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

config.nvim's Issues

Lua config

Neovim plugins often use setup funtions or similar for configuration. There should be a way to configure them from a config.

  • Call "setup" with config
  • Set a lua variable
  • Call some function e.g. add/remove rule for autopairs

(Auto) Reload

Store current config, and when reload is triggered, diff them and reset the removed settings and apply the new ones

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.