switch to nvim-cmp
This commit is contained in:
+132
-46
@@ -21,6 +21,7 @@ vim.wo.cursorline = true
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.wrap = true
|
||||
vim.opt.showmatch = true
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
|
||||
vim.g.python3_host_prog = '/home/frosty/.dotfiles/nvim/env/bin/python'
|
||||
|
||||
@@ -48,7 +49,7 @@ function imap(shortcut, command)
|
||||
map('i', shortcut, command)
|
||||
end
|
||||
|
||||
vim.opt.guifont = "Iosevka Nerd Font:h12"
|
||||
vim.opt.guifont = "Hack Nerd Font:h12"
|
||||
if vim.g.neovide then
|
||||
vim.g.neovide_refresh_rate = 140
|
||||
-- change to whatever font you prefer
|
||||
@@ -72,7 +73,7 @@ end
|
||||
-- <leader> is leader key; default is \
|
||||
nmap("<leader>v", "<cmd>NvimTreeToggle<cr>")
|
||||
nmap("<leader>ec", "<cmd>e ~/.config/nvim/init.lua<cr>")
|
||||
nmap("<leader>sc", "<cmd>source ~/.config/nvim/init.lua<cr><cmd>PackerSync<cr>")
|
||||
nmap("<leader>sc", "<cmd>source ~/.config/nvim/init.lua<cr><cmd>PackerClean<cr><cmd>PackerCompile<cr>")
|
||||
|
||||
-- buffer commands
|
||||
nmap("<leader>b", "<cmd>BufferLineCyclePrev<cr>")
|
||||
@@ -130,9 +131,17 @@ local on_attach = function(client, bufnr)
|
||||
end
|
||||
|
||||
local lsp = require "lspconfig"
|
||||
local lsp_defaults = lsp.util.default_config
|
||||
|
||||
|
||||
|
||||
lsp.hls.setup { on_attach = on_attach } -- haskell language server
|
||||
lsp.ccls.setup { on_attach = on_attach }
|
||||
lsp.pyright.setup { on_attach = on_attach }
|
||||
lsp.svelte.setup { on_attach = on_attach }
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.offsetEncoding = { "utf-16" }
|
||||
lsp.clangd.setup { on_attach = on_attach, capabilities = capabilities }
|
||||
-- https://github.com/denoland/deno - maybe switch?
|
||||
lsp.tsserver.setup { on_attach = on_attach }
|
||||
lsp.marksman.setup { on_attach = on_attach }
|
||||
@@ -146,8 +155,9 @@ lsp.lua_ls.setup { on_attach = on_attach,
|
||||
}
|
||||
}
|
||||
}
|
||||
lsp.tailwindcss.setup { on_attach = on_attach }
|
||||
|
||||
vim.cmd("colorscheme carbonfox")
|
||||
vim.cmd("colorscheme mellifluous")
|
||||
-- kill eslint_d on exit
|
||||
local on_leave_group = vim.api.nvim_create_augroup("OnLeaveGroup", {})
|
||||
vim.api.nvim_create_autocmd("VimLeave", {
|
||||
@@ -184,29 +194,7 @@ return M]]
|
||||
return require('packer').startup(function(use)
|
||||
use 'wbthomason/packer.nvim'
|
||||
use 'nvim-lua/plenary.nvim'
|
||||
--[[use { "lukas-reineke/lsp-format.nvim",
|
||||
config = function()
|
||||
require("lsp-format").setup {
|
||||
python = {
|
||||
exclude = { "pyright" },
|
||||
},
|
||||
javascript = {
|
||||
exclude = { "tsserver" }
|
||||
}
|
||||
}
|
||||
end,
|
||||
requires = { 'neovim/nvim-lspconfig' }
|
||||
}]]
|
||||
--
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use {
|
||||
'ms-jpq/coq_nvim',
|
||||
branch = 'coq',
|
||||
event = "VimEnter",
|
||||
config = 'vim.cmd[[COQnow]]'
|
||||
}
|
||||
use { 'ms-jpq/coq.artifacts', branch = 'artifacts' }
|
||||
use { 'ms-jpq/coq.thirdparty', branch = '3p' }
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = ':TSUpdate',
|
||||
@@ -218,12 +206,95 @@ return require('packer').startup(function(use)
|
||||
}
|
||||
end
|
||||
}
|
||||
use { 'kyazdani42/nvim-tree.lua',
|
||||
requires = {
|
||||
'kyazdani42/nvim-web-devicons'
|
||||
},
|
||||
use {
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
}
|
||||
use {
|
||||
'ramojus/mellifluous.nvim',
|
||||
config = function()
|
||||
require('mellifluous').setup {}
|
||||
end
|
||||
}
|
||||
use {
|
||||
'nvim-tree/nvim-tree.lua',
|
||||
after = "nvim-web-devicons",
|
||||
requires = "nvim-tree/nvim-web-devicons",
|
||||
config = function() require('nvim-tree').setup {} end
|
||||
}
|
||||
use {
|
||||
"hrsh7th/nvim-cmp",
|
||||
requires = {
|
||||
"hrsh7th/cmp-buffer", "hrsh7th/cmp-nvim-lsp",
|
||||
"L3MON4D3/LuaSnip", "rafamadriz/friendly-snippets",
|
||||
'hrsh7th/cmp-nvim-lua', 'octaltree/cmp-look', 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc',
|
||||
'f3fora/cmp-spell', 'hrsh7th/cmp-emoji'
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end
|
||||
},
|
||||
sources = {
|
||||
{ name = 'path' },
|
||||
{ name = 'nvim_lsp', keyword_length = 1 },
|
||||
{ name = 'buffer', keyword_length = 3 },
|
||||
{ name = 'luasnip', keyword_length = 2 },
|
||||
},
|
||||
window = {
|
||||
documentation = cmp.config.window.bordered()
|
||||
},
|
||||
formatting = {
|
||||
fields = { 'menu', 'abbr', 'kind' },
|
||||
format = function(entry, item)
|
||||
local menu_icon = {
|
||||
nvim_lsp = 'λ',
|
||||
luasnip = '⋗',
|
||||
buffer = 'Ω',
|
||||
path = '🖫',
|
||||
}
|
||||
|
||||
item.menu = menu_icon[entry.source.name]
|
||||
return item
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<Up>'] = cmp.mapping.select_prev_item(select_opts),
|
||||
['<Down>'] = cmp.mapping.select_next_item(select_opts),
|
||||
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(select_opts),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(select_opts),
|
||||
|
||||
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
||||
|
||||
['<C-f>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
|
||||
['<C-b>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
}
|
||||
})
|
||||
end
|
||||
}
|
||||
--use { 'jose-elias-alvarez/typescript.nvim',
|
||||
-- config = function() require("typescript")
|
||||
use {
|
||||
@@ -241,27 +312,44 @@ return require('packer').startup(function(use)
|
||||
return find_pyproject(params.root) or params.root
|
||||
end
|
||||
})
|
||||
|
||||
local black = null_ls.builtins.formatting.black.with({
|
||||
extra_args = { "--config", "pyproject.toml" },
|
||||
cwd = function(params)
|
||||
return find_pyproject(params.root) or params.root
|
||||
end
|
||||
})
|
||||
|
||||
local flake8 = null_ls.builtins.diagnostics.flake8.with({
|
||||
cwd = function(params)
|
||||
return find_flake8(params.root) or params.root
|
||||
end
|
||||
})
|
||||
local eslint_d_format = null_ls.builtins.formatting.eslint_d
|
||||
local eslint_d_diag = null_ls.builtins.diagnostics.eslint_d
|
||||
local eslint_d_code = null_ls.builtins.code_actions.eslint_d
|
||||
local gitsigns = null_ls.builtins.code_actions.gitsigns
|
||||
|
||||
local eslint_format = null_ls.builtins.formatting.eslint_d.with({
|
||||
extra_filetypes = { "svelte" },
|
||||
})
|
||||
|
||||
local eslint_diag = null_ls.builtins.diagnostics.eslint_d.with({
|
||||
extra_filetypes = { "svelte" },
|
||||
})
|
||||
|
||||
local eslint_code_actions = null_ls.builtins.code_actions.eslint_d.with({
|
||||
extra_filetypes = { "svelte" },
|
||||
})
|
||||
|
||||
|
||||
null_ls.setup {
|
||||
on_attach = on_attach,
|
||||
sources = {
|
||||
eslint_format,
|
||||
eslint_diag,
|
||||
eslint_code_actions,
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
isort,
|
||||
black,
|
||||
flake8
|
||||
}
|
||||
}
|
||||
null_ls.register({ isort, black, flake8, gitsigns })
|
||||
null_ls.register({ name = "eslint_d", sources = { eslint_d_code, eslint_d_diag, eslint_d_format } })
|
||||
end,
|
||||
requires = { "nvim-lua/plenary.nvim" },
|
||||
}
|
||||
@@ -275,8 +363,8 @@ return require('packer').startup(function(use)
|
||||
}
|
||||
use {
|
||||
'akinsho/bufferline.nvim',
|
||||
tag = "v2.*",
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
tag = "*",
|
||||
requires = 'nvim-tree/nvim-web-devicons',
|
||||
config = function()
|
||||
require("bufferline").setup {
|
||||
options = {
|
||||
@@ -285,11 +373,6 @@ return require('packer').startup(function(use)
|
||||
}
|
||||
end
|
||||
}
|
||||
use { "EdenEast/nightfox.nvim",
|
||||
config = function()
|
||||
require("nightfox").setup {}
|
||||
end
|
||||
}
|
||||
use {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VimEnter",
|
||||
@@ -299,11 +382,12 @@ return require('packer').startup(function(use)
|
||||
sections = { lualine_x = { 'filetype' } }
|
||||
}
|
||||
end,
|
||||
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
|
||||
requires = { 'nvim-tree/nvim-web-devicons', opt = true }
|
||||
}
|
||||
use {
|
||||
"startup-nvim/startup.nvim",
|
||||
requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
|
||||
after = "nvim-web-devicons",
|
||||
requires = { "nvim-tree/nvim-web-devicons", "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
require "startup".setup()
|
||||
end
|
||||
@@ -332,6 +416,7 @@ return require('packer').startup(function(use)
|
||||
require('colorizer').setup {
|
||||
'css',
|
||||
'javascript',
|
||||
'toml'
|
||||
}
|
||||
end,
|
||||
}
|
||||
@@ -354,6 +439,7 @@ return require('packer').startup(function(use)
|
||||
{ 'nvim-lua/plenary.nvim' },
|
||||
}
|
||||
}
|
||||
use { 'stevearc/dressing.nvim' }
|
||||
if packer_bootstrap then
|
||||
require('packer').sync()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user