working new nvim config, but not quite as good as coc-land yet

This commit is contained in:
Anish L 2022-02-26 04:50:52 +10:00
parent d60d88a930
commit 52e8ee033c

View file

@ -76,9 +76,6 @@ in
csv-vim csv-vim
rainbow_parentheses-vim rainbow_parentheses-vim
vim-surround vim-surround
bufferline-nvim
feline-nvim
nvim-web-devicons
vim-devicons vim-devicons
# kitaab stuff # kitaab stuff
vimwiki vimwiki
@ -86,6 +83,7 @@ in
vim-zettel vim-zettel
telescope-nvim telescope-nvim
plenary-nvim plenary-nvim
bufferline-nvim
# lsp stuff # lsp stuff
ale ale
nvim-lspconfig nvim-lspconfig
@ -278,314 +276,56 @@ in
" lua config " lua config
lua <<EOF lua <<EOF
-- Setup nvim-cmp. -- Setup nvim-cmp.
local cmp = require'cmp' local cmp = require'cmp'
cmp.setup({ cmp.setup({
mapping = { mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = 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-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-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({ ['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(), i = cmp.mapping.abort(),
c = cmp.mapping.close(), c = cmp.mapping.close(),
}), }),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
}, { }, {
{ name = 'buffer' }, { name = 'buffer' },
}) })
}) })
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', { cmp.setup.cmdline('/', {
sources = { sources = {
{ name = 'buffer' }, { name = 'buffer' },
{ name = "nvim_lsp"}, { name = "nvim_lsp"},
{ name = "path" }, { name = "path" },
{ name = 'conjure'}, { name = 'conjure'},
{ name = 'cmp_tabnine'}, { name = 'cmp_tabnine'},
} }
}) })
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', { cmp.setup.cmdline(':', {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'path' } { name = 'path' }
}, { }, {
{ name = 'cmdline' } { name = 'cmdline' }
}) })
}) })
-- Setup lspconfig. -- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
require'lspconfig'nvim_lsp.setup {} -- require'lspconfig'nvim_lsp.setup {}
require'lspconfig'clojure_lsp.setup {} -- require'lspconfig'clojure_lsp.setup {}
require'lspconfig'rnix.setup {} -- require'lspconfig'rnix.setup {}
require'lspconfig'pylsp.setup {} -- require'lspconfig'pylsp.setup {}
require'lspconfig'terraform_lsp.setup {} -- require'lspconfig'terraform_lsp.setup {}
-- Feline -- Bufferline
local colors = require 'theme.colors' require('bufferline').setup {}
local lsp = require 'feline.providers.lsp' EOF
local vi_mode_utils = require 'feline.providers.vi_mode'
local vi_mode_colors = {
NORMAL = colors.green,
INSERT = colors.red,
VISUAL = colors.magenta,
OP = colors.green,
BLOCK = colors.blue,
REPLACE = colors.violet,
['V-REPLACE'] = colors.violet,
ENTER = colors.cyan,
MORE = colors.cyan,
SELECT = colors.orange,
COMMAND = colors.green,
SHELL = colors.green,
TERM = colors.green,
NONE = colors.yellow
}
local icons = {
linux = ' ',
macos = ' ',
windows = ' ',
errs = ' ',
warns = ' ',
infos = ' ',
hints = ' ',
lsp = ' ',
git = ''
}
local function file_osinfo()
local os = vim.bo.fileformat:upper()
local icon
if os == 'UNIX' then
icon = icons.linux
elseif os == 'MAC' then
icon = icons.macos
else
icon = icons.windows
end
return icon .. os
end
local function lsp_diagnostics_info()
return {
errs = lsp.get_diagnostics_count('Error'),
warns = lsp.get_diagnostics_count('Warning'),
infos = lsp.get_diagnostics_count('Information'),
hints = lsp.get_diagnostics_count('Hint')
}
end
local function diag_enable(f, s)
return function()
local diag = f()[s]
return diag and diag ~= 0
end
end
local function diag_of(f, s)
local icon = icons[s]
return function()
local diag = f()[s]
return icon .. diag
end
end
local function vimode_hl()
return {
name = vi_mode_utils.get_mode_highlight_name(),
fg = vi_mode_utils.get_mode_color()
}
end
-- LuaFormatter off
local comps = {
vi_mode = {
left = {
provider = '',
hl = vimode_hl,
right_sep = ' '
},
right = {
provider = '',
hl = vimode_hl,
left_sep = ' '
}
},
file = {
info = {
provider = 'file_info',
hl = {
fg = colors.blue,
style = 'bold'
}
},
encoding = {
provider = 'file_encoding',
left_sep = ' ',
hl = {
fg = colors.violet,
style = 'bold'
}
},
type = {
provider = 'file_type'
},
os = {
provider = file_osinfo,
left_sep = ' ',
hl = {
fg = colors.violet,
style = 'bold'
}
}
},
line_percentage = {
provider = 'line_percentage',
left_sep = ' ',
hl = {
style = 'bold'
}
},
scroll_bar = {
provider = 'scroll_bar',
left_sep = ' ',
hl = {
fg = colors.blue,
style = 'bold'
}
},
diagnos = {
err = {
provider = diag_of(lsp_diagnostics_info, 'errs'),
left_sep = ' ',
enabled = diag_enable(lsp_diagnostics_info, 'errs'),
hl = {
fg = colors.red
}
},
warn = {
provider = diag_of(lsp_diagnostics_info, 'warns'),
left_sep = ' ',
enabled = diag_enable(lsp_diagnostics_info, 'warns'),
hl = {
fg = colors.yellow
}
},
info = {
provider = diag_of(lsp_diagnostics_info, 'infos'),
left_sep = ' ',
enabled = diag_enable(lsp_diagnostics_info, 'infos'),
hl = {
fg = colors.blue
}
},
hint = {
provider = diag_of(lsp_diagnostics_info, 'hints'),
left_sep = ' ',
enabled = diag_enable(lsp_diagnostics_info, 'hints'),
hl = {
fg = colors.cyan
}
},
},
lsp = {
name = {
provider = 'lsp_client_names',
left_sep = ' ',
icon = icons.lsp,
hl = {
fg = colors.yellow
}
}
},
git = {
branch = {
provider = 'git_branch',
icon = icons.git,
left_sep = ' ',
hl = {
fg = colors.violet,
style = 'bold'
},
},
add = {
provider = 'git_diff_added',
hl = {
fg = colors.green
}
},
change = {
provider = 'git_diff_changed',
hl = {
fg = colors.orange
}
},
remove = {
provider = 'git_diff_removed',
hl = {
fg = colors.red
}
}
}
}
local properties = {
force_inactive = {
filetypes = {
'NvimTree',
'dbui',
'packer',
'startify',
'fugitive',
'fugitiveblame'
},
buftypes = {'terminal'},
bufnames = {}
}
}
local components = {
left = {
active = {
comps.vi_mode.left,
comps.file.info,
comps.lsp.name,
comps.diagnos.err,
comps.diagnos.warn,
comps.diagnos.hint,
comps.diagnos.info
},
inactive = {
comps.vi_mode.left,
comps.file.info
}
},
mid = {
active = {},
inactive = {}
},
right = {
active = {
comps.git.add,
comps.git.change,
comps.git.remove,
comps.file.os,
comps.git.branch,
comps.line_percentage,
comps.scroll_bar,
comps.vi_mode.right
},
inactive = {}
}
}
-- LuaFormatter on
require'feline'.setup {
default_bg = colors.bg,
default_fg = colors.fg,
components = components,
properties = properties,
vi_mode_colors = vi_mode_colors
}
-- Buffeline
require('bufferline').setup {}
EOF
''; '';
}; };
} }