init commit
This commit is contained in:
409
config/dot/nvim/lua/plugins/lsp.lua
Normal file
409
config/dot/nvim/lua/plugins/lsp.lua
Normal file
@@ -0,0 +1,409 @@
|
||||
return {
|
||||
'mason-org/mason-lspconfig.nvim',
|
||||
dependencies = {
|
||||
{ 'neovim/nvim-lspconfig', },
|
||||
{
|
||||
'mason-org/mason.nvim',
|
||||
opts = {
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
event = { 'InsertEnter', 'CmdlineEnter' },
|
||||
config = function()
|
||||
local cmp = require'cmp'
|
||||
local lspkind = require'lspkind'
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
local luasnip = require'luasnip'
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
{ name = 'luasnip_choice' },
|
||||
{ name = 'copilot' },
|
||||
{ name = 'supermaven' },
|
||||
{ name = 'nvim_lsp_document_symbol' },
|
||||
{ name = 'nvim_lsp_signature_help' },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'nerdfont' },
|
||||
{ name = 'emoji' },
|
||||
{ name = 'npm' },
|
||||
{ name = 'cmp-tw2css' },
|
||||
{ name = 'dotenv' },
|
||||
{ name = 'render-markdown' },
|
||||
}),
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
mode = 'symbol',
|
||||
maxwidth = {
|
||||
menu = 50,
|
||||
abbr = 50,
|
||||
},
|
||||
symbol_map = {
|
||||
Supermaven = '',
|
||||
},
|
||||
ellipsis_char = '...',
|
||||
show_labelDetails = true,
|
||||
before = function(entry, vim_item)
|
||||
return vim_item
|
||||
end,
|
||||
}),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<CR>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
if luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
else
|
||||
cmp.confirm({
|
||||
select = true,
|
||||
})
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
--['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
--['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
--['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
}),
|
||||
--mapping = cmp.mapping.preset.insert({
|
||||
--['<Tab>'] = cmp.mapping(function(fallback)
|
||||
--if cmp.visible() then
|
||||
--if cmp.get_selected_entry() then
|
||||
--cmp.confirm({ select = false })
|
||||
--else
|
||||
--cmp.select_next_item()
|
||||
--end
|
||||
--else
|
||||
--fallback()
|
||||
--end
|
||||
--end, { 'i', 's' }),
|
||||
|
||||
--['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
--['<C-Space>'] = cmp.mapping.complete(),
|
||||
--['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
--['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
--['<C-e>'] = cmp.mapping.abort(),
|
||||
--['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
--['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
--['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||
--['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||
--}),
|
||||
preselect = cmp.PreselectMode.Item,
|
||||
completion = {
|
||||
completeopt = 'menu,menuone,noinsert',
|
||||
},
|
||||
})
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'git' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
}
|
||||
})
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' },
|
||||
}, {
|
||||
{ name = 'cmdline' },
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false }
|
||||
})
|
||||
end,
|
||||
},
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
{ 'nvim-lua/plenary.nvim' },
|
||||
{ 'hrsh7th/cmp-nvim-lsp-document-symbol' },
|
||||
{ 'hrsh7th/cmp-nvim-lua' },
|
||||
{ 'hrsh7th/cmp-nvim-lsp-signature-help' },
|
||||
{ 'hrsh7th/cmp-path' },
|
||||
{ 'hrsh7th/cmp-copilot' },
|
||||
{ 'hrsh7th/cmp-buffer' },
|
||||
{ 'hrsh7th/cmp-emoji' },
|
||||
{ 'chrisgrieser/cmp-nerdfont' },
|
||||
{ 'jcha0713/cmp-tw2css' },
|
||||
{ 'SergioRibera/cmp-dotenv' },
|
||||
{ 'saadparwaiz1/cmp_luasnip' },
|
||||
{ 'onsails/lspkind.nvim' },
|
||||
{ 'rafamadriz/friendly-snippets' },
|
||||
{
|
||||
'L3MON4D3/cmp-luasnip-choice',
|
||||
config = function()
|
||||
require'cmp_luasnip_choice'.setup()
|
||||
end,
|
||||
},
|
||||
{
|
||||
'petertriho/cmp-git',
|
||||
config = function()
|
||||
require'cmp_git'.setup({})
|
||||
end
|
||||
},
|
||||
{
|
||||
'j-hui/fidget.nvim',
|
||||
config = function()
|
||||
require'fidget'.setup({})
|
||||
end,
|
||||
},
|
||||
{
|
||||
'David-Kunz/cmp-npm',
|
||||
config = function()
|
||||
require'cmp-npm'.setup({})
|
||||
end
|
||||
},
|
||||
{
|
||||
'stevearc/conform.nvim',
|
||||
config = function()
|
||||
require'conform'.setup({
|
||||
formatters_by_ft = {
|
||||
cs = { 'csharpier', 'lsp' },
|
||||
javascript = { 'prettierd', 'prettier' },
|
||||
javascriptreact = { 'prettierd', 'prettier' },
|
||||
typescript = { 'prettierd', 'prettier' },
|
||||
typescriptreact = { 'prettierd', 'prettier' },
|
||||
json = { 'prettierd', 'prettier' },
|
||||
html = { 'prettierd', 'prettier' },
|
||||
css = { 'prettierd', 'prettier' },
|
||||
lua = { 'stylua' },
|
||||
},
|
||||
})
|
||||
vim.api.nvim_create_user_command(
|
||||
'Format',
|
||||
function(args)
|
||||
local range
|
||||
if args.count ~= -1 then
|
||||
local start_line = vim.fn.line("'<")
|
||||
local end_line = vim.fn.line("'>")
|
||||
range = { start = { start_line, 0 }, ["end"] = { end_line, 0 } }
|
||||
end
|
||||
require'conform'.format({
|
||||
async = true,
|
||||
lsp_fallback = true,
|
||||
range = range,
|
||||
})
|
||||
end, { range = true, desc = "Format current buffer or range" })
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
'<leader>fk',
|
||||
':Format<CR>',
|
||||
mode = {'n', 'v'},
|
||||
silent = true,
|
||||
desc = "Format with conform"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'L3MON4D3/LuaSnip',
|
||||
version = 'v2.*',
|
||||
build = 'make install_jsregexp'
|
||||
},
|
||||
{
|
||||
'github/copilot.vim',
|
||||
},
|
||||
{
|
||||
'supermaven-inc/supermaven-nvim',
|
||||
config = function()
|
||||
require'supermaven-nvim'.setup({
|
||||
keymaps = {
|
||||
accept_suggestion = '<Tab>',
|
||||
clear_suggestion = '<C-]>',
|
||||
accept_word = '<C-.>',
|
||||
},
|
||||
disable_inline_completion = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
'windwp/nvim-autopairs',
|
||||
event = 'InsertEnter',
|
||||
config = true
|
||||
},
|
||||
{
|
||||
'windwp/nvim-ts-autotag',
|
||||
config = function()
|
||||
require'nvim-ts-autotag'.setup({})
|
||||
end,
|
||||
},
|
||||
--{
|
||||
--"garyhurtz/cmp_kitty",
|
||||
--dependencies = {
|
||||
--{ "hrsh7th/nvim-cmp" },
|
||||
--},
|
||||
--init = function()
|
||||
--require('cmp_kitty'):setup()
|
||||
--end
|
||||
--},
|
||||
{ 'hrsh7th/cmp-cmdline' },
|
||||
},
|
||||
config = function()
|
||||
vim.diagnostic.config({
|
||||
float = {
|
||||
focusable = false,
|
||||
style = 'minimal',
|
||||
border = 'rounded',
|
||||
source = true,
|
||||
header = '',
|
||||
prefix = '',
|
||||
},
|
||||
})
|
||||
require'mason'.setup({})
|
||||
local cmp = require'cmp'
|
||||
local cmp_lsp = require'cmp_nvim_lsp'
|
||||
local lspconfig = require'lspconfig'
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
'force',
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
cmp_lsp.default_capabilities()
|
||||
)
|
||||
local cmp_autopairs = require'nvim-autopairs.completion.cmp'
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||
require 'mason-lspconfig'.setup({
|
||||
ensure_installed = {
|
||||
'angularls',
|
||||
'asm_lsp',
|
||||
'bacon_ls',
|
||||
'bashls',
|
||||
'clangd',
|
||||
'cmake',
|
||||
'cssls',
|
||||
'css_variables',
|
||||
'cssmodules_ls',
|
||||
'docker_compose_language_service',
|
||||
'docker_language_server',
|
||||
'dockerls',
|
||||
'eslint',
|
||||
'gopls',
|
||||
'graphql',
|
||||
'html',
|
||||
'htmx',
|
||||
'intelephense',
|
||||
'jsonls',
|
||||
'kotlin_lsp',
|
||||
'ltex',
|
||||
'ltex_plus',
|
||||
'lua_ls',
|
||||
'markdown_oxide',
|
||||
'nginx_language_server',
|
||||
'phpactor',
|
||||
'postgres_lsp',
|
||||
'prismals',
|
||||
'pylyzer',
|
||||
'pyright',
|
||||
'remark_ls',
|
||||
'rust_analyzer',
|
||||
'sqlls',
|
||||
'superhtml',
|
||||
'svelte',
|
||||
'systemd_ls',
|
||||
'tailwindcss',
|
||||
'tinymist',
|
||||
'ts_ls',
|
||||
'yamlls',
|
||||
},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
lspconfig[server_name].setup({
|
||||
capabilities = capabilities
|
||||
})
|
||||
end,
|
||||
zls = function()
|
||||
lspconfig.zls.setup({
|
||||
root_dir = lspconfig.util.root_pattern(".git", "build.zig", "zls.json"),
|
||||
settings = {
|
||||
zls = {
|
||||
enable_inlay_hints = true,
|
||||
enable_snippets = true,
|
||||
warn_style = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.g.zig_fmt_parse_errors = 0
|
||||
vim.g.zig_fmt_autosave = 0
|
||||
end,
|
||||
["lua_ls"] = function()
|
||||
lspconfig.lua_ls.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { 'vim' },
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
-- These are the key settings to prevent the infinite processing
|
||||
maxPreload = 100000,
|
||||
preloadFileSize = 10000,
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
format = {
|
||||
enable = true,
|
||||
defaultConfig = {
|
||||
indent_style = "space",
|
||||
indent_size = "2",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
})
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user