Make kak more installable

* Kak relies on the kakrc file to be in ../share/kak/kakrc relative
to kak binary rather than in the same directory
* Added an install target to the Makefile
This commit is contained in:
Maxime Coste 2013-12-23 21:26:07 +00:00
parent bcba5287ad
commit fa72d27f9a
19 changed files with 25 additions and 5 deletions

View File

@ -16,6 +16,8 @@ def -hidden _cpp_indent_on_new_line %~
try %{ exec -draft k<a-x> s \h+$ <ret>d } try %{ exec -draft k<a-x> s \h+$ <ret>d }
# align to opening paren of previous line # align to opening paren of previous line
try %{ exec -draft [( <a-k> \`\([^\n]+\n[^\n]*\n?\' <ret> s \`\(\h*.|.\' <ret> & } try %{ exec -draft [( <a-k> \`\([^\n]+\n[^\n]*\n?\' <ret> s \`\(\h*.|.\' <ret> & }
# align to previous statement start when previous line closed a parenthesis
# try %{ exec -draft <a-?>\)M<a-k>\`\(.*\)[^\n()]*\n\h*\n?\'<ret>s\`|.\'<ret>1<a-&> }
# copy // comments prefix # copy // comments prefix
try %{ exec -draft <c-s>k<a-x> s ^\h*\K(/{2,}) <ret> y<c-o>P } try %{ exec -draft <c-s>k<a-x> s ^\h*\K(/{2,}) <ret> y<c-o>P }
# indent after visibility specifier # indent after visibility specifier
@ -31,8 +33,8 @@ def -hidden _cpp_indent_on_opening_curly_brace %[
] ]
def -hidden _cpp_indent_on_closing_curly_brace %[ def -hidden _cpp_indent_on_closing_curly_brace %[
# deindent on insert } alone on a line # align to opening curly brace when alone on a line
try %[ exec -draft <a-h><a-k> ^\h+\}$ <ret> < ] try %[ exec -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\`|.\'<ret>1<a-&> ]
# add ; after } if class or struct definition # add ; after } if class or struct definition
try %[ exec -draft "hm<space><a-?>(class|struct)<ret><a-k>\`(class|struct)[^{}\n]+(\n)?\s*\{\'<ret><a-space>ma;<esc>" ] try %[ exec -draft "hm<space><a-?>(class|struct)<ret><a-k>\`(class|struct)[^{}\n]+(\n)?\s*\{\'<ret><a-space>ma;<esc>" ]
] ]

View File

@ -10,6 +10,7 @@ addhl -def-group kakrc regex (?<=\<set)\h+((global|buffer|window)|(\S+))\h+(\S+)
addhl -def-group kakrc regex (?<=\<regex)\h+(\S+) 1:string addhl -def-group kakrc regex (?<=\<regex)\h+(\S+) 1:string
addhl -def-group kakrc regex (?<!\\)(["'])(?:\\\1|.)*?\1 0:string addhl -def-group kakrc regex (?<!\\)(["'])(?:\\\1|.)*?\1 0:string
addhl -def-group kakrc regex (^|\h)\#[^\n]*\n 0:comment addhl -def-group kakrc regex (^|\h)\#[^\n]*\n 0:comment
addhl -def-group kakrc region_ref '%sh\{' '\}' sh
hook global WinSetOption filetype=kak %{ addhl ref kakrc } hook global WinSetOption filetype=kak %{ addhl ref kakrc }
hook global WinSetOption filetype=(?!kak).* %{ rmhl kakrc } hook global WinSetOption filetype=(?!kak).* %{ rmhl kakrc }

View File

@ -2,6 +2,13 @@ sources := $(wildcard *.cc)
objects := $(addprefix ., $(sources:.cc=.o)) objects := $(addprefix ., $(sources:.cc=.o))
deps := $(addprefix ., $(sources:.cc=.d)) deps := $(addprefix ., $(sources:.cc=.d))
PREFIX ?= /usr/local
DESTDIR ?= /
bindir := $(DESTDIR)$(PREFIX)/bin
sharedir := $(DESTDIR)$(PREFIX)/share/kak
docdir := $(DESTDIR)$(PREFIX)/share/doc/kak
CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare -pedantic CXXFLAGS += -std=gnu++11 -g -Wall -Wno-reorder -Wno-sign-compare -pedantic
LIBS += -lncursesw LIBS += -lncursesw
@ -41,6 +48,16 @@ XDG_CONFIG_HOME ?= $(HOME)/.config
userconfig: userconfig:
mkdir -p $(XDG_CONFIG_HOME)/kak/autoload mkdir -p $(XDG_CONFIG_HOME)/kak/autoload
ln -s $(CURDIR)/rc/{asciidoc,client,cpp,diff,git,grep,kakrc,mime,make,sh,mail,man}.kak $(XDG_CONFIG_HOME)/kak/autoload/ ln -s $(CURDIR)/../rc/{asciidoc,client,cpp,diff,git,grep,kakrc,mime,make,sh,mail,man}.kak $(XDG_CONFIG_HOME)/kak/autoload/
.PHONY: tags userconfig install: kak
mkdir -p $(bindir)
install -D -m 0755 kak $(bindir)
mkdir -p $(sharedir)/rc
install -D -m 0644 ../share/kak/kakrc $(sharedir)
install -D -m 0644 ../rc/* $(sharedir)/rc
mkdir -p $(docdir)
install -D -m 0644 ../README.asciidoc $(docdir)
install -D -m 0644 ../doc/* $(docdir)
.PHONY: tags userconfig install

View File

@ -52,7 +52,7 @@ String runtime_directory()
char* ptr = strrchr(buffer, '/'); char* ptr = strrchr(buffer, '/');
if (not ptr) if (not ptr)
throw runtime_error("unable to determine runtime directory"); throw runtime_error("unable to determine runtime directory");
return String(buffer, ptr); return String(buffer, ptr) + "/../share/kak";
} }
void register_env_vars() void register_env_vars()