Skip to content

Commit

Permalink
Object 2
Browse files Browse the repository at this point in the history
  • Loading branch information
luozhiya committed Dec 19, 2024
1 parent 6575168 commit 4dfabf8
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
7 changes: 3 additions & 4 deletions lua/fittencode/chat/controller.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local Config = require('fittencode.config')
local Log = require('fittencode.log')
local Runtime = require('fittencode.chat.runtime')

---@class fittencode.chat.ChatController
local ChatController = {}
Expand Down Expand Up @@ -59,9 +60,6 @@ function ChatController:hide_chat_view()
self.chat_view:hide()
end

function ChatController:reload_chat_breaker()
end

function ChatController:receive_view_message(parsed_message)
if not parsed_message then return end
local msg_type = parsed_message.type
Expand Down Expand Up @@ -96,7 +94,6 @@ function ChatController:create_conversation(e, show, mode)
updateChatPanel = updateChatPanel,
diffEditorManager = diffEditorManager,
initVariables = s,
logger = logger
})

if o.type == 'unavailable' then
Expand Down Expand Up @@ -126,3 +123,5 @@ end
function ChatController:get_conversation_type(e)
return self.conversation_types_provider:get_conversation_type(e)
end

return ChatController
14 changes: 12 additions & 2 deletions lua/fittencode/chat/conversation.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
local Editor = require('fittencode.editor')
local Log = require('fittencode.log')
local Fn = require('fittencode.fn')
local Config = require('fittencode.config')
local Client = require('fittencode.chat.client')
local Runtime = require('fittencode.chat.runtime')
local VM = require('fittencode.chat.vm')

---@class fittencode.chat.Conversation
local Conversation = {}
Conversation.__index = Conversation
Expand Down Expand Up @@ -45,11 +53,11 @@ end
function Conversation:export_markdown()
local md = self:get_markdown_export()
if md then
local e = View.open_text_document({
local e = Editor.open_text_document({
language = 'markdown',
content = md
})
View.show_text_document(e)
Editor.show_text_document(e)
end
end

Expand Down Expand Up @@ -175,3 +183,5 @@ end
function Conversation:is_busying()
return self.request_handle and self.request_handle.is_active()
end

return Conversation
8 changes: 7 additions & 1 deletion lua/fittencode/chat/conversation_types_provider.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
local TemplateResolver = require('fittencode.chat.template_resolver')
local ConversationType = require('fittencode.chat.conversation_type')
local Editor = require('fittencode.editor')

---@class fittencode.chat.ConversationTypeProvider
local ConversationTypesProvider = {}
ConversationTypesProvider.__index = ConversationTypesProvider
Expand Down Expand Up @@ -92,10 +96,12 @@ function ConversationTypesProvider:load_extension_templates()
end

function ConversationTypesProvider:load_workspace_templates()
local e = TemplateResolver.load_from_directory(editor.get_workspace_path())
local e = TemplateResolver.load_from_directory(Editor.get_workspace_path())
for _, r in ipairs(e) do
if r and r.isEnabled then
self.conversation_types[r.id] = ConversationType:new({ template = r, source = 'local-workspace' })
end
end
end

return ConversationTypesProvider
6 changes: 6 additions & 0 deletions lua/fittencode/chat/runtime.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
local Config = require('fittencode.config')
local editor = require('fittencode.editor')
local Log = require('fittencode.log')

local Runtime = {}

local function get_comment_snippet()
Expand Down Expand Up @@ -84,3 +88,5 @@ function Runtime.resolve_variables(variables, tm)
end
return n
end

return Runtime
4 changes: 4 additions & 0 deletions lua/fittencode/chat/template_resolver.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local Fn = require('fittencode.fn')

---@class fittencode.chat.TemplateResolver
local TemplateResolver = {}

Expand Down Expand Up @@ -125,3 +127,5 @@ function TemplateResolver.load_from_directory(dir)
end
return templates
end

return TemplateResolver
5 changes: 5 additions & 0 deletions lua/fittencode/chat/vm.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
local OPL = require('fittencode.opl')
local Log = require('fittencode.log')

local VM = {}

function VM.run(env, template)
Expand All @@ -12,3 +15,5 @@ function VM.run(env, template)
end
return sample()
end

return VM
2 changes: 1 addition & 1 deletion lua/fittencode/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Editor.get_selected_location_text()
return name .. ' ' .. location.row .. ':' .. location.col
end

function Editor.get_selected_text_with_diagnostics()
function Editor.get_selected_text_with_diagnostics(opts)
-- 1. Get selected text with lsp diagnostic info
-- 2. Format
end
Expand Down
Empty file removed lua/fittencode/view.lua
Empty file.

0 comments on commit 4dfabf8

Please sign in to comment.