Skip to content

Commit

Permalink
(autocmds) don't restore cursor on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunsingh committed Jan 17, 2023
1 parent b558a53 commit e331b56
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 65 deletions.
2 changes: 0 additions & 2 deletions fnl/core/doctor.fnl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
;; WIP: use :checkhealth to display missing LSP executables

(local config (require :lspconfig))
(local {:report_start report-start!
:report_info report-info!
Expand Down
9 changes: 8 additions & 1 deletion fnl/core/init.fnl
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
(import-macros {: let!} :macros)
(local {: executable?} (autoload :core.lib))


;; add python provider and mason binaries

(set vim.env.PATH (.. vim.env.PATH ":" (vim.fn.stdpath :data) :/mason/bin))

(set vim.env.PATH (.. vim.env.PATH ":" (vim.fn.stdpath :config) :/bin))

(let! python3_host_prog (if (executable? "python") (vim.fn.exepath "python")
(executable? "python3") (vim.fn.exepath "python3")
nil))

;; check for cli

(local cli (os.getenv :NYOOM_CLI))
Expand Down
16 changes: 8 additions & 8 deletions fnl/core/lib/fun.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -264,26 +264,26 @@
(set methods.nth (method1 nth))
(set exports.nth (export1 nth))

(fn head-call [state ...]
(fn car-call [state ...]
(when (= state nil)
(error "head: iterator is empty"))
...)

(fn head [gen param state]
(head-call (gen param state)))
(fn car [gen param state]
(car-call (gen param state)))

(set methods.car head)
(set exports.car (export0 head))
(set methods.car car)
(set exports.car (export0 car))

(fn tail [gen param state]
(fn cdr [gen param state]
(set-forcibly! state (gen param state))
(when (= state nil)
(let [earlyrtns_1 [(wrap nil-gen nil nil)]]
(lua "return (table.unpack or _G.unpack)(earlyrtns_1)")))
(wrap gen param state))

(set methods.cdr (method0 tail))
(set exports.cdr (export0 tail))
(set methods.cdr (method0 cdr))
(set exports.cdr (export0 cdr))

(fn take-n-gen-x [i state-x ...]
(when (= state-x nil)
Expand Down
4 changes: 2 additions & 2 deletions fnl/core/lib/io.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
(assert (string.match (tmpfile \"Hello world\") \"^/tmp/vim\"
(assert (string.match (tmpfile {\"Hello\", \"world\"}) \"^/tmp/vim\"))
```"
(let [tmp (vim.fn.tempname)]
(let [tmp (vim.loop.fs_mktemp)]
(if (= :table (type contents))
(spit tmp (.. "\n" contents))
(spit tmp (or contents "")))
Expand Down Expand Up @@ -366,7 +366,7 @@
```fennel
(assert (= (mkdirp \"/tmp/dir1/dir2\") true))
```"
(vim.fn.mkdir dir :p))
(vim.loop.fs_mkdir dir :p))

(fn expand [...]
"Expand environment variables in a path.
Expand Down
27 changes: 0 additions & 27 deletions fnl/core/patch.fnl

This file was deleted.

17 changes: 7 additions & 10 deletions fnl/macros.fnl
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
;; fennel-ls: macro-file

(local {: nil? : str? : ->str : begins-with? : all : crypt} (require :core.lib))

(fn car [xs]
(. xs 1))
(local {: nil? : str? : ->str : begins-with? : all : crypt : car} (require :core.lib))

(lambda expr->str [expr]
`(macrodebug ,expr nil))
Expand Down Expand Up @@ -553,12 +550,12 @@
loadname (string.sub (string.match package "/.+") 2)
augroup (.. :nyoom-pact- loadname)
host :github
autocmds `(do
)
callback `(do
)
result `(do
)
autocmds `(do)

callback `(do)

result `(do)

options (or ?options {})
options (collect [k v (pairs options)]
(match k
Expand Down
1 change: 1 addition & 0 deletions fnl/modules.fnl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(import-macros {: nyoom!} :macros)

;; NOTE: TODO and FIXME modules still need work. WIP: modules work but may still be buggy

;; fnlfmt: skip
Expand Down
8 changes: 1 addition & 7 deletions fnl/modules/checkers/diagnostics/config.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
(local null-ls (autoload :null-ls))
(local null-ls-sources [])

;; ensures

(nyoom-module-ensure! lsp)

;; configure signs

(let [{: config : severity} vim.diagnostic
{: sign_define} vim.fn]
(config {:underline {:severity {:min severity.INFO}}
:signs {:severity {:min severity.INFO}}
;; lsp_lines handles this
:virtual_text false
:update_in_insert true
:severity_sort true
Expand Down Expand Up @@ -43,8 +38,7 @@

(nyoom-module-p! format
(do
(table.insert null-ls-sources
null-ls.builtins.formatting.fnlfmt)
;; (table.insert null-ls-sources null-ls.builtins.formatting.fnlfmt)
(nyoom-module-p! cc
(table.insert null-ls-sources
null-ls.builtins.formatting.clang_format))
Expand Down
12 changes: 8 additions & 4 deletions fnl/modules/config/default/config.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
(fn bufexists? [...]
(= (vim.fn.bufexists ...) 1))

(augroup! restore-cursor-on-exit (clear!)
(autocmd! VimLeave * `(set! guicursor ["a:ver100-blinkon0"])))

(augroup! open-file-on-last-position (clear!)
(autocmd! BufReadPost *
`(fn []
Expand All @@ -16,9 +13,16 @@

(augroup! read-file-on-disk-change (clear!)
(autocmd! [FocusGained BufEnter CursorHold CursorHoldI] *
`(if (and (not= :c (vim.fn.mode))
`(if (and (not= :c (vim.api.nvim_get_mode))
(not (bufexists? "[Command Line]")))
(vim.cmd.checktime)))
(autocmd! FileChangedShellPost *
`(vim.notify "File changed on disk. Buffer reloaded."
vim.log.levels.INFO)))

(let [open_floating_preview vim.lsp.util.open_floating_preview]
(fn vim.lsp.util.open_floating_preview [...]
(local (bufnr winid) (open_floating_preview ...))
(vim.api.nvim_win_set_option winid :breakindentopt "")
(vim.api.nvim_win_set_option winid :showbreak "NONE")
(values bufnr winid)))
1 change: 0 additions & 1 deletion fnl/modules/lang/neorg/config.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
(local neorg-modules
{:core.defaults {}
:core.norg.manoeuvre {}
:core.gtd.base {:config {:workspace :main}}
:core.keybinds {:config {:default_keybinds false}}
:core.norg.dirman {:config {:workspaces {:main "~/neorg"}}}})

Expand Down
12 changes: 10 additions & 2 deletions fnl/modules/tools/tree-sitter/config.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(let [leap-ast (autoload :leap-ast)]
(map! [nxo] :gs `(leap-ast.leap) {:desc "Leap AST"}))))

(local treesitter-filetypes [:comment :help :fennel :vim :regex :query])
(local treesitter-filetypes [:help :fennel :vim :regex :query])

;; conditionally install parsers

Expand Down Expand Up @@ -94,14 +94,22 @@
;; load dependencies

(packadd! nvim-ts-rainbow)
(packadd! nvim-ts-refactor)
(packadd! nvim-treesitter-textobjects)
(packadd! nvim-ts-context-commentstring)
; the usual

(setup :nvim-treesitter.configs
{:ensure_installed treesitter-filetypes
:sync_install true
;; :sync_install true
:highlight {:enable true :use_languagetree true}
:indent {:enable true}
:context_commentstring {:enable true}
:refactor {:enable true
:keymaps {:smart_rename "<localleader>rn"}}
:query_linter {:enable true
:use_virtual_text true
:lint_events ["BufWrite" "CursorHold"]}
:rainbow {:enable true
:extended_mode true
:colors ["#878d96"
Expand Down
2 changes: 2 additions & 0 deletions fnl/modules/tools/tree-sitter/init.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
:requires [(pack :nvim-treesitter/playground
{:cmd :TSPlayground})
(pack :p00f/nvim-ts-rainbow {:opt true})
(pack :JoosepAlviste/nvim-ts-context-commentstring {:opt true})
(pack :nvim-treesitter/nvim-treesitter-refactor {:opt true})
(pack :nvim-treesitter/nvim-treesitter-textobjects
{:opt true})]
:setup (fn []
Expand Down
1 change: 0 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ end
local default_providers = {
"node",
"perl",
"python3",
"ruby",
}

Expand Down

0 comments on commit e331b56

Please sign in to comment.