• Stars
    star
    548
  • Rank 81,119 (Top 2 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 2 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Neovim dev container support - Mirror of https://codeberg.org/esensar/nvim-dev-container

devcontainer

Goal of this plugin is to provide functionality similar to VSCode's remote container development plugin and other functionality that enables development in docker container. This plugin is inspired by jamestthompson3/nvim-remote-containers, but aims to enable having neovim embedded in docker container.

NOTE: If you do not have an account registered and do not want to register one, you can use mailing lists to report bugs, discuss the project and send patches:

WORK IN PROGRESS

Requirements

  • NeoVim version 0.9.0+ (previous versions may be supported, but are not tested - commands and autocommands will definitely fail)
  • nvim-treesitter with included jsonc parser (or manually installed jsonc parser)

Installation

Install using favourite plugin manager.

e.g. Using Packer.nvim

use {
  'https://codeberg.org/esensar/nvim-dev-container',
  requires = { 'nvim-treesitter/nvim-treesitter' }
}

or assuming nvim-treesitter is already available:

use { 'https://codeberg.org/esensar/nvim-dev-container' }

Usage

To use the plugin with defaults just call the setup function:

require("devcontainer").setup{}

It is possible to override some of the functionality of the plugin with options passed into setup. Everything passed to setup is optional. Following block represents default values:

require("devcontainer").setup {
  config_search_start = function()
    -- By default this function uses vim.loop.cwd()
    -- This is used to find a starting point for .devcontainer.json file search
    -- Since by default, it is searched for recursively
    -- That behavior can also be disabled
  end,
  workspace_folder_provider = function()
    -- By default this function uses first workspace folder for integrated lsp if available and vim.loop.cwd() as a fallback
    -- This is used to replace `${localWorkspaceFolder}` in devcontainer.json
    -- Also used for creating default .devcontainer.json file
  end,
  terminal_handler = function(command)
    -- By default this function creates a terminal in a new tab using :terminal command
    -- It also removes statusline when that tab is active, to prevent double statusline
    -- It can be overridden to provide custom terminal handling
  end,
  nvim_dockerfile_template = function(base_image)
    -- Takes base_image and returns string, which should be used as a Dockerfile
    -- This is used when adding neovim to existing images
    -- Check out default implementation in lua/devcontainer/config.lua
    -- It installs neovim version based on current version
  end,
  devcontainer_json_template = function()
    -- Returns table - list of lines to set when creating new devcontainer.json files
    -- As a template
    -- Used only when using functions from commands module or created commands
  end,
  -- Can be set to false to prevent generating default commands
  -- Default commands are listed below
  generate_commands = true,
  -- By default no autocommands are generated
  -- This option can be used to configure automatic starting and cleaning of containers
  autocommands = {
    -- can be set to true to automatically start containers when devcontainer.json is available
    init = false,
    -- can be set to true to automatically remove any started containers and any built images when exiting vim
    clean = false,
    -- can be set to true to automatically restart containers when devcontainer.json file is updated
    update = false,
  },
  -- can be changed to increase or decrease logging from library
  log_level = "info",
  -- can be set to true to disable recursive search
  -- in that case only .devcontainer.json and .devcontainer/devcontainer.json files will be checked relative
  -- to the directory provided by config_search_start
  disable_recursive_config_search = false,
  -- By default all mounts are added (config, data and state)
  -- This can be changed to disable mounts or change their options
  -- This can be useful to mount local configuration
  -- And any other mounts when attaching to containers with this plugin
  attach_mounts = {
    -- Can be set to true to always mount items defined below
    -- And not only when directly attaching
    -- This can be useful if executing attach command separately
    always = false,
    neovim_config = {
      -- enables mounting local config to /root/.config/nvim in container
      enabled = false,
      -- makes mount readonly in container
      options = { "readonly" }
    },
    neovim_data = {
      -- enables mounting local data to /root/.local/share/nvim in container
      enabled = false,
      -- no options by default
      options = {}
    },
    -- Only useful if using neovim 0.8.0+
    neovim_state = {
      -- enables mounting local state to /root/.local/state/nvim in container
      enabled = false,
      -- no options by default
      options = {}
    },
    -- This takes a list of mounts (strings) that should always be added whenever attaching to containers
    -- This is passed directly as --mount option to docker command
    -- Or multiple --mount options if there are multiple values
    custom_mounts = {}
  },
  -- This takes a list of mounts (strings) that should always be added to every run container
  -- This is passed directly as --mount option to docker command
  -- Or multiple --mount options if there are multiple values
  always_mount = {},
  -- This takes a string (usually either "podman" or "docker") representing container runtime
  -- That is the command that will be invoked for container operations
  -- If it is nil, plugin will use whatever is available (trying "podman" first)
  container_runtime = nil,
  -- This takes a string (usually either "podman-compose" or "docker-compose") representing compose command
  -- That is the command that will be invoked for compose operations
  -- If it is nil, plugin will use whatever is available (trying "podman-compose" first)
  compose_command = nil,
}

Check out wiki for more information.

Commands

If not disabled by using generate_commands = false in setup, this plugin provides the following commands:

  • DevcontainerBuild - builds image from nearest devcontainer.json
  • DevcontainerImageRun - runs image from nearest devcontainer.json
  • DevcontainerBuildAndRun - builds image from nearest devcontainer.json and then runs it
  • DevcontainerBuildRunAndAttach - builds image from nearest devcontainer.json (with neovim added), runs it and attaches to neovim in it - currently using terminal_handler, but in the future with Neovim 0.8.0 maybe directly (#30)
  • DevcontainerComposeUp - run docker-compose up based on devcontainer.json
  • DevcontainerComposeDown - run docker-compose down based on devcontainer.json
  • DevcontainerComposeRm - run docker-compose rm based on devcontainer.json
  • DevcontainerStartAuto - start whatever is defined in devcontainer.json
  • DevcontainerStartAutoAndAttach - start and attach to whatever is defined in devcontainer.json
  • DevcontainerAttachAuto - attach to whatever is defined in devcontainer.json
  • DevcontainerStopAuto - stop whatever was started based on devcontainer.json
  • DevcontainerStopAll - stop everything started with this plugin (in current session)
  • DevcontainerRemoveAll - remove everything started with this plugin (in current session)
  • DevcontainerLogs - open plugin log file
  • DevcontainerOpenNearestConfig - opens nearest devcontainer.json file if it exists
  • DevcontainerEditNearestConfig - opens nearest devcontainer.json file if it exists, or creates a new one if it does not

Functions

Check out :h devcontainer for full list of functions.

Contributing

Check out contributing guidelines.

License

MIT

More Repositories

1

kotlinx-serialization-msgpack

MsgPack support for kotlinx.serialization -- msgpack.org[kotlinx.serialization]
Kotlin
44
star
2

neovim-java

Neovim Java client library. Provides multiple interfaces for communicating with Neovim instance via multiple different protocols. - Moved to https://codeberg.org/neovim-java/neovim-java
Java
41
star
3

fbihtax

CLI tool to help manage tax payments in FBiH (Bosnia and Herzegovina Federation) written in Rust. - Moved to https://sr.ht/~esensar/fbihtax/
Rust
5
star
4

neovim-java-plugin-host

Neovim Java plugin manager and host - Moved to https://codeberg.org/neovim-java/neovim-java-plugin-host
Lua
4
star
5

neovim-kotlin

Neovim Kotlin client library. Provides interface for communicating with Neovim instance via multiple different protocols. - Moved to https://codeberg.org/esensar/neovim-kotlin
Kotlin
4
star
6

vimwiki-reviews-lua

Simple periodical review extension for vimwiki(https://github.com/vimwiki/vimwiki). - Moved to https://codeberg.org/vimwiki-reviews/vimwiki-reviews-lua
Lua
3
star
7

bugged-racing

Submission for GitHub Game Off 2021 - https://itch.io/jam/game-off-2021 - Continued development after the jam
GDScript
2
star
8

dotfiles

My dotfiles - Configurations for editors and more
Shell
2
star
9

advent-of-code

Advent of Code (https://adventofcode.com/) solutions. - Moved to https://codeberg.org/esensar/advent-of-code
Rust
1
star
10

mbed_3d_labyrinth

3D labyrinth game written for university project in mbed's environment for N5110 display and generic joystick. Contains porting to terminal display, for use on *NIX and Windows systems.
C++
1
star
11

neovim-http-api-plugin

Very simple HTTP wrapper around Neovim RPC API - demonstration of neovim-java-plugin-host - Moved to https://codeberg.org/neovim-java/neovim-http-api-plugin
Java
1
star
12

rxjava-github

Sample RxJava app using GitHub API made for Sarajevo Mobile Technology Meetup 04.06.2016. Showcases simple use cases for RxJava Observables and RxBindings to connect user events into flows.
Java
1
star
13

RealTimeTalk

University course project application used as a small social network with real time talk capabilities. This is the Android application used to access the system and talk to other users.
Java
1
star