feat(nvim): coc -> lspconfig
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-05-08 23:04:16 -04:00
parent 6753c39ccd
commit 8deffb3adb
12 changed files with 64 additions and 193 deletions

View file

@ -1,97 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (config.vars) neovimIde;
inherit (pkgs) vimPlugins;
in
lib.mkIf neovimIde {
programs = {
neovim = {
coc = {
enable = true;
settings = {
colors.enable = true;
coc.preferences.formatOnType = true;
diagnostic.checkCurrentLine = true;
inlayHint.enable = false;
};
};
extraLuaConfig =
/*
lua
*/
''
vim.api.nvim_create_user_command("Format", "call CocAction('format')", {});
-- Always show the signcolumn, otherwise it would shift the text each time
-- diagnostics appear/become resolved
vim.opt.signcolumn = 'yes';
'';
plugins = [
{
plugin = vimPlugins.coc-snippets;
type = "viml";
config =
/*
vim
*/
''
" use vscode keybinds for snippets completion
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump','''])\<CR>" :
\ CheckBackspace() ? "\<TAB>" :
\ coc#refresh()
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'
'';
}
## Fzf
vimPlugins.coc-fzf
vimPlugins.coc-highlight
vimPlugins.coc-json
vimPlugins.coc-yaml
vimPlugins.coc-toml
{
plugin = vimPlugins.nvim-autopairs;
type = "lua";
config =
/*
lua
*/
''
-- Auto indent when pressing Enter between brackets
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs')
npairs.setup({map_cr=false})
_G.MUtils= {}
MUtils.completion_confirm=function()
if vim.fn["coc#pum#visible"]() ~= 0 then
return vim.fn["coc#pum#confirm"]()
else
return npairs.autopairs_cr()
end
end
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})
'';
}
];
};
};
}

View file

@ -6,7 +6,6 @@
inherit (pkgs) vimPlugins;
in {
imports = [
./coc.nix
./git.nix
./langs
./theme.nix
@ -35,8 +34,15 @@ in {
vim.opt.undofile = true;
vim.opt.undodir = '${config.xdg.cacheHome}/nvim/';
-- Always show the signcolumn, otherwise it would shift
-- the text each time diagnostics appear/become resolved
vim.opt.signcolumn = 'yes';
-- remove highlight on words
vim.keymap.set('n', '<esc>', ':noh<cr><esc>', { noremap = true, silent = true });
vim.keymap.set('n', '<esc>', ':noh<cr><esc>', {
noremap = true,
silent = true,
});
'';
plugins = [

View file

@ -31,12 +31,7 @@ in
});
'';
coc.settings = {
bashIde.shellcheckPath = "${pkgs.shellcheck}/bin/shellcheck";
};
plugins = [
vimPlugins.coc-sh
];
};
};

View file

@ -16,8 +16,6 @@ in
];
plugins = [
vimPlugins.coc-clangd
vimPlugins.coc-cmake
];
};
};

View file

@ -1,4 +1,12 @@
{...}: {
{
config,
lib,
pkgs,
...
}: let
inherit (config.vars) neovimIde;
inherit (pkgs) vimPlugins;
in {
imports = [
./bash.nix
./clang.nix
@ -10,4 +18,40 @@
./python.nix
./web.nix
];
programs = lib.mkIf neovimIde {
neovim = {
extraLuaConfig = lib.mkBefore
/*
lua
*/
''
-- Start completion / snippet stuff
vim.g.coq_settings = { auto_start = true };
-- Add formatting cmd
vim.api.nvim_create_user_command(
'Format',
function()
vim.lsp.buf.format({ async = true });
end,
{}
);
-- Remove LSP highlighting to use Treesitter
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
client.server_capabilities.semanticTokensProvider = nil
end,
});
'';
plugins = [
vimPlugins.nvim-lspconfig
vimPlugins.coq_nvim
vimPlugins.coq-artifacts
vimPlugins.coq-thirdparty
];
};
};
}

View file

@ -37,25 +37,7 @@ in
});
'';
coc.settings.java = {
maven.downloadSources = true;
eclipse.downloadSources = true;
format.settings.url = "eclipse-formatter.xml";
jdt.ls = {
java.home = "${javaSdk}";
statusIcons = {
"busy" = "Busy";
"ready" = "OK";
"warning" = "Warning";
"error" = "Error";
};
};
};
plugins = [
vimPlugins.coc-java
];
};
};

View file

@ -10,29 +10,8 @@ in
lib.mkIf neovimIde {
programs = {
neovim = {
coc.settings = {
Lua = {
misc.parameters = [
"--metapath"
"~/.cache/sumneko_lua/meta"
"--logpath"
"~/.cache/sumneko_lua/log"
];
workspace.library = [
"$\{3rd\}/luv/library"
];
};
sumneko-lua = {
serverDir = "${pkgs.lua-language-server}/share/lua-language-server";
enableNvimLuaDev = true;
};
};
plugins = [
vimPlugins.coc-sumneko-lua
vimPlugins.neodev-nvim
vimPlugins.coc-vimlsp
];
};
};

View file

@ -17,20 +17,8 @@ in
lib.mkIf neovimIde {
programs = {
neovim = {
coc.settings = {
markdownlint.config = {
no-trailing-spaces = true;
no-multiple-blanks = false;
no-duplicate-heading = false;
line-length = {
tables = false;
};
};
};
plugins = [
vimPlugins.markdown-preview-nvim
vimPlugins.coc-markdownlint
{
plugin = buildPlugin "easytables-nvim" vimplugin-easytables-src;
type = "lua";

View file

@ -50,12 +50,16 @@ in
nixdPkg
];
coc.settings.languageserver = {
nix = {
command = "nixd";
filetypes = ["nix"];
};
};
extraLuaConfig =
/*
lua
*/
''
local lsp = require('lspconfig')
lsp.nixd.setup({});
lsp.nixd.setup(require('coq').lsp_ensure_capabilities({}));
'';
};
};
}

View file

@ -17,7 +17,6 @@ in
];
plugins = [
vimPlugins.coc-pyright
];
};
};

View file

@ -2,13 +2,10 @@
config,
pkgs,
lib,
coc-stylelintplus,
...
}: let
inherit (config.vars) neovimIde;
inherit (pkgs) vimPlugins;
coc-stylelintplus-flake = coc-stylelintplus.packages.${pkgs.system}.default;
in
lib.mkIf neovimIde {
programs = {
@ -42,31 +39,7 @@ in
});
'';
coc.settings = {
# ESLint
eslint = {
format.enable = true;
autoFixOnSave = true;
};
# Stylelint
stylelintplus = {
enable = true;
cssInJs = true;
autoFixOnSave = true;
autoFixOnFormat = true;
};
css.validate = false;
less.validate = false;
scss.validate = false;
wxss.validate = false;
};
plugins = [
vimPlugins.coc-css
vimPlugins.coc-eslint
coc-stylelintplus-flake
vimPlugins.coc-tsserver
];
};
};

View file

@ -95,7 +95,7 @@ in {
globalstatus = true,
},
sections = {
lualine_x = { 'g:coc_status', 'bo:filetype' },
lualine_x = { 'bo:filetype' },
},
});
'';