Skip to content

Commit

Permalink
pcc customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
pcc committed Jun 12, 2022
1 parent 650c2aa commit c31d4b6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .kakrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set buffer indentwidth 4
2 changes: 2 additions & 0 deletions linux.kakrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set buffer indentwidth 0
set buffer aligntab true
4 changes: 4 additions & 0 deletions share/kak/kakrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ evaluate-commands %sh{
echo "source '${kak_config}/kakrc'"
fi
}

set -add global ui_options terminal_enable_mouse=false
add-highlighter global/ wrap
set global indentwidth 2
17 changes: 17 additions & 0 deletions src/buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "buffer_manager.hh"
#include "buffer_utils.hh"
#include "client.hh"
#include "command_manager.hh"
#include "context.hh"
#include "diff.hh"
#include "file.hh"
Expand Down Expand Up @@ -73,6 +74,22 @@ void Buffer::on_registered()

if (m_flags & Flags::File)
{
{
InputHandler hook_handler{{ *this, Selection{} },
Context::Flags::Draft,
""};

std::string dir = m_name.c_str();
while (dir.size() > 1) {
dir = dir.substr(0, dir.rfind('/', dir.size() - 2) + 1);
std::string kakrc = dir + ".kakrc";

struct stat s;
if (stat(kakrc.c_str(), &s) == 0) {
CommandManager::instance().execute(format("source {}", StringView(kakrc.c_str(), kakrc.size())), hook_handler.context());
}
}
}
if (m_flags & Buffer::Flags::New)
run_hook_in_own_context(Hook::BufNewFile, m_name);
else
Expand Down
2 changes: 2 additions & 0 deletions src/client.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public:

int pid() const { return m_pid; }

Window &window() const { return *m_window.get(); }

private:
void on_option_changed(const Option& option) override;

Expand Down
7 changes: 7 additions & 0 deletions src/commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,16 @@ void quit(const ParametersParser& parser, Context& context, const ShellContext&)
{
if (not force and ClientManager::instance().count() == 1 and not Server::instance().is_daemon())
ensure_all_buffers_are_saved();
else if (not force and context.buffer().is_modified())
throw runtime_error("buffer modified");

const int status = parser.positional_count() > 0 ? str_to_int(parser[0]) : 0;
ClientManager::instance().remove_client(context.client(), true, status);

if (!any_of(ClientManager::instance(), [&](auto &&c) { return &c->window().buffer() == &context.buffer(); })) {
BufferManager::instance().delete_buffer(context.buffer());
context.forget_buffer(context.buffer());
}
}

const CommandDesc quit_cmd = {
Expand Down
5 changes: 5 additions & 0 deletions vi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

kak=$(dirname $(realpath $0))/src/kak

$kak -s main "$@" || $kak -c main "$@"

0 comments on commit c31d4b6

Please sign in to comment.