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.hlsearch = false
|
||||||
vim.opt.wrap = true
|
vim.opt.wrap = true
|
||||||
vim.opt.showmatch = true
|
vim.opt.showmatch = true
|
||||||
|
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||||
|
|
||||||
vim.g.python3_host_prog = '/home/frosty/.dotfiles/nvim/env/bin/python'
|
vim.g.python3_host_prog = '/home/frosty/.dotfiles/nvim/env/bin/python'
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ function imap(shortcut, command)
|
|||||||
map('i', shortcut, command)
|
map('i', shortcut, command)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.opt.guifont = "Iosevka Nerd Font:h12"
|
vim.opt.guifont = "Hack Nerd Font:h12"
|
||||||
if vim.g.neovide then
|
if vim.g.neovide then
|
||||||
vim.g.neovide_refresh_rate = 140
|
vim.g.neovide_refresh_rate = 140
|
||||||
-- change to whatever font you prefer
|
-- change to whatever font you prefer
|
||||||
@@ -72,7 +73,7 @@ end
|
|||||||
-- <leader> is leader key; default is \
|
-- <leader> is leader key; default is \
|
||||||
nmap("<leader>v", "<cmd>NvimTreeToggle<cr>")
|
nmap("<leader>v", "<cmd>NvimTreeToggle<cr>")
|
||||||
nmap("<leader>ec", "<cmd>e ~/.config/nvim/init.lua<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
|
-- buffer commands
|
||||||
nmap("<leader>b", "<cmd>BufferLineCyclePrev<cr>")
|
nmap("<leader>b", "<cmd>BufferLineCyclePrev<cr>")
|
||||||
@@ -130,9 +131,17 @@ local on_attach = function(client, bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local lsp = require "lspconfig"
|
local lsp = require "lspconfig"
|
||||||
|
local lsp_defaults = lsp.util.default_config
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lsp.hls.setup { on_attach = on_attach } -- haskell language server
|
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.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?
|
-- https://github.com/denoland/deno - maybe switch?
|
||||||
lsp.tsserver.setup { on_attach = on_attach }
|
lsp.tsserver.setup { on_attach = on_attach }
|
||||||
lsp.marksman.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
|
-- kill eslint_d on exit
|
||||||
local on_leave_group = vim.api.nvim_create_augroup("OnLeaveGroup", {})
|
local on_leave_group = vim.api.nvim_create_augroup("OnLeaveGroup", {})
|
||||||
vim.api.nvim_create_autocmd("VimLeave", {
|
vim.api.nvim_create_autocmd("VimLeave", {
|
||||||
@@ -184,29 +194,7 @@ return M]]
|
|||||||
return require('packer').startup(function(use)
|
return require('packer').startup(function(use)
|
||||||
use 'wbthomason/packer.nvim'
|
use 'wbthomason/packer.nvim'
|
||||||
use 'nvim-lua/plenary.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 '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 {
|
use {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
run = ':TSUpdate',
|
run = ':TSUpdate',
|
||||||
@@ -218,12 +206,95 @@ return require('packer').startup(function(use)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
use { 'kyazdani42/nvim-tree.lua',
|
use {
|
||||||
requires = {
|
'nvim-tree/nvim-web-devicons',
|
||||||
'kyazdani42/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
|
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',
|
--use { 'jose-elias-alvarez/typescript.nvim',
|
||||||
-- config = function() require("typescript")
|
-- config = function() require("typescript")
|
||||||
use {
|
use {
|
||||||
@@ -241,27 +312,44 @@ return require('packer').startup(function(use)
|
|||||||
return find_pyproject(params.root) or params.root
|
return find_pyproject(params.root) or params.root
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
local black = null_ls.builtins.formatting.black.with({
|
local black = null_ls.builtins.formatting.black.with({
|
||||||
extra_args = { "--config", "pyproject.toml" },
|
|
||||||
cwd = function(params)
|
cwd = function(params)
|
||||||
return find_pyproject(params.root) or params.root
|
return find_pyproject(params.root) or params.root
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
local flake8 = null_ls.builtins.diagnostics.flake8.with({
|
local flake8 = null_ls.builtins.diagnostics.flake8.with({
|
||||||
cwd = function(params)
|
cwd = function(params)
|
||||||
return find_flake8(params.root) or params.root
|
return find_flake8(params.root) or params.root
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
local eslint_d_format = null_ls.builtins.formatting.eslint_d
|
|
||||||
local eslint_d_diag = null_ls.builtins.diagnostics.eslint_d
|
local eslint_format = null_ls.builtins.formatting.eslint_d.with({
|
||||||
local eslint_d_code = null_ls.builtins.code_actions.eslint_d
|
extra_filetypes = { "svelte" },
|
||||||
local gitsigns = null_ls.builtins.code_actions.gitsigns
|
})
|
||||||
|
|
||||||
|
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 {
|
null_ls.setup {
|
||||||
on_attach = on_attach,
|
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,
|
end,
|
||||||
requires = { "nvim-lua/plenary.nvim" },
|
requires = { "nvim-lua/plenary.nvim" },
|
||||||
}
|
}
|
||||||
@@ -275,8 +363,8 @@ return require('packer').startup(function(use)
|
|||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
'akinsho/bufferline.nvim',
|
'akinsho/bufferline.nvim',
|
||||||
tag = "v2.*",
|
tag = "*",
|
||||||
requires = 'kyazdani42/nvim-web-devicons',
|
requires = 'nvim-tree/nvim-web-devicons',
|
||||||
config = function()
|
config = function()
|
||||||
require("bufferline").setup {
|
require("bufferline").setup {
|
||||||
options = {
|
options = {
|
||||||
@@ -285,11 +373,6 @@ return require('packer').startup(function(use)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
use { "EdenEast/nightfox.nvim",
|
|
||||||
config = function()
|
|
||||||
require("nightfox").setup {}
|
|
||||||
end
|
|
||||||
}
|
|
||||||
use {
|
use {
|
||||||
"nvim-lualine/lualine.nvim",
|
"nvim-lualine/lualine.nvim",
|
||||||
event = "VimEnter",
|
event = "VimEnter",
|
||||||
@@ -299,11 +382,12 @@ return require('packer').startup(function(use)
|
|||||||
sections = { lualine_x = { 'filetype' } }
|
sections = { lualine_x = { 'filetype' } }
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
|
requires = { 'nvim-tree/nvim-web-devicons', opt = true }
|
||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
"startup-nvim/startup.nvim",
|
"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()
|
config = function()
|
||||||
require "startup".setup()
|
require "startup".setup()
|
||||||
end
|
end
|
||||||
@@ -332,6 +416,7 @@ return require('packer').startup(function(use)
|
|||||||
require('colorizer').setup {
|
require('colorizer').setup {
|
||||||
'css',
|
'css',
|
||||||
'javascript',
|
'javascript',
|
||||||
|
'toml'
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
@@ -354,6 +439,7 @@ return require('packer').startup(function(use)
|
|||||||
{ 'nvim-lua/plenary.nvim' },
|
{ 'nvim-lua/plenary.nvim' },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
use { 'stevearc/dressing.nvim' }
|
||||||
if packer_bootstrap then
|
if packer_bootstrap then
|
||||||
require('packer').sync()
|
require('packer').sync()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user