YOINK COC!!!!

This commit is contained in:
LordMZTE 2022-01-22 16:38:51 +01:00
parent 52e08a8ea7
commit c9f86f008d
15 changed files with 155 additions and 244 deletions

View file

@ -1,37 +0,0 @@
{
"diagnostic.virtualText": true,
"diagnostic.virtualTextCurrentLineOnly": false,
"languageserver": {
"haskell": {
"command": "haskell-language-server-wrapper",
"args": ["--lsp"],
"rootPatterns": [
"*.cabal",
"stack.yaml",
"cabal.project",
"package.yaml",
"hie.yaml"
],
"filetypes": ["haskell", "lhaskell"]
},
"ocaml-lsp": {
"command": "opam",
"args": ["config", "exec", "--", "ocamllsp"],
"filetypes": ["ocaml", "reason"]
},
"mun": {
"command": "mun",
"rootPatterns": ["mun.toml"],
"trace.server": "verbose",
"args": ["language-server"],
"filetypes": ["mun"]
},
"zls": {
"command": "zls",
"filetypes": ["zig"]
}
},
"java.format.enabled": true,
"java.format.onType.enabled": true,
"sumneko-lua.enableNvimLuaDev": true
}

9
.config/nvim/install_lsps.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
set -e
sudo npm i -g bash-language-server
paru -S --needed --noconfirm \
vscode-langservers-extracted \
rust-analyzer \
lua-language-server \
taplo-lsp

View file

@ -1,34 +1,5 @@
local map = vim.api.nvim_set_keymap
function escape_keycode(keycode)
return vim.api.nvim_replace_termcodes(keycode, true, true, true)
end
local function check_back_space()
local col = vim.fn.col "." - 1
return col <= 0 or vim.fn.getline("."):sub(col, col):match "%s"
end
function tab_completion()
if vim.fn.pumvisible() > 0 then
return escape_keycode "<C-n>"
end
if check_back_space() then
return escape_keycode "<TAB>"
end
return vim.fn["coc#refresh"]()
end
function shift_tab_completion()
if vim.fn.pumvisible() > 0 then
return escape_keycode "<C-p>"
else
return escape_keycode "<C-h>"
end
end
-- Getting stuck in ~~vim~~ terminal
map("t", "<Esc>", "<C-\\><C-n>", {})
@ -48,37 +19,3 @@ map("n", "+d", '"+d', { noremap = true })
map("n", "*y", '"*y', { noremap = true })
map("n", "*p", '"*p', { noremap = true })
map("n", "*d", '"*d', { noremap = true })
map("i", "<TAB>", "v:lua.tab_completion()", { expr = true })
map("i", "<S-TAB>", "v:lua.shift_tab_completion()", { expr = true })
-- symbol renaming
map("n", "-n", "<Plug>(coc-rename)", { silent = true })
-- apply AutoFix to problem on current line
map("n", "-f", "<Plug>(coc-fix-current)", { silent = true })
-- open action dialog
map("n", "-a", ":CocAction<CR>", { silent = true })
-- GoTo code navigation.
map("n", "gd", "<Plug>(coc-definition)", { silent = true })
map("n", "gy", "<Plug>(coc-type-definition)", { silent = true })
map("n", "gi", "<Plug>(coc-implementation)", { silent = true })
map("n", "gr", "<Plug>(coc-references)", { silent = true })
-- Use K to show documentation in preview window.
map("n", "K", ":call CocActionAsync('doHover')<CR>", { silent = true })
-- use space o to show symbols
map("n", "<space>o", ":CocList -I symbols<CR>", { silent = true })
-- format code
map("n", "-r", ":call CocActionAsync('format')<CR>", { silent = true })
-- Use <c-space> to trigger completion.
map("i", "<c-space>", "coc#refresh()", { silent = true, expr = true })
-- Use -d to jump to next diagnostic
map("n", "-d", "<Plug>(coc-diagnostic-next)", { silent = true })
-- Use -o to show outline
map("n", "-o", ":CocList outline<CR>", { silent = true })

View file

@ -0,0 +1,10 @@
local autopairs = require "nvim-autopairs"
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
local cmp = require "cmp"
autopairs.setup {
check_ts = true,
fast_wrap = {},
}
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } })

View file

@ -1,49 +0,0 @@
coc = {}
vim.g.coc_global_extensions = {
"coc-clangd",
"coc-fish",
"coc-go",
"coc-haxe",
"coc-java",
"coc-json",
"coc-kotlin",
"coc-prettier",
"coc-rust-analyzer",
"coc-snippets",
"coc-sumneko-lua",
"coc-toml",
}
local function check_back_space()
local col = vim.fn.col "." - 1
return col <= 0 or vim.fn.getline("."):sub(col, col):match "%s"
end
function coc.tab_completion()
if vim.fn.pumvisible() > 0 then
return escape_keycode "<C-n>"
end
if check_back_space() then
return escape_keycode "<TAB>"
end
return vim.fn["coc#refresh"]()
end
function coc.shift_tab_completion()
if vim.fn.pumvisible() > 0 then
return escape_keycode "<C-p>"
else
return escape_keycode "<C-h>"
end
end
function coc.cr_completion()
if vim.fn.pumvisible() > 0 then
return vim.fn["coc#_select_confirm"]()
else
return escape_keycode [[\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>]]
end
end

View file

@ -2,7 +2,6 @@
local gl = require "galaxyline"
local gls = gl.section
local extension = require "galaxyline.provider_extensions"
gl.short_line_list = {
"LuaTree",
@ -40,19 +39,13 @@ local mode_color = {
v = colors.magenta,
[""] = colors.blue,
V = colors.blue,
c = colors.red,
no = colors.magenta,
s = colors.orange,
S = colors.orange,
[""] = colors.orange,
ic = colors.yellow,
R = colors.purple,
Rv = colors.purple,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
["r?"] = colors.cyan,
["!"] = colors.green,
t = colors.green,
c = colors.purple,
@ -63,47 +56,6 @@ local mode_color = {
Rv = colors.magenta,
}
local function lsp_status(status)
shorter_stat = ""
for match in string.gmatch(status, "[^%s]+") do
err_warn = string.find(match, "^[WE]%d+", 0)
if not err_warn then
shorter_stat = shorter_stat .. " " .. match
end
end
return shorter_stat
end
local function get_coc_lsp()
local status = vim.fn["coc#status"]()
if not status or status == "" then
return ""
end
return lsp_status(status)
end
function get_diagnostic_info()
if vim.fn.exists "*coc#rpc#start_server" == 1 then
return get_coc_lsp()
end
return ""
end
local function get_current_func()
local has_func, func_name = pcall(vim.fn.nvim_buf_get_var, 0, "coc_current_function")
if not has_func then
return
end
return func_name
end
function get_function_info()
if vim.fn.exists "*coc#rpc#start_server" == 1 then
return get_current_func()
end
return ""
end
local function trailing_whitespace()
local trail = vim.fn.search("\\s$", "nw")
if trail ~= 0 then
@ -113,11 +65,9 @@ local function trailing_whitespace()
end
end
CocStatus = get_diagnostic_info
CocFunc = get_current_func
TrailingWhiteSpace = trailing_whitespace
function has_file_type()
local function has_file_type()
local f_type = vim.bo.filetype
if not f_type or f_type == "" then
return false
@ -147,7 +97,6 @@ gls.left[2] = {
local alias = {
n = "NORMAL",
i = "INSERT",
c = "COMMAND",
V = "VISUAL",
[""] = "VISUAL",
v = "VISUAL",
@ -285,22 +234,6 @@ gls.left[15] = {
},
}
gls.left[16] = {
CocStatus = {
provider = CocStatus,
highlight = { colors.green, colors.bg },
icon = " 🗱",
},
}
gls.left[17] = {
CocFunc = {
provider = CocFunc,
icon = " λ ",
highlight = { colors.yellow, colors.bg },
},
}
gls.right[1] = {
BufferType = {
provider = "FileTypeName",

View file

@ -0,0 +1,50 @@
local map = vim.api.nvim_set_keymap
local lspc = require "lspconfig"
local caps = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
local lua_runtime_path = vim.split(package.path, ";")
table.insert(lua_runtime_path, "lua/?.lua")
table.insert(lua_runtime_path, "lua/?/init.lua")
lspc.bashls.setup { capabilities = caps } -- npm i -g bash-language-server
lspc.clangd.setup { capabilities = caps }
lspc.html.setup { capabilities = caps } -- paru -S vscode-langservers-extracted
lspc.jsonls.setup { capabilities = caps } -- paru -S vscode-langservers-extracted
lspc.rust_analyzer.setup { capabilities = caps } -- paru -S rust-analyzer
lspc.sumneko_lua.setup { -- paru -S lua-language-server
capabilities = caps,
settings = {
Lua = {
runtime = {
version = "LuaJIT",
path = lua_runtime_path,
},
diagnostics = {
globals = { "vim" },
},
workspace = {
vim.api.nvim_get_runtime_file("", true),
},
telemetry = {
enable = false,
},
},
},
}
lspc.zls.setup { capabilities = caps } -- paru -S zls-bin
lspc.taplo.setup { capabilities = caps } -- paru -S taplo-lsp
-- Mappings.
local opts = { noremap = true, silent = true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
map("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
map("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
map("n", "-n", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
map("n", "-a", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
map("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
map("n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
map("n", "-d", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
map("n", "-r", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)

View file

@ -0,0 +1,37 @@
local cmp = require "cmp"
cmp.setup {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = {
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item()),
["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item()),
["<CR>"] = cmp.mapping.confirm { select = true },
},
sources = cmp.config.sources {
{ name = "nvim_lsp" },
{ name = "luasnips" },
},
}
cmp.setup.cmdline("/", {
sources = {
{ name = "buffer" },
},
})
cmp.setup.cmdline(":", {
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
})

View file

@ -0,0 +1,2 @@
require("luasnip.loaders.from_vscode").load()
require("luasnip.loaders.from_snipmate").load()

View file

@ -1,13 +0,0 @@
local pears = require "pears"
pears.setup(function(conf)
conf.preset "tag_matching"
conf.on_enter(function(pears_handle)
if vim.fn.pumvisible() == 1 then
return vim.fn["coc#_select_confirm"]()
else
pears_handle()
end
end)
end)

View file

@ -1,7 +1,6 @@
require("nvim-tree").setup {
-- don't open tree when using firenvim
open_on_setup = not vim.g.started_by_firenvim,
auto_close = true,
diagnostics = {
enable = true,
},

View file

@ -0,0 +1,4 @@
local rust_tools = require "rust-tools"
require("rust-tools.inlay_hints").set_inlay_hints()
rust_tools.setup {}

View file

@ -18,6 +18,10 @@ configs.setup {
enable = true,
},
autotag = {
enable = true,
},
rainbow = {
enable = true,
extended_mode = true,

View file

@ -4,14 +4,39 @@ local function pconf(plugin)
return 'require("pluginconf.' .. plugin .. '")'
end
local function cmp_plugins(use)
use {
"neovim/nvim-lspconfig",
config = pconf "lspconf",
}
use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-buffer"
use "hrsh7th/cmp-path"
use "hrsh7th/cmp-cmdline"
use {
"hrsh7th/nvim-cmp",
config = pconf "nvim_cmp",
}
use "saadparwaiz1/cmp_luasnip"
use {
"L3MON4D3/LuaSnip",
config = pconf "nvim_luasnip",
requires = {
"rafamadriz/friendly-snippets",
"honza/vim-snippets",
},
}
use {
"simrat39/rust-tools.nvim",
config = pconf "rust_tools",
}
end
return require("packer").startup(function(use)
use "wbthomason/packer.nvim"
use {
"neoclide/coc.nvim",
branch = "release",
config = pconf "coc",
}
use "ryanoasis/vim-devicons"
use {
"dracula/vim",
@ -27,11 +52,10 @@ return require("packer").startup(function(use)
use "airblade/vim-gitgutter"
use "dag/vim-fish"
use "uiiaoo/java-syntax.vim"
use "honza/vim-snippets"
use "sheerun/vim-polyglot"
use {
"glepnir/galaxyline.nvim",
branch = "main",
"dsych/galaxyline.nvim",
branch = "bugfix/diagnostics", -- fork with a fix to not use deprecated API
config = pconf "galaxyline",
}
use {
@ -69,11 +93,15 @@ return require("packer").startup(function(use)
}
use "gluon-lang/vim-gluon"
use {
"steelsojka/pears.nvim",
config = pconf "nvim_pears",
"windwp/nvim-autopairs",
config = pconf "autopairs",
}
use "windwp/nvim-ts-autotag"
use {
"p00f/nvim-ts-rainbow",
requires = "nvim-treesitter/nvim-treesitter",
}
cmp_plugins(use)
end)

View file

@ -21,9 +21,6 @@ g.neovide_iso_layout = true
cmd "colorscheme dracula"
-- Highlight the symbol and its references when holding the cursor.
cmd "autocmd CursorHold * silent call CocActionAsync('highlight')"
cmd "autocmd StdinReadPre * let s:std_in=1"
cmd "filetype plugin on"