Removed lspconfig, migrated old lua/go snippets to new snippets format
This commit is contained in:
@@ -85,6 +85,7 @@ return {
|
||||
score_offset = 200, -- make snippets highest priority
|
||||
transform_items = function(_, items)
|
||||
return vim.tbl_filter(function(item)
|
||||
-- vim.print(item)
|
||||
if item.kind ~= require('blink.cmp.types').CompletionItemKind.Snippet then
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
return {
|
||||
-- NOTE: Make sure the order is as follows:
|
||||
-- Mason loads -> Mason lspconfig loads -> Lspconfig loads
|
||||
'neovim/nvim-lspconfig',
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
dependencies = {
|
||||
-- 'hrsh7th/cmp-nvim-lsp',
|
||||
{ 'antosha417/nvim-lsp-file-operations', conifg = true },
|
||||
},
|
||||
config = function()
|
||||
end,
|
||||
}
|
||||
@@ -26,7 +26,6 @@ return {
|
||||
},
|
||||
|
||||
lsp_file_methods = {
|
||||
-- Enable or disable LSP file operations
|
||||
enabled = true,
|
||||
-- Time to wait for LSP file operations to complete before skipping
|
||||
timeout_ms = 1000,
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
require('luasnip.session.snippet_collection').clear_snippets('go')
|
||||
local ls = require('luasnip')
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local d = ls.dynamic_node
|
||||
|
||||
---@param abbr string
|
||||
---@param expansion string
|
||||
---@param args table
|
||||
local function snip(abbr, expansion, args)
|
||||
return ls.snippet(abbr, require('luasnip.extras.fmt').fmt(expansion, args))
|
||||
end
|
||||
|
||||
local tea_model = [=[
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
type Model struct{{
|
||||
{}
|
||||
}}
|
||||
|
||||
func New() Model {{
|
||||
return Model{{
|
||||
}}
|
||||
}}
|
||||
|
||||
func (m Model) Init() tea.Cmd {{
|
||||
return nil
|
||||
}}
|
||||
|
||||
func (m Model) View() string {{
|
||||
return fmt.Sprintf(
|
||||
"%s",
|
||||
"",
|
||||
)
|
||||
}}
|
||||
|
||||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {{
|
||||
switch msg := msg.(type) {{
|
||||
default:
|
||||
return m, nil
|
||||
}}
|
||||
}}
|
||||
]=]
|
||||
|
||||
local server_api = [=[
|
||||
func {}(ctx context.Context, sess *session.Session, request packet{}) packet.Payload {{
|
||||
}}
|
||||
]=]
|
||||
|
||||
ls.add_snippets('go', {
|
||||
snip('tmod', tea_model, { i(0) }),
|
||||
snip('sapi', server_api, { i(1), i(0) }),
|
||||
|
||||
s('iferr', {
|
||||
t({ 'if err != nil {', '' }),
|
||||
i(1, ' return'),
|
||||
t({ '', '}' }),
|
||||
}),
|
||||
|
||||
s('fmterr', {
|
||||
t('fmt.Errorf("'),
|
||||
i(1, 'msg'),
|
||||
t(': %w", err)'),
|
||||
}),
|
||||
|
||||
s('dberr', {
|
||||
t({ 'if err != nil {', '' }),
|
||||
i(2, { ' log.Println("database error ', 'x', ':", err)', '' }),
|
||||
i(2, ' return ', '&ErrInternalError'),
|
||||
t({ '', '}' }),
|
||||
}),
|
||||
})
|
||||
@@ -1,37 +0,0 @@
|
||||
require('luasnip.session.snippet_collection').clear_snippets('lua')
|
||||
local ls = require('luasnip')
|
||||
local i = ls.insert_node
|
||||
|
||||
---@param abbr string
|
||||
---@param expansion string
|
||||
---@param args table
|
||||
local function s(abbr, expansion, args)
|
||||
return ls.snippet(abbr, require('luasnip.extras.fmt').fmt(expansion, args))
|
||||
end
|
||||
|
||||
local carbonight_group = [=[
|
||||
--[[
|
||||
Copyright (C) 2024 Kyren223
|
||||
This file is licensed under the GPL-3.0-or-later license, see https://fsf.org/licenses/gpl-3.0
|
||||
--]]
|
||||
|
||||
local utils = require("carbonight.utils")
|
||||
|
||||
local M = {{}}
|
||||
|
||||
---@param c Colors
|
||||
function M.get(c)
|
||||
return {{
|
||||
{}
|
||||
}}
|
||||
end
|
||||
|
||||
return M
|
||||
]=]
|
||||
|
||||
ls.add_snippets('lua', {
|
||||
s('desc', "{{ desc = '{}' }}", { i(0) }),
|
||||
s('cmd', '<cmd>{}<cr>', { i(0) }),
|
||||
s('scmd', "'<cmd>{}<cr>'", { i(0) }),
|
||||
s('cng', carbonight_group, { i(0) }),
|
||||
})
|
||||
56
.config/nvim/snippets/eko-go.json
Normal file
56
.config/nvim/snippets/eko-go.json
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"eko dblog": {
|
||||
"body": "log.Println(\"$TM_FILENAME:$TM_LINE_NUMBER database error:\", err)",
|
||||
"prefix": "dblog"
|
||||
},
|
||||
"eko dberr": {
|
||||
"body": [
|
||||
"if err != nil {",
|
||||
"\tlog.Println(\"$TM_FILENAME:$TM_LINE_NUMBER database error:\", err)",
|
||||
"\treturn &ErrInternalError",
|
||||
"}"
|
||||
],
|
||||
"prefix": "dberr"
|
||||
},
|
||||
"eko serverapi": {
|
||||
"body": [
|
||||
"func $1(ctx context.Context, sess *session.Session, request *packet$0) packet.Payload {",
|
||||
"}"
|
||||
],
|
||||
"prefix": "serverapi"
|
||||
},
|
||||
"eko teamodel": {
|
||||
"body": [
|
||||
"import (",
|
||||
"\t\"fmt\"",
|
||||
"",
|
||||
"\ttea \"github.com/charmbracelet/bubbletea\"",
|
||||
")",
|
||||
"",
|
||||
"type Model struct{",
|
||||
" $0",
|
||||
"}",
|
||||
"",
|
||||
"func New() Model {",
|
||||
"\treturn Model",
|
||||
" }",
|
||||
"}",
|
||||
"",
|
||||
"func (m Model) Init() tea.Cmd {",
|
||||
"\treturn nil",
|
||||
"}",
|
||||
"",
|
||||
"func (m Model) View() string {",
|
||||
"\treturn \"\"",
|
||||
"}",
|
||||
"",
|
||||
"func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {",
|
||||
"\tswitch msg := msg.(type) {",
|
||||
"\tdefault:",
|
||||
"\t\treturn m, nil",
|
||||
"\t}",
|
||||
"}"
|
||||
],
|
||||
"prefix": "teamodel"
|
||||
}
|
||||
}
|
||||
22
.config/nvim/snippets/go.json
Normal file
22
.config/nvim/snippets/go.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"fmterr": {
|
||||
"body": "fmt.Errorf(\"$0: %w\", err)",
|
||||
"prefix": "fmterr"
|
||||
},
|
||||
"iferr": {
|
||||
"body": [
|
||||
"if err != nil {",
|
||||
"\treturn $0",
|
||||
"}"
|
||||
],
|
||||
"prefix": "iferr"
|
||||
},
|
||||
"meth": {
|
||||
"body": [
|
||||
"func (${1:receiver} ${2:type}) ${3:method}($4) $5 {",
|
||||
"\t$0",
|
||||
"}"
|
||||
],
|
||||
"prefix": "meth"
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,29 @@
|
||||
{
|
||||
"name": "personal-snippets",
|
||||
"contributes": {
|
||||
"snippets": [
|
||||
{
|
||||
"path": "./lua.json",
|
||||
"language": [
|
||||
"lua"
|
||||
]
|
||||
],
|
||||
"path": "./lua.json"
|
||||
},
|
||||
{
|
||||
"language": "lua",
|
||||
"path": "./carbonight.nvim/lua.json"
|
||||
"path": "./carbonight-lua.json"
|
||||
},
|
||||
{
|
||||
"language": [
|
||||
"go"
|
||||
],
|
||||
"path": "./go.json"
|
||||
},
|
||||
{
|
||||
"language": [
|
||||
"go"
|
||||
],
|
||||
"path": "./eko-go.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "personal-snippets"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user