feat: add translation snippet

This commit is contained in:
max_richter 2022-11-17 23:38:29 +01:00
parent 00822e03a4
commit 13407572ac
6 changed files with 102 additions and 2 deletions

View File

@ -58,6 +58,7 @@ cmp.setup({
{ name = "nvim_lsp" },
-- { name = "cmp_tabnine", max_item_count = 3 },
{ name = "luasnip" },
{ name = "emoji" },
{ name = "path" },
{ name = "buffer" },
{ name = "calc" },

View File

@ -0,0 +1,58 @@
local languages = require "configs.translate.languages";
local pickers = require 'telescope.pickers'
local finders = require 'telescope.finders'
local actions = require 'telescope.actions'
local action_state = require 'telescope.actions.state'
local conf = require('telescope.config').values
return function()
-- This active_buf and active selection because telescope clears everything (i think)
local active_buf = vim.api.nvim_get_current_buf();
local mode = vim.api.nvim_get_mode().mode;
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), 'x!', true)
local start_mark = vim.api.nvim_buf_get_mark(active_buf, "<")
local end_mark = vim.api.nvim_buf_get_mark(active_buf, ">")
pickers
.new({}, {
prompt_title = 'Translate',
finder = finders.new_table {
results = languages,
entry_maker = function(entry)
return {
value = entry[2],
ordinal = entry[1] .. " " .. entry[2],
display = entry[3] .. entry[1],
}
end,
},
sorter = conf.generic_sorter {},
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
vim.api.nvim_set_current_buf(active_buf)
vim.api.nvim_win_set_cursor(0, start_mark);
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(mode, true, false, true), 'x!', true)
vim.api.nvim_win_set_cursor(0, end_mark);
local timer = vim.loop.new_timer()
timer:start(500, 0, vim.schedule_wrap(function()
if mode == "v" or mode == "V" then
vim.cmd("'<,'>Translate " .. selection.value)
else
vim.cmd("Translate " .. selection.value)
end
end))
end)
return true
end,
previewer = nil
})
:find()
end

View File

@ -0,0 +1,34 @@
return { { "Afrikaans", "af", "🇦🇫" }, { "Albanian", "sq", "🇸🇶" }, { "Amharic", "am", "🇦🇲" },
{ "Arabic", "ar", "🇦🇷" }, { "Armenian", "hy", "🇭🇾" }, { "Azerbaijani", "az", "🇦🇿" },
{ "Basque", "eu", "🇪🇺" }, { "Belarusian", "be", "🇧🇪" }, { "Bengali", "bn", "🇧🇳" },
{ "Bosnian", "bs", "🇧🇸" }, { "Bulgarian", "bg", "🇧🇬" }, { "Catalan", "ca", "🇨🇦" },
{ "Cebuano", "ceb", "🇨🇪🇧" }, { "Chinese (Simplified)", "zh-CN", "🇿🇭🇒🇨🇳" },
{ "Chinese (Traditional)", "zh-TW", "🇿🇭🇒🇹🇼" }, { "Corsican", "co", "🇨🇴" },
{ "Croatian", "hr", "🇭🇷" }, { "Czech", "cs", "🇨🇸" }, { "Danish", "da", "🇩🇦" }, { "Dutch", "nl", "🇳🇱" },
{ "English", "en", "🇪🇳" }, { "Esperanto", "eo", "🇪🇴" }, { "Estonian", "et", "🇪🇹" },
{ "Finnish", "fi", "🇫🇮" }, { "French", "fr", "🇫🇷" }, { "Frisian", "fy", "🇫🇾" },
{ "Galician", "gl", "🇬🇱" }, { "Georgian", "ka", "🇰🇦" }, { "German", "de", "🇩🇪" },
{ "Greek", "el", "🇪🇱" }, { "Gujarati", "gu", "🇬🇺" }, { "Haitian Creole", "ht", "🇭🇹" },
{ "Hausa", "ha", "🇭🇦" }, { "Hawaiian", "haw", "🇭🇦🇼" }, { "Hebrew", "iw", "🇮🇼" },
{ "Hindi", "hi", "🇭🇮" }, { "Hmong", "hmn", "🇭🇲🇳" }, { "Hungarian", "hu", "🇭🇺" },
{ "Icelandic", "is", "🇮🇸" }, { "Igbo", "ig", "🇮🇬" }, { "Indonesian", "id", "🇮🇩" },
{ "Irish", "ga", "🇬🇦" }, { "Italian", "it", "🇮🇹" }, { "Japanese", "ja", "🇯🇦" },
{ "Javanese", "jw", "🇯🇼" }, { "Kannada", "kn", "🇰🇳" }, { "Kazakh", "kk", "🇰🇰" },
{ "Khmer", "km", "🇰🇲" }, { "Korean", "ko", "🇰🇴" }, { "Kurdish", "ku", "🇰🇺" }, { "Kyrgyz", "ky", "🇰🇾" },
{ "Lao", "lo", "🇱🇴" }, { "Latin", "la", "🇱🇦" }, { "Latvian", "lv", "🇱🇻" }, { "Lithuanian", "lt", "🇱🇹" },
{ "Luxembourgish", "lb", "🇱🇧" }, { "Macedonian", "mk", "🇲🇰" }, { "Malagasy", "mg", "🇲🇬" },
{ "Malay", "ms", "🇲🇸" }, { "Malayalam", "ml", "🇲🇱" }, { "Maltese", "mt", "🇲🇹" },
{ "Maori", "mi", "🇲🇮" }, { "Marathi", "mr", "🇲🇷" }, { "Mongolian", "mn", "🇲🇳" },
{ "Myanmar (Burmese)", "my", "🇲🇾" }, { "Nepali", "ne", "🇳🇪" }, { "Norwegian", "no", "🇳🇴" },
{ "Nyanja (Chichewa)", "ny", "🇳🇾" }, { "Pashto", "ps", "🇵🇸" }, { "Persian", "fa", "🇫🇦" },
{ "Polish", "pl", "🇵🇱" }, { "Portuguese (Portugal, Brazil)", "pt", "🇵🇹" }, { "Punjabi", "pa", "🇵🇦" },
{ "Romanian", "ro", "🇷🇴" }, { "Russian", "ru", "🇷🇺" }, { "Samoan", "sm", "🇸🇲" },
{ "Scots Gaelic", "gd", "🇬🇩" }, { "Serbian", "sr", "🇸🇷" }, { "Sesotho", "st", "🇸🇹" },
{ "Shona", "sn", "🇸🇳" }, { "Sindhi", "sd", "🇸🇩" }, { "Sinhala (Sinhalese)", "si", "🇸🇮" },
{ "Slovak", "sk", "🇸🇰" }, { "Slovenian", "sl", "🇸🇱" }, { "Somali", "so", "🇸🇴" },
{ "Spanish", "es", "🇪🇸" }, { "Sundanese", "su", "🇸🇺" }, { "Swahili", "sw", "🇸🇼" },
{ "Swedish", "sv", "🇸🇻" }, { "Tagalog (Filipino)", "tl", "🇹🇱" }, { "Tajik", "tg", "🇹🇬" },
{ "Tamil", "ta", "🇹🇦" }, { "Telugu", "te", "🇹🇪" }, { "Thai", "th", "🇹🇭" }, { "Turkish", "tr", "🇹🇷" },
{ "Ukrainian", "uk", "🇺🇰" }, { "Urdu", "ur", "🇺🇷" }, { "Uzbek", "uz", "🇺🇿" },
{ "Vietnamese", "vi", "🇻🇮" }, { "Welsh", "cy", "🇨🇾" }, { "Xhosa", "xh", "🇽🇭" },
{ "Yiddish", "yi", "🇾🇮" }, { "Yoruba", "yo", "🇾🇴" }, { "Zulu", "zu", "🇿🇺" } }

View File

@ -8,7 +8,7 @@ vim.api.nvim_create_autocmd({ 'TextYankPost' }, {
end,
})
local rememberFoldsGroup = vim.api.nvim_create_augroup('RememberFolds', { clear = true })
-- local rememberFoldsGroup = vim.api.nvim_create_augroup('RememberFolds', { clear = true })
--
-- vim.api.nvim_create_autocmd({ 'BufWinLeave', 'BufLeave' }, {
-- pattern = "*",

View File

@ -1,6 +1,7 @@
-- local map = vim.api.nvim_set_keymap
local map = vim.keymap.set
local g = vim.g
local translate = require("configs.translate")
local saga = require("lspsaga")
saga.init_lsp_saga()
@ -31,6 +32,9 @@ map({ "n", "v" }, "gr", "Lspsaga lsp_finder<CR>", options)
map("n", "<leader>t", ":TroubleToggle<CR>", remap)
map("n", "<leader>t", translate, remap)
map("v", "<leader>t", translate, remap)
-- DAP Functionality
map("n", "<Leader>b", ":lua require('dap').toggle_breakpoint()", options)

View File

@ -11,7 +11,10 @@ local function scheme_for_appearance(appearance)
end
return {
font = wezterm.font("FiraCodeNerdFont"),
font = wezterm.font_with_fallback {
"FiraCodeNerdFont",
"Noto Color Emoji"
},
font_size = 13,
-- You can specify some parameters to influence the font selection;
-- for example, this selects a Bold, Italic font variant.