summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-04-29 19:14:35 +0300
committerKyren223 <Kyren223@proton.me>2025-04-29 19:14:35 +0300
commitd6415a930134078dd1ba6f07770d8750b2a6b95c (patch)
tree477e1f6837d01e4d7321f1ae6baba6b154a24c93 /.config
parent8ad80a4040f89c713a2ab35ce76a3e6997c66e65 (diff)
Removed lspconfig, migrated old lua/go snippets to new snippets format
Diffstat (limited to '.config')
-rw-r--r--.config/nvim/lua/plugins/blink-cmp.lua1
-rw-r--r--.config/nvim/lua/plugins/nvim-lspconfig.lua12
-rw-r--r--.config/nvim/lua/plugins/oil.lua1
-rw-r--r--.config/nvim/lua/snippets/go.lua77
-rw-r--r--.config/nvim/lua/snippets/lua.lua37
-rw-r--r--.config/nvim/snippets/carbonight-lua.json (renamed from .config/nvim/snippets/carbonight.nvim/lua.json)0
-rw-r--r--.config/nvim/snippets/eko-go.json56
-rw-r--r--.config/nvim/snippets/go.json22
-rw-r--r--.config/nvim/snippets/package.json22
9 files changed, 96 insertions, 132 deletions
diff --git a/.config/nvim/lua/plugins/blink-cmp.lua b/.config/nvim/lua/plugins/blink-cmp.lua
index 0c19ef8..08b5f44 100644
--- a/.config/nvim/lua/plugins/blink-cmp.lua
+++ b/.config/nvim/lua/plugins/blink-cmp.lua
@@ -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
diff --git a/.config/nvim/lua/plugins/nvim-lspconfig.lua b/.config/nvim/lua/plugins/nvim-lspconfig.lua
deleted file mode 100644
index 169f339..0000000
--- a/.config/nvim/lua/plugins/nvim-lspconfig.lua
+++ /dev/null
@@ -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,
-}
diff --git a/.config/nvim/lua/plugins/oil.lua b/.config/nvim/lua/plugins/oil.lua
index 7b7521d..04c4c06 100644
--- a/.config/nvim/lua/plugins/oil.lua
+++ b/.config/nvim/lua/plugins/oil.lua
@@ -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,
diff --git a/.config/nvim/lua/snippets/go.lua b/.config/nvim/lua/snippets/go.lua
deleted file mode 100644
index d6b7114..0000000
--- a/.config/nvim/lua/snippets/go.lua
+++ /dev/null
@@ -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({ '', '}' }),
- }),
-})
diff --git a/.config/nvim/lua/snippets/lua.lua b/.config/nvim/lua/snippets/lua.lua
deleted file mode 100644
index 194f776..0000000
--- a/.config/nvim/lua/snippets/lua.lua
+++ /dev/null
@@ -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) }),
-})
diff --git a/.config/nvim/snippets/carbonight.nvim/lua.json b/.config/nvim/snippets/carbonight-lua.json
index 5697fd2..5697fd2 100644
--- a/.config/nvim/snippets/carbonight.nvim/lua.json
+++ b/.config/nvim/snippets/carbonight-lua.json
diff --git a/.config/nvim/snippets/eko-go.json b/.config/nvim/snippets/eko-go.json
new file mode 100644
index 0000000..867af4b
--- /dev/null
+++ b/.config/nvim/snippets/eko-go.json
@@ -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"
+ }
+}
diff --git a/.config/nvim/snippets/go.json b/.config/nvim/snippets/go.json
new file mode 100644
index 0000000..ff03abc
--- /dev/null
+++ b/.config/nvim/snippets/go.json
@@ -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"
+ }
+}
diff --git a/.config/nvim/snippets/package.json b/.config/nvim/snippets/package.json
index 69cd58e..d85b2b7 100644
--- a/.config/nvim/snippets/package.json
+++ b/.config/nvim/snippets/package.json
@@ -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"
}