GithubHelp home page GithubHelp logo

arywz11 / nvim-compleet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from noib3/nvim-completion

0.0 0.0 0.0 443 KB

:zap: An async autocompletion framework for Neovim

License: MIT License

Rust 99.16% Shell 0.84%

nvim-compleet's Introduction

โšก nvim-compleet

This plugin is still in early development.

preview

๐Ÿ“– Table of Contents

๐Ÿ“ฆ Installation

nvim-compleet requires Neovim 0.7+. Also, since the Rust code has to be compiled it needs the rustup toolchain to be available (follow this guide for instructions on how to install Rust) with rustc version 1.58+, together with the make and ar utilities.

Then installing the plugin is as easy as

require("packer").startup(function()
  use({
    "noib3/nvim-compleet",
    config = function()
      require("compleet").setup()
    end,
    run = "./install.sh release",
  })
end)

๐Ÿš€ Features

Config validation

validation1 validation2 validation3

๐Ÿ”ง Configuration

nvim-compleet is configured by passing a table to the setup function. The default config is

require('compleet').setup({
  ui = {
    menu = {
      -- Where to anchor the completion menu, either "cursor" or "match".
      anchor = "cursor",

      -- Whether to automatically show the menu every time there are
      -- completions available.
      autoshow = true,

      -- The maximum height (in rows) of the completion menu.
      max_height = nil,

      border = {
        -- Whether to add a border to the completion menu's floating window.
        enable = false,

        -- Any of the style formats listed in `:h nvim_open_win`.
        style = "single"
      },
    },

    details = {
      border = {
        -- Whether to add a border to the details's floating window.
        enable = true,

        -- Same as `ui.menu.border.style`.
        style = {
          "",
          "",
          "",
          {" ", "CompleetDetails"},
        }
      },
    },

    hint = {
      -- Whether to show completion hints.
      enable = false,
    }
  },

  completion = {
    -- Whether to enable completion while deleting characters.
    while_deleting = false,
  },

  sources = {
    lipsum = {
      enable = false,
    },
  }
})

โ— Commands

nvim-compleet provides two commands: CompleetStop{!} to stop the completion and CompleetStart{!} to restart it. The versions with the bang ! stop/start the completion in all the buffers, the ones without it only affect the current buffer.

๐ŸŽน Mappings

The following key mappings are exposed:

  • <Plug>(compleet-next-completion): selects the next item in the completion menu;

  • <Plug>(compleet-prev-completion): selects the previous item in the completion menu;

  • <Plug>(compleet-insert-selected-completion): inserts the currently selected completion item into the buffer;

  • <Plug>(compleet-insert-first-completion): inserts the first completion into the buffer. Useful when hints are enabled and ui.menu.autoshow is set to false;

  • <Plug>(compleet-show-completions): shows all the available completions at the current cursor position.

A possible configuration could be:

local compleet = require('compleet')
local keymap = vim.keymap

local tab = function()
  return
    (compleet.is_menu_open() and "<Plug>(compleet-next-completion)")
    or (compleet.has_completions() and "<Plug>(compleet-show-completions)")
    or "<Tab>"
end

local s_tab = function()
  return
    compleet.is_menu_open()
    and "<Plug>(compleet-prev-completion)"
     or "<S-Tab>"
end

local right = function()
  return
    compleet.is_hint_visible()
    and "<Plug>(compleet-insert-first-completion)"
     or "<Right>"
end

local cr = function()
  return
    compleet.is_completion_selected()
    and "<Plug>(compleet-insert-selected-completion)"
     or "<CR>"
end

local opts = { expr = true, remap = true }

keymap.set("i", "<Tab>", tab, opts)
keymap.set("i", "<S-Tab>", s_tab, opts)
keymap.set("i", "<Right>", right, opts)
keymap.set("i", "<CR>", cr, opts)

๐Ÿ“ˆ Roadmap

  • Add LSP source;
  • Add Filepath source;
  • Add Treesitter source;
  • Integrate with snippets engines;
  • Stabilize api, document how to add sources in Rust, add option to provide user-defined sources in Lua;
  • ...

nvim-compleet's People

Contributors

noib3 avatar murderm3l0dy avatar edeneast avatar

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.