WIP get rid of coc

This commit is contained in:
Daniel Flanagan 2022-03-09 11:50:01 -06:00
parent 3e4f318386
commit 460d693a54
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
10 changed files with 205 additions and 267 deletions

View file

@ -1,71 +0,0 @@
{
"coc.preferences.formatOnSaveFiletypes": ["elixir", "ex", "exs", "typescript", "css", "markdown", "sh", "bash"],
"languageserver": {
"nim": {
"command": "nimlsp",
"filetypes": ["nim"]
},
"zls": {
"command": "~/zls/zls",
"filetypes": ["zig"]
},
"godot": {
"host": "127.0.0.1",
"filetypes": ["gd", "gdscript3"],
"port": 6008
}
},
"elixir.pathToElixirLS": "~/.elixir-ls/release/language_server.sh",
"rust-analyzer.checkOnSave.command": "clippy",
"diagnostic-languageserver": {
"enable": true,
"mergeConfig": true,
"linters": {
"shellcheck": {
"command": "shellcheck",
"debounce": 100,
"args": [
"-x",
"--format",
"json1",
"-"
],
"sourceName": "shellcheck",
"parseJson": {
"errorsRoot": "comments",
"line": "line",
"column": "column",
"endLine": "endLine",
"endColumn": "endColumn",
"message": "${message} [${code}]",
"security": "level"
},
"securities": {
"error": "error",
"warning": "warning",
"info": "info",
"style": "hint"
}
}
},
"filetypes": {
"elixir": ["mix_credo", "mix_credo_compile"],
"eelixir": ["mix_credo", "mix_credo_compile"],
"sh": "shellcheck",
"bash": "shellcheck"
},
"formatters": {
"shfmt": {
"command": "shfmt",
"args": ["-i", "2", "-bn", "-ci", "-sr", "-kp"]
}
},
"formatFiletypes": {
"elixir": "mix_format",
"eelixir": "mix_format",
"sh": "shfmt",
"bash": "shfmt"
}
}
}

View file

@ -1,52 +1,7 @@
vim.g.vimdir = os.getenv('XDG_CONFIG_HOME') .. '/nvim'
-- TODO: learn about the wildmenu `q:`
-- TODO: what is `let &fcs = 'eob: '` for?
require('plugins').setup()
require'plugins'
require'options'
require'keymap'
require('fold').setup()
-- require('lsp').setup()
require('statusline').setup()
function Dbg(a, d)
if d == nil then d = 0 end
if type(a) == 'table' then
local s = '{\n'
local indent = string.rep(' ', d)
for k,v in pairs(a) do
s = s .. ' ' .. indent .. tostring(k) .. '=' .. Dbg(v, d+1) .. '\n'
end
return s .. '\n' .. indent .. '}'
elseif type(a) == 'string' then
return a
elseif type(a) == 'number' then
return tostring(a)
else
return 'type:'..type(a)..',tostring:'..tostring(a)
end
end
local plugin_setups = {
telescope = {
defaults = {
prompt_prefix = "",
mappings = {i = {['c-u'] = false, ['c-d'] = false}},
generic_sorter = require('telescope.sorters').get_fzy_sorter,
file_sorter = require('telescope.sorters').get_fzy_sorter,
}
},
}
for k,v in pairs(plugin_setups) do
if type(v) == 'function' then
v(require(k))
elseif type(v) == 'table' then
require(k).setup(v)
elseif type(v) == 'string' then
require(k)[v]()
elseif v == true then
require(k)
end
end
require'statusline'
require'lsp'

View file

@ -1,12 +0,0 @@
function NeatFoldText()
-- TODO: finish this!
-- local lines_count = vim.foldend - vim.foldstart + 1
-- local foldchar = vim.fn.matchstr(vim.fillchars, 'fold:\\zs.')
-- local foldtextstart = vim.fn.strpart('^' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
-- let foldtextend = printf("%s %".(winwidth(0)-20)."dL", foldtextstart, getline(v:foldstart), lines_count)
-- let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
-- return printf("%s%d", substitute(getline(v:foldstart), "^.", ">"), lines_count)
end
-- set foldtext=NeatFoldText()
return {setup = function() end}

View file

@ -7,33 +7,42 @@ local m = {
}
local keymap = {
n = {
['<leader>/'] = {':let @/ = ""<cr>:<BACKSPACE>', m.s},
['<leader>r'] = {':luafile ' .. vim.g.vimdir .. '/init.lua<cr>:echo \'Reloaded init.lua\'<cr>', m.s},
['<leader>gv'] = {':e ' .. vim.g.vimdir .. '/init.lua<cr>', m.s},
['<leader>w'] = {':bd<cr>', m.s},
['<leader>h'] = {':b#<cr>', m.s},
['<leader>k'] = {':bnext<cr>', m.s},
['<leader>j'] = {':bprevious<cr>', m.s},
['<leader>/'] = {':let @/ = ""<cr>:<BACKSPACE>', m.s},
['<c-q>'] = ':qa<cr>',
['<c-p>'] = '<cmd>Telescope git_files<cr>',
['<c-g>'] = '<cmd>Telescope live_grep<cr>',
['<c-b>'] = '<cmd>Telescope buffers<cr>',
['<leader>t'] = '<cmd>Telescope help_tags<cr>',
['<c-h>'] = ':TmuxNavigateLeft<cr>',
['<c-j>'] = ':TmuxNavigateDown<cr>',
['<c-k>'] = ':TmuxNavigateUp<cr>',
['<c-l>'] = ':TmuxNavigateRight<cr>',
['<expr> n'] = "'Nn'[v:searchforward]",
['<expr> N'] = "'nN'[v:searchforward]",
['<c-m>'] = ':lua SynGroup()<cr>',
['g]'] = '<Plug>(coc-diagnostic-next)',
['g['] = '<Plug>(coc-diagnostic-prev)',
},
-- terminal bindings
t = {},
[''] = {
['<space>'] = {'<nop>', m.sn},
-- remove trailing whitespace
['<f3>'] = 'mw:%s/\\s\\+$//<cr>:let @/ = ""<cr>\'w',
['<f4>'] = ':setlocal spell!<cr>',
['<leader>gs'] = ':setlocal spell!<cr>',
[',w'] = {'<Plug>CamelCaseMotion_w', m.s},
[',b'] = {'<Plug>CamelCaseMotion_b', m.s},
[',e'] = {'<Plug>CamelCaseMotion_e', m.s},

View file

@ -1,86 +1,64 @@
local opts = {noremap=true, silent=true}
local lsp = require'lspconfig'
-- local coq = require'coq'
vim.api.nvim_set_keymap('n', '[g', '<Plug>(coc-diagnostic-prev)', opts)
vim.api.nvim_set_keymap('n', ']g', '<Plug>(coc-diagnostic-next)', opts)
-- TODO: replace with nvim lsp bindings for jumping to next linting issue?
--vim.api.nvim_set_keymap('n', '[d', '<cmd>)<CR>', opts)
vim.api.nvim_set_keymap('n', 'gd', '<Plug>(coc-definition)', opts)
vim.api.nvim_set_keymap('n', 'gy', '<Plug>(coc-type-definition)', opts)
local opts = {
noremap = true,
silent = true,
}
local nvim_lsp = require('lspconfig')
local on_attach = function(_client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
local kmaps = {
['gD']='<Cmd>lua vim.lsp.buf.declaration()<CR>'
}
local on_attach = function(_, bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<cr>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g]', '<cmd>lua vim.diagnostic.goto_next()<cr>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g[', '<cmd>lua vim.diagnostic.goto_prev()<cr>', opts)
for k,v in pairs(kmaps) do
vim.api.nvim_buf_set_keymap(bufnr, 'n', k, v, opts)
end
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
local servers = {'clangd', 'rust_analyzer', 'pyright', 'tsserver'}
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup{on_attach=on_attach}
local common_config = {
capabilities = require'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = on_attach,
flags = {
debounce_text_changes = 150
},
}
local lsp_configs = {
elixirls = {
cmd = { vim.fn.expand'~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' },
},
sumneko_lua = {},
vimls = {},
rust_analyzer = {},
denols = {}
}
for server, config in pairs(lsp_configs) do
for k,v in pairs(common_config) do config[k] = v end
lsp[server].setup(config)
end
local sumneko_root_path = vim.fn.getenv('HOME')..'/.local/bin/sumneko_lua'
local sumneko_binary_path = '/bin/linux/lua-language-server'
nvim_lsp.sumneko_lua.setup{
cmd={sumneko_root_path .. sumneko_binary_path, '-E', sumneko_root_path..'/main.lua'};
on_attach=on_attach,
settings={
Lua={
runtime={
version='LuaJIT',
path=vim.split(package.path, ';'),
},
diagnostics={
globals={'vim'},
},
workspace={
library={
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
},
},
},
},
}
local lsp_installer = require'nvim-lsp-installer'
lsp_installer.on_server_ready(function(server)
local server_opts = {}
vim.cmd "command! Format execute 'lua vim.lsp.buf.formatting()'"
vim.o.completeopt = 'menuone,noinsert'
-- if server.name == "elixirls" then
-- server_opts.cmd = { vim.fn.expand'~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' }
-- end
--[[require'compe'.setup{
enabled=true,
autocomplete=true,
debug=false,
min_length=1,
preselect='enable',
throttle_time=80,
source_timeout=200,
incomplete_delay=400,
max_abbr_width=100,
max_kind_width=100,
max_menu_width=100,
documentation=true,
source={path=true, nvim_lsp=true},
}
]]--
return {
setup=function()
end
}
server:setup(server_opts)
end)

View file

@ -1,6 +0,0 @@
-- local completion = require('completion')
local lsp = require('lspconfig')
lsp.elixirls.setup{}
lsp.sumneko_lua.setup{}
lsp.vimls.setup{}

View file

@ -1,4 +1,8 @@
local globals = {
coq_settings = {
['display.icons.mode'] = 'none'
},
dashboard_default_executive = 'telescope',
mapleader = ' ',
maplocalleader = ' ',
completion_enable_auto_popup = 0,
@ -81,9 +85,21 @@ function SynGroup()
print(vim.fn.synIDattr(s, 'name') .. ' -> ' .. vim.fn.synIDattr(vim.fn.synIDtrans(s), 'name'))
end
print(vim.api.nvim_exec([[
vim.api.nvim_exec([[
au! TextYankPost * silent! lua vim.highlight.on_yank { higroup='Search', timeout=200 }
au! FileType gitcommit exec 'norm gg' | startinsert!
au! BufNewFile,BufRead *.slimleex set syntax=slime
command! W write
]], true))
]], true)
-- au! VimEnter * COQnow -s
function NeatFoldText()
-- TODO: finish this!
-- local lines_count = vim.foldend - vim.foldstart + 1
-- local foldchar = vim.fn.matchstr(vim.fillchars, 'fold:\\zs.')
-- local foldtextstart = vim.fn.strpart('^' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
-- let foldtextend = printf("%s %".(winwidth(0)-20)."dL", foldtextstart, getline(v:foldstart), lines_count)
-- let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
-- return printf("%s%d", substitute(getline(v:foldstart), "^.", ">"), lines_count)
end
-- set foldtext=NeatFoldText()

View file

@ -1,48 +1,121 @@
local setup = function()
local packer_install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if #vim.fn.glob(packer_install_path) == 0 then
vim.fn.system {'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_install_path}
vim.api.nvim_command'packadd packer.nvim'
end
vim.g.polyglot_disabled = {'cue'}
local packer = require'packer'
packer.startup(function()
local plugins = {
'wbthomason/packer.nvim',
'editorconfig/editorconfig-vim',
'tpope/vim-sleuth',
'vim-scripts/LargeFile',
'vim-scripts/restore_view.vim',
'christoomey/vim-tmux-navigator',
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
'tpope/vim-commentary',
'tpope/vim-repeat',
'machakann/vim-sandwich',
'michaeljsmith/vim-indent-object',
'wellle/targets.vim',
'bkad/CamelCaseMotion',
'ludovicchabant/vim-gutentags',
'tpope/vim-obsession',
'dhruvasagar/vim-prosession',
'nvim-lua/popup.nvim',
'nvim-lua/plenary.nvim',
{'nvim-telescope/telescope.nvim', requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}}},
-- 'joshdick/onedark.vim',
'lukas-reineke/indent-blankline.nvim',
-- {'lewis6991/gitsigns.nvim', requires = {'nvim-lua/plenary.nvim'}},
'neovim/nvim-lspconfig',
'hrsh7th/nvim-compe',
'jjo/vim-cue',
'sheerun/vim-polyglot',
{'neoclide/coc.nvim', branch = 'release'},
}
for _,plugin in ipairs(plugins) do
packer.use(plugin)
end
end)
local packer_install_path = vim.fn.stdpath'data' .. '/site/pack/packer/start/packer.nvim'
if #vim.fn.glob(packer_install_path) == 0 then
vim.fn.system{'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_install_path}
vim.api.nvim_command'packadd packer.nvim'
end
return {setup = setup}
local packer = require'packer'
packer.startup(function()
local plugins = {
'wbthomason/packer.nvim', -- neovim plugin manager
'vim-scripts/LargeFile', -- degrade gracefully with large files
'tpope/vim-repeat', -- enable repeat for plugin maps
'tpope/vim-sleuth', -- use whatever whitespace is in the file
'editorconfig/editorconfig-vim', -- handle .editorconfig files
'christoomey/vim-tmux-navigator', -- navigate vim splits and tmux panes fluidly
'machakann/vim-sandwich', -- edit surrounding characters
'michaeljsmith/vim-indent-object', -- adds indent-level text objects
'wellle/targets.vim', -- add many other text objects
'bkad/CamelCaseMotion', -- invaluable motions for properly operating on various casings
{
-- session management
'olimorris/persisted.nvim',
config = function()
-- TODO: only load session if no arguments passed?
require'persisted'.setup{
autoload = true,
}
end
},
{
-- toggle comments
'terrortylor/nvim-comment',
config = function()
require'nvim_comment'.setup()
end
},
{
-- fuzzy finder
'nvim-telescope/telescope.nvim',
requires = {
'nvim-lua/popup.nvim',
'nvim-lua/plenary.nvim',
}
},
-- TODO: add keymap <leader>ig for toggling these
'lukas-reineke/indent-blankline.nvim', -- indentation guide lines
'neovim/nvim-lspconfig',
'williamboman/nvim-lsp-installer',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
{
'hrsh7th/nvim-cmp',
config = function()
local cmp = require'cmp'
cmp.setup{
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' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping{
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
['<CR>'] = cmp.mapping.confirm{select = true}, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources{
{ name = 'nvim_lsp' },
{ name = 'buffer' },
},
}
cmp.setup.cmdline('/', {
sources = {
{name = 'buffer'},
}
})
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{name = 'path'}
}, {
{name = 'cmdline'}
})
})
end,
},
-- TODO: automate this installation process of :COQdeps<cr>:COQnow<cr>
-- {'ms-jpq/coq_nvim', branch = 'coq'},
-- {'ms-jpq/coq.thirdparty', branch = '3p'},
{
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate',
config = function()
require'nvim-treesitter.configs'.setup {
ensure_installed = "maintained",
sync_install = false,
ignore_install = {},
indent = {
enable = true,
},
highlight = {
enable = true,
disable = {},
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
-- additional_vim_regex_highlighting = false,
},
}
end
},
}
for _,plugin in pairs(plugins) do packer.use(plugin) end
end)

View file

@ -73,8 +73,4 @@ function StatusLine()
return status_line_buffers() .. '%*%=%c,%l/%L (%p%%)'
end
return {
setup=function()
vim.o.statusline = '%!v:lua.StatusLine()'
end
}
vim.o.statusline = '%!v:lua.StatusLine()'