better
This commit is contained in:
@@ -1,17 +1,3 @@
|
||||
local remap = vim.api.nvim_set_keymap
|
||||
local npairs = require('nvim-autopairs')
|
||||
|
||||
npairs.setup({map_cr=false})
|
||||
|
||||
-- skip it, if you use another global object
|
||||
_G.MUtils= {}
|
||||
|
||||
MUtils.completion_confirm=function()
|
||||
if vim.fn["coc#pum#visible"]() ~= 0 then
|
||||
return vim.fn["coc#pum#confirm"]()
|
||||
else
|
||||
return npairs.autopairs_cr()
|
||||
end
|
||||
end
|
||||
|
||||
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})
|
||||
npairs.setup({})
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
local cmp = require("cmp")
|
||||
local cmp_lsp = require("cmp_nvim_lsp")
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
cmp_lsp.default_capabilities()
|
||||
)
|
||||
|
||||
require("fidget").setup({})
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"gopls",
|
||||
},
|
||||
handlers = {
|
||||
function(server_name) -- default handler (optional)
|
||||
require("lspconfig")[server_name].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
end,
|
||||
|
||||
zls = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
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()
|
||||
local lspconfig = require("lspconfig")
|
||||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = { version = "Lua 5.1" },
|
||||
diagnostics = {
|
||||
globals = { "bit", "vim", "it", "describe", "before_each", "after_each" },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end,
|
||||
}
|
||||
})
|
||||
|
||||
local cmp_select = { behaivior = cmp.SelectBehavior.Select }
|
||||
|
||||
cmp.setup {
|
||||
completion = { completeopt = "menu,menuone" },
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
mapping = {
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
|
||||
["<CR>"] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
},
|
||||
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif require("luasnip").jumpable(-1) then
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "async_path" },
|
||||
}),
|
||||
}
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' },
|
||||
{ name = 'cmdline' },
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false },
|
||||
})
|
||||
|
||||
vim.diagnostic.config({
|
||||
-- update_in_insert = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
|
||||
local lspconfig = require "lspconfig"
|
||||
|
||||
-- EXAMPLE
|
||||
local servers = {
|
||||
"html",
|
||||
"cssls",
|
||||
"bashls",
|
||||
"texlab",
|
||||
"pyright",
|
||||
"ts_ls",
|
||||
"jdtls",
|
||||
"sourcekit",
|
||||
"zls",
|
||||
}
|
||||
|
||||
for _, server in ipairs(servers) do
|
||||
lspconfig[server].setup {
|
||||
}
|
||||
end
|
||||
|
||||
-- lspconfig.hyprls.setup {
|
||||
-- root_dir = vim.fs.root( 0, 'hyprland.conf' ),
|
||||
-- single_file_support = false,
|
||||
-- filetypes = { "conf" },
|
||||
-- }
|
||||
+15
-10
@@ -1,16 +1,21 @@
|
||||
local fn = vim.fn
|
||||
|
||||
local function get_coc_lsp_client()
|
||||
local clients = vim.g.coc_service_initialized and vim.fn['CocAction']('services') or {}
|
||||
for _, client in pairs(clients) do
|
||||
if client['state'] == 'running' then
|
||||
local client_name = client['id']
|
||||
-- Remove 'languageserver.' prefix if it exists
|
||||
client_name = client_name:gsub('^languageserver%.', '')
|
||||
return client_name
|
||||
local get_active_lsp = function()
|
||||
local msg = "🚫"
|
||||
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
|
||||
local clients = vim.lsp.get_clients { bufnr = 0 }
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return ''
|
||||
return msg
|
||||
end
|
||||
|
||||
local function spell()
|
||||
@@ -127,7 +132,7 @@ require("lualine").setup {
|
||||
color = { fg = "black", bg = "#f46868" },
|
||||
},
|
||||
{
|
||||
get_coc_lsp_client,
|
||||
get_active_lsp,
|
||||
icon = " LSP:",
|
||||
},
|
||||
{
|
||||
|
||||
+27
-20
@@ -12,13 +12,6 @@ return {
|
||||
require("config.autosession")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neoclide/coc.nvim",
|
||||
branch = 'release',
|
||||
},
|
||||
-- {
|
||||
-- "sainnhe/gruvbox-material",
|
||||
-- },
|
||||
{
|
||||
"olimorris/onedarkpro.nvim",
|
||||
config = function()
|
||||
@@ -54,9 +47,6 @@ return {
|
||||
require("config.barbar")
|
||||
end,
|
||||
},
|
||||
-- {
|
||||
-- "itchyny/lightline.vim",
|
||||
-- },
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
@@ -73,15 +63,6 @@ return {
|
||||
require("config.undotree")
|
||||
end,
|
||||
},
|
||||
-- {
|
||||
-- "lukas-reineke/indent-blankline.nvim",
|
||||
-- main = "ibl",
|
||||
-- ---@module "ibl"
|
||||
-- ---@type ibl.config
|
||||
-- config = function()
|
||||
-- require("config.indent-blankline")
|
||||
-- end,
|
||||
-- },
|
||||
{
|
||||
"hiphish/rainbow-delimiters.nvim",
|
||||
},
|
||||
@@ -124,7 +105,7 @@ return {
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
config = function()
|
||||
require("config.dap")
|
||||
require("config.dapconf")
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -172,4 +153,30 @@ return {
|
||||
{
|
||||
"notken12/base46-colors",
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"j-hui/fidget.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("config.lspconfig")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"smolck/command-completion.nvim",
|
||||
opts = {
|
||||
border = nil,
|
||||
highlight_selection = true,
|
||||
use_matchfuzzy = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user