Skip to content

Commit

Permalink
action to save temp file
Browse files Browse the repository at this point in the history
  • Loading branch information
mosheavni committed Dec 12, 2023
1 parent 7ee038b commit 2622bc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .config/nvim/lua/user/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,24 @@ return {
end)
end)
end,
['Save current buffer as temp'] = function()
local ft = vim.api.nvim_buf_get_option(0, 'filetype')
if ft == '' then
vim.ui.select(vim.fn.getcompletion('', 'filetype'), { prompt = 'Filetype' }, function(selected)
if not selected then
pretty_print 'Canceled.'
return
end
vim.cmd('set filetype=' .. selected)
-- save with the filetype extension
vim.cmd('write ' .. vim.fn.tempname() .. '.' .. selected)
vim.cmd 'edit'
end)
else
vim.cmd('write ' .. vim.fn.tempname() .. '.' .. ft)
vim.cmd 'edit'
end
end,
['Find files (<C-p>)'] = function()
require('telescope.builtin').find_files()
end,
Expand Down
2 changes: 0 additions & 2 deletions .config/nvim/lua/user/lsp/code-actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ M.toggle_function_params = {
fn = function(context)
local row = context.range.row
local current_line = context.content[row]
-- check if current line starts with \s*def .*\(

local is_function = vim.regex([=[\v\s*def\s[^\)]+\(]=]):match_str(current_line)
local final = current_line
if is_function then
Expand Down

0 comments on commit 2622bc7

Please sign in to comment.