all repos

init.lua @ 79d4a48

my nvim config
5 files changed, 70 insertions(+), 14 deletions(-)
refactor(treesitter): update sql injection
Author: Smirnov Oleksandr ss2316544@gmail.com
Committed at: 2024-03-17 23:50:20 +0200
Parent: 81c1e8f
M after/ftplugin/go.lua

@@ -7,11 +7,15 @@ vim.opt_local.shiftwidth = 4

vim.opt_local.softtabstop = 4 -- mapping -map("n", "<leader>;f", "<cmd>GoIfErr<cr>") -map("n", "<leader>;c", "<cmd>GoCmt<cr>") -map("n", "<leader>;g", "<cmd>GoGenerate %<cr>") -map("n", "<leader>;o", "<cmd>GoTestAdd<cr>") -map("n", "<leader>;a", "<cmd>GoTestsAll<cr>") -map("n", "<leader><leader>", function() - require("scratch.gotest_switcher").switch() -end) +map("n", "<localleader>f", "<cmd>GoIfErr<cr>") +map("n", "<localleader>c", "<cmd>GoCmt<cr>") + +map("n", "<localleader>t", "<cmd>GoTestAdd<cr>") +map("n", "<localleader>a", "<cmd>GoTestsAll<cr>") +map("n", "<localleader>e", "<cmd>GoTestsExp<cr>") + +map( + "n", + "<localleader><localleader>", + require("scratch.gotest_switcher").switch +)
M after/ftplugin/lua.lua

@@ -5,6 +5,6 @@ vim.opt_local.shiftwidth = 2

vim.opt_local.softtabstop = 2 -- some maps -map("n", "<leader>;s", function() +map("n", "<localleader>s", function() vim.cmd.source "%" end)
M lua/plugins/lualine.lua

@@ -34,6 +34,11 @@ end

return "" end, }, + harpoon_status = { + function() + return require("scratch.harpoon_status").lualine() + end, + }, } return {

@@ -56,7 +61,7 @@ },

sections = { lualine_a = { c.mode }, lualine_b = {}, - lualine_c = { "filename", "branch", c.diagnostic }, + lualine_c = { c.harpoon_status, "filename", "branch", c.diagnostic }, lualine_x = { c.qf_status, c.lsp, "diff" }, lualine_y = {}, lualine_z = { c.location },
A lua/scratch/harpoon_status.lua

@@ -0,0 +1,41 @@

+local h = require "harpoon" +local M = {} + +local function get_active_indicator(v) + return string.format("|%d|", v) +end + +function M.status() + local list = h:list() + local rdir = list.config:get_root_dir() + local cfpath = vim.api.nvim_buf_get_name(0) + local len = list:length() + + local status = {} + for i = 1, len do + local value = list:get(i).value + value = value:gsub("^%./", "") + + if cfpath == rdir .. "/" .. value then + table.insert(status, get_active_indicator(i)) + else + table.insert(status, i) + end + end + + return table.concat(status, " ") +end + +function M.lualine() + if not package.loaded["harpoon"] ~= nil then + return + end + return M.status():reverse() +end + +function M.debug() + package.loaded["scratch.harpoon_status"] = nil + require "scratch.harpoon_status" +end + +return M
M queries/go/injections.scm

@@ -1,9 +1,15 @@

;; sql -([(interpreted_string_literal) - (raw_string_literal)] @injection.content +((call_expression + (selector_expression field: (field_identifier) @_field) + (argument_list (interpreted_string_literal) @sql)) + (#any-of? @_field "Exec" "ExecContext" "Query" "QueryContext" "QueryRow" "QueryRowContext") + (#offset! @sql 0 1 0 -1)) + +((raw_string_literal) @injection.content (#contains? @injection.content - "--sql" "-- sql" "select" "insert" "update" "delete" "from" "into" "values" "set" "where" "group by" - "--SQL" "-- SQL" "SELECT" "INSERT" "UPDATE" "DELETE" "FROM" "INTO" "VALUES" "SET" "WHERE" "GROUP BY") + "--sql" "-- sql" ; "select" "insert" "update" "delete" "from" "into" "values" "set" "where" "group by" + "--SQL" "-- SQL" ; "SELECT" "INSERT" "UPDATE" "DELETE" "FROM" "INTO" "VALUES" "SET" "WHERE" "GROUP BY") + ) (#offset! @injection.content 0 1 0 -1) (#set! injection.language "sql"))