fix: misc fixes to snippets and the state managemnt
This commit is contained in:
parent
c16f6576e2
commit
13d6a9f251
1 changed files with 3 additions and 2 deletions
|
|
@ -95,12 +95,13 @@ local function setup_problem(contest_id, problem_id, language)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.cmd.e(scrape_ctx.source_file)
|
vim.cmd.e(scrape_ctx.source_file)
|
||||||
|
local source_buf = vim.api.nvim_get_current_buf()
|
||||||
|
|
||||||
if vim.api.nvim_buf_get_lines(0, 0, -1, true)[1] == "" then
|
if vim.api.nvim_buf_get_lines(source_buf, 0, -1, true)[1] == "" then
|
||||||
local has_luasnip, luasnip = pcall(require, "luasnip")
|
local has_luasnip, luasnip = pcall(require, "luasnip")
|
||||||
if has_luasnip then
|
if has_luasnip then
|
||||||
local constants = require("cp.constants")
|
local constants = require("cp.constants")
|
||||||
local filetype = vim.api.nvim_get_option_value("filetype", { buf = 0 })
|
local filetype = vim.api.nvim_get_option_value("filetype", { buf = source_buf })
|
||||||
local language_name = constants.filetype_to_language[filetype]
|
local language_name = constants.filetype_to_language[filetype]
|
||||||
local canonical_language = constants.canonical_filetypes[language_name] or language_name
|
local canonical_language = constants.canonical_filetypes[language_name] or language_name
|
||||||
local prefixed_trigger = ("cp.nvim/%s.%s"):format(state.platform, canonical_language)
|
local prefixed_trigger = ("cp.nvim/%s.%s"):format(state.platform, canonical_language)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue