separated plugins configs and added couple new plugins

This commit is contained in:
Jeremie Fraeys 2023-11-22 01:25:43 -05:00
parent 8c93e97b86
commit 6b3424c590
11 changed files with 201 additions and 115 deletions

View file

@ -14,21 +14,48 @@ return {
},
config = function()
-- See `:help cmp`
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
require('luasnip.loaders.from_vscode').lazy_load()
local cmp = require 'cmp'
local luasnip = require 'luasnip'
require('luasnip.loaders.from_vscode').lazy_load()
luasnip.config.setup {}
local select_opts = { behavior = cmp.SelectBehavior.Select }
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 = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
@ -54,10 +81,38 @@ return {
end
end, { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}
local sign = function(opts)
vim.fn.sign_define(opts.name, {
texthl = opts.name,
text = opts.text,
numhl = ''
})
end
sign({ name = 'DiagnosticSignError', text = '' })
sign({ name = 'DiagnosticSignWarn', text = '' })
sign({ name = 'DiagnosticSignHint', text = '' })
sign({ name = 'DiagnosticSignInfo', text = '»' })
vim.diagnostic.config({
virtual_text = false,
severity_sort = true,
float = {
border = 'rounded',
source = 'always',
},
})
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
vim.lsp.handlers.hover,
{ border = 'rounded' }
)
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
vim.lsp.handlers.signature_help,
{ border = 'rounded' }
)
end,
}

View file

@ -60,17 +60,24 @@ return {
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
end, { desc = 'Format current buffer with LSP and lint' })
-- Enable auto-formatting on save
vim.api.nvim_command([[
augroup AutoFormatOnSave
autocmd!
autocmd BufWritePre * :Format
augroup END
]])
-- vim.api.nvim_command([[
-- augroup AutoFormatOnSave
-- autocmd!
-- autocmd BufWritePre * :Format
-- augroup END
-- ]])
end
-- Setup neovim lua configuration
require('neodev').setup()
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Servers configuration
local servers = {
clangd = {},
gopls = {
@ -82,7 +89,7 @@ return {
completeUnimported = true,
usePlaceholders = true,
analysis = {
unusedarams = true,
unusedParams = true,
},
},
},
@ -91,46 +98,39 @@ return {
settings = {
pylsp = {
plugins = {
pycodestyle = {
ignore = { 'W391' },
maxLineLength = 79
black = {
blackArgs = {
"--line-length", "79",
"--exclude", "venv",
"--exclude", "env",
"--exclude", ".git",
"--exclude", ".hg",
},
lineLength = 79,
},
flake8 = {},
black = {
lineLength = 79,
-- Configure Black to split lines without specifying a target version
blackArgs = {
"--line-length",
"79",
"--exclude",
"venv",
"--exclude",
"env",
"--exclude",
".git",
"--exclude",
".hg",
},
isort = {
profile = "black",
},
mypy = {
enabled = true,
command = 'mypy',
args = {},
command = "mypy",
diagnostics = true,
enabled = true,
},
isort = {
profile = 'black',
pycodestyle = {
ignore = { "W391" },
maxLineLength = 79,
},
},
python = {
-- Specify the path to your Python interpreter
pythonPath = "/usr/bin/python3",
analysis = {
autoSearchPaths = true,
diagnosticMode = 'openFilesOnly',
diagnosticMode = "openFilesOnly",
typeCheckingMode = "strict",
useLibraryCodeForTypes = true,
typeCheckingMode = 'on',
},
pythonPath = "/usr/local/bin/python3",
},
},
},
@ -138,7 +138,6 @@ return {
-- rust_analyzer = {},
-- tsserver = {},
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
@ -147,16 +146,8 @@ return {
},
}
-- Setup neovim lua configuration
require('neodev').setup()
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- Setup Mason condifuration
local mason = require 'mason'
-- Setup Mason configuration
local mason = require('mason')
mason.setup {
ui = {
icons = {
@ -166,13 +157,14 @@ return {
},
},
}
-- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig'
-- Ensure the servers above are installed
local mason_lspconfig = require('mason-lspconfig')
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers)
ensure_installed = vim.tbl_keys(servers),
}
-- Add Mason handlers
mason_lspconfig.setup_handlers {
function(server_name)
require('lspconfig')[server_name].setup {
@ -183,5 +175,8 @@ return {
}
end
}
-- Load nvim-cmp after Mason to allow Mason to configure it first
require('cmp')
end
}

View file

@ -0,0 +1,34 @@
return {
"debugloop/telescope-undo.nvim",
dependencies = { -- note how they're inverted to above example
{
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
},
},
keys = {
{ -- lazy style key map
"<leader>u",
"<cmd>Telescope undo<cr>",
desc = "undo history",
},
},
opts = {
extensions = {
undo = {
side_by_side = true,
layout_strategy = "vertical",
layout_config = {
preview_height = 0.8,
},
},
},
},
config = function(_, opts)
-- Calling telescope's setup from multiple specs does not hurt, it will happily merge the
-- configs for us. We won't use data, as everything is in it's own namespace (telescope
-- defaults, as well as each extension).
require("telescope").setup(opts)
require("telescope").load_extension("undo")
end,
}

View file

@ -4,6 +4,7 @@ return {
branch = '0.1.x',
dependencies = {
'nvim-lua/plenary.nvim',
'debugloop/telescope-undo.nvim',
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
-- Only load if `make` is available. Make sure you have the system
-- requirements installed.
@ -19,7 +20,7 @@ return {
'nvim-tree/nvim-web-devicons',
},
config = function()
require('telescope').setup {
require('telescope').setup({
defaults = {
mappings = {
i = {
@ -28,7 +29,7 @@ return {
},
},
},
}
})
-- Enable telescope fzf native, if installed
pcall(require('telescope').load_extension, 'fzf')
@ -68,5 +69,7 @@ return {
end
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
-- require("telescope").extensions.undo.undo()
end,
}

View file

@ -1,6 +1,6 @@
return {
'mbbill/undotree',
config = function()
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle, { desc = '[U]ndotree' })
end
-- 'mbbill/undotree',
-- config = function()
-- vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle, { desc = '[U]ndotree' })
-- end
}

View file

@ -43,4 +43,3 @@ return {
end
end
}

View file

@ -1,4 +1,13 @@
return {
'folke/which-key.nvim',
opts = {}
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}