-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- TODO: | ||
-- [ ] clear all errors on buffer save until linter returns to prevent outdated errors when linter is active | ||
-- [ ] show preview window when linting process is active |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
set tabstop=2 | ||
set shiftwidth=2 | ||
|
||
lua vim.treesitter.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require("my.remap") | ||
-- require('my.packages') | ||
|
||
-- print("init/my done") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- https://neovim.io/doc/user/intro.html#keycodes | ||
|
||
vim.g.mapleader = ' ' | ||
|
||
-- nmap 0 looks like free binding | ||
|
||
-- local normal = { 'Q' = 'q', 'q' = dwim_window_exit } | ||
|
||
vim.keymap.set('n', '<leader>j', vim.cmd.Ex) | ||
|
||
vim.keymap.set('n', 'Q', 'q') | ||
|
||
vim.keymap.set('n', 'q', function() | ||
-- window first | ||
-- then tab (but last window kill should close tab itself) | ||
-- then buffer | ||
vim.api.nvim_feedkeys(vim.keycode('<C-w>q'), 'n', false) | ||
end, { expr = true }) | ||
|
||
|
||
-- insert mode 's-enter' make newline above 'C-o s-O' | ||
-- vim.keymap.set('i', '<S-CR>', '<Esc>O') | ||
|
||
-- :help menu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
-- ttt - type to tab | ||
|
||
-- :h completeopt omnifunc completefunc complete-functions | ||
-- :h ins-completion-menu | ||
-- :h :map-<expr> | ||
|
||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect', 'popup' } | ||
|
||
-- infix hints are out of scope | ||
local function inline_hint() | ||
local pos = vim.api.nvim_win_get_cursor(0) | ||
|
||
-- local buf = vim.api.nvim_get_current_buf() | ||
local ns = vim.api.nvim_create_namespace('ttt') | ||
|
||
local mark = vim.api.nvim_buf_set_extmark(0, ns, 0, 0, {}) | ||
|
||
-- local all = api.nvim_buf_get_extmarks(0, ns, 0, -1, {}) | ||
|
||
|
||
-- Deprecated | ||
-- vim.api.nvim_buf_set_virtual_text(buf, ns, 0, {{'Just', 'Comment'}}, {}) | ||
|
||
-- virt_text_pos = 'overlay' | ||
-- virt_text_pos = 'eol' | ||
-- local opts = { id = 1, end_line = 10, virt_text = {{"just", "Delimiter"}} } | ||
-- local mark_id = vim.api.nvim_buf_set_extmark(buf, ns, line, column, opts) | ||
end | ||
|
||
vim.keymap.set('i', '<Tab>', function() | ||
if vim.fn.pumvisible() == 1 then | ||
return '<C-n>' | ||
end | ||
return '<Tab>' | ||
end, { expr = true }) | ||
|
||
-- inoremap <expr> . MayComplete() | ||
-- func MayComplete() | ||
-- if (can complete) | ||
-- return ".\<C-X>\<C-O>" | ||
-- endif | ||
-- return '.' | ||
-- endfunc | ||
|
||
|
||
-- TODO: make it buffer local and init with delimiters for filetype (maybe from grammar) | ||
local triggers = {'.'} | ||
vim.api.nvim_create_autocmd("InsertCharPre", { | ||
buffer = vim.api.nvim_get_current_buf(), | ||
callback = function() | ||
if vim.fn.pumvisible() == 1 or vim.fn.state('m') == 'm' then | ||
return | ||
end | ||
local char = vim.v.char | ||
if vim.list_contains(triggers, char) then | ||
local key = vim.keycode("<C-x><C-n><C-p>") | ||
vim.api.nvim_feedkeys(key, 'm', false) | ||
end | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function! GitRef() | ||
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'") | ||
endfunction | ||
|
||
function! GitRoot() | ||
let l:git_root = system("basename $(git rev-parse --show-toplevel)") | ||
if v:shell_error == 0 | ||
echomsg 'git root:' .. l:git_root | ||
return l:git_root | ||
else | ||
" echohl WarningMsg | echo "Don't panic!" | echohl None | ||
throw 'git root unavailable' | ||
endif | ||
endfunction | ||
|
||
function! StatuslineGit() | ||
let l:refname = GitRef() | ||
" TODO: | ||
" - [ ] dim the title | ||
" - [ ] make this local to window | ||
return strlen(l:refname) > 0 ? ' git:'.l:refname.' ' : '' | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
" Omni Tab | ||
" :h ins-completion | ||
" complete_info() - get the current completion info | ||
" | ||
" C-e stops , C-y accepts | ||
" :h popupmenu-keys | ||
" :h compl-current | ||
" :h completefunc | ||
" :h vim.lua_omnifunc | ||
" | ||
" | ||
" | ||
" https://neovim.io/doc/user/autocmd.html#CompleteChanged | ||
" https://neovim.io/doc/user/insert.html#complete-items | ||
" | ||
" Idle detection | ||
" https://neovim.io/doc/user/options.html#'updatetime' | ||
" https://neovim.io/doc/user/windows.html#CursorHold-example | ||
|
||
let s:triggers = ['.'] " TODO: re-use delimiters from filetype | ||
|
||
" let Pchar = {-> 'ignoerr' } | ||
|
||
function! Pchar() | ||
if pumvisible() == 1 | ||
echo . | ||
return | ||
endif | ||
let l:c = v:char | ||
if index(s:triggers, c) >= 0 | ||
feedkeys("<C-x><C-n>", 'm') | ||
endif | ||
endfunction | ||
|
||
function! Clear() | ||
" echo 'clear completion' | ||
endfunction | ||
|
||
command Abspath :let @+ = expand('%:p') " copy to pasteboard current buffer absolute path | ||
|
||
augroup ot | ||
autocmd! | ||
autocmd InsertCharPre <buffer> :call Pchar() | ||
autocmd InsertLeavePre <buffer> :echo 'leave pre' | ||
" autocmd CursorMovedI <buffer> :call Clear() | ||
augroup end | ||
|
||
|
||
" autocmd BufWritePost <sfile> ++once source <sfile> |