Skip to content

Commit

Permalink
Init coc.nvim extension
Browse files Browse the repository at this point in the history
  • Loading branch information
oxalica committed Feb 25, 2023
1 parent d4e6677 commit 128a699
Show file tree
Hide file tree
Showing 12 changed files with 3,714 additions and 28 deletions.
27 changes: 12 additions & 15 deletions dev/vim-coc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ let
customRC = ''
source ${./vimrc.vim}
let $COC_NO_PLUGINS = 1
if !empty($COC_NIL_PATH)
execute 'set rtp^=' . $COC_NIL_PATH
endif
autocmd BufRead,BufNewFile *.nix setf nix
Expand Down Expand Up @@ -83,21 +85,15 @@ let
'';

cocSetting = {
"coc.preferences.formatOnSaveFiletypes" = [ "nix" ];
"links.tooltip" = true;
coc.preferences.formatOnSaveFiletypes = [ "nix" ];
links.tooltip = true;
semanticTokens.filetypes = [ "nix" ];
languageserver.nix = {
command = pkgs.writeShellScript "nil" ''
exec "$NIL_PATH" "$@"
'';
filetypes = [ "nix" ];
rootPatterns = [ "flake.nix" ];
settings.nil = {
testSetting = 42;
formatting.command = [ "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" ];
diagnostics.excludedFiles = [ "generated.nix" ];
};
};

nil.server.path = pkgs.writeShellScript "nil" ''
exec "$NIL_PATH" "$@"
'';
nil.formatting.command = [ "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" ];
nil.diagnostics.excludedFiles = [ "generated.nix" ];
};


Expand All @@ -115,6 +111,7 @@ pkgs.vim_configurable.customize {
packages.myPlugins.start = with pkgs.vimPlugins; [
vim-nix # File type and syntax highlighting.
coc-nvim
coc-json
# FIXME
(nightfox-nvim.overrideAttrs (old: {
src = pkgs.fetchFromGitHub {
Expand Down
16 changes: 16 additions & 0 deletions editors/coc-nil/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
env: {
node: true,
},
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
};
2 changes: 2 additions & 0 deletions editors/coc-nil/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/lib
11 changes: 11 additions & 0 deletions editors/coc-nil/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
src
node_modules
tsconfig.json
*.map
.tags
.DS_Store
webpack.config.js
esbuild.js
.github
.eslintrc.js
.prettierrc
1 change: 1 addition & 0 deletions editors/coc-nil/LICENSE-APACHE
1 change: 1 addition & 0 deletions editors/coc-nil/LICENSE-MIT
37 changes: 37 additions & 0 deletions editors/coc-nil/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# coc-nil

**WIP**

[nil] language server glue for Vim/Neovim, works as an extension with [coc.nvim].

[nil]: https://github.com/oxalica/nil
[coc.nvim]: https://github.com/neoclide/coc.nvim

## Install

`:CocInstall coc-nil`

## Configurations

This extension is configured using a jsonc file. You can open this configuration file using the command `:CocConfig`,
and it is typically located at `$HOME/.config/nvim/coc-settings.json`.

Configurations to the LSP is documentated in
[`docs/configuration.md` of the LSP repository](https://github.com/oxalica/nil/blob/main/docs/configuration.md#reference),
with the exception that configuration keys can **ALSO** be written as flattened dot-separated string key.
That is, `coc-nvim` supports `"nil.nix.binary": "nix"`, `"nil": { "nix": { "binary": "nix" } }"`,
and even `"nil": { "nix.binary": "nix" }`.

The table below shows all extra configurations for the extension itself.

| Configuration | Description | Default |
|---|---|---|
| `nil.enable` | Enable `coc-nil` | `true` |
| `nil.server.path` | Path to the `nil` LSP server | `"nil"` |

## License

"coc-nil" is primarily distributed under the terms of both the MIT
license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.
Loading

0 comments on commit 128a699

Please sign in to comment.