1
0
Fork 0

nvim: Configuration updates

This commit is contained in:
Daniel Kempkens 2022-05-01 21:52:10 +02:00
parent 9f3e43db4a
commit f736b5ce92
12 changed files with 157 additions and 79 deletions

View file

@ -31,8 +31,7 @@
(let [formatprg (vim.opt_local.formatprg:get)
formatprg-exe (-> formatprg (vim.split " " {:trimempty true}) (. 1))]
(if (= b.nifoc_formatter_disabled 1) nil
(= b.nifoc_lsp_formatter_enabled 1) (vim.lsp.buf.formatting_sync nil
1000)
(= b.nifoc_lsp_formatter_enabled 1) (vim.lsp.buf.format {:timeout_ms 1000})
(not= formatprg-exe nil) (let [neoformat (.. "Neoformat "
formatprg-exe)]
(cmd (.. "try | undojoin | " neoformat

72
config/nvim/nifoc/lsp.fnl Normal file
View file

@ -0,0 +1,72 @@
;; Based on https://github.com/nvim-lua/lsp-status.nvim
(let [mod {}
current-function-symbols {:Class ""
:Enum "ﴳ"
:Function ""
:Interface ""
:Method ""
:Module ""
:Namespace ""
:Package ""
:Struct "ﴳ"}
lsp-proto vim.lsp.protocol
set-bufvar vim.api.nvim_buf_set_var
augroup (vim.api.nvim_create_augroup :NifocLsp {:clear true})
aucmd vim.api.nvim_create_autocmd]
(fn extract-symbols [acc items]
(if (= items nil)
acc
(do
(each [_ item (ipairs items)]
(local kind (or (. lsp-proto.SymbolKind item.kind) :Unknown))
(var sym-range nil)
(if item.location (set sym-range item.location.range)
item.range (set sym-range item.range))
(when sym-range
(do
(set sym-range.start.line (+ sym-range.start.line 1))
(set sym-range.end.line (+ sym-range.end.line 1))))
(table.insert acc {:range sym-range : kind :text item.name})
(when item.children
(extract-symbols item.children acc)))
acc)))
(fn current-function-symbol? [item]
(and item.range (not= (. current-function-symbols item.kind) nil)))
(fn cursor-in-range? [cursor sym]
(let [line (. cursor 1)
char (. cursor 2)]
(if (or (< line sym.start.line) (> line sym.end.line)) false
(and (= line sym.start.line) (< char sym.start.character)) false
(and (= line sym.end.line) (> char sym.end.character)) false
true)))
(fn handle-update-current-context [err result ctx config]
(set-bufvar ctx.bufnr :nifoc_lsp_current_context "")
(when (and (= err nil) (= (type result) :table))
(let [filtered-symbols (->> result (extract-symbols [])
(vim.tbl_filter current-function-symbol?))
cursor-pos (vim.api.nvim_win_get_cursor 0)]
(for [i (length filtered-symbols) 1 -1]
(local sym (. filtered-symbols i))
(when (cursor-in-range? cursor-pos sym.range)
(let [current-context (.. (. current-function-symbols sym.kind) " "
sym.text)]
(set-bufvar ctx.bufnr :nifoc_lsp_current_context current-context)))))))
(fn update-current-context [bufnr]
(let [params {:textDocument (vim.lsp.util.make_text_document_params bufnr)}]
(vim.lsp.buf_request bufnr :textDocument/documentSymbol params
handle-update-current-context)))
(fn mod.on-attach [client bufnr]
(when client.server_capabilities.documentSymbolProvider
(aucmd [:CursorHold]
{:callback #(update-current-context bufnr)
:buffer bufnr
:group augroup
:desc "Update current function variable"})))
mod)

View file

@ -42,8 +42,8 @@
(table.concat result " ")))
(fn mod.current-function []
(let [fun vim.b.lsp_current_function]
(if (and (not= fun nil) (> (fun:len) 0)) (.. " " fun) "")))
(let [ctx vim.b.nifoc_lsp_current_context]
(if (and (not= ctx nil) (> (ctx:len) 0)) ctx "")))
(fn mod.spell-enabled? []
(if (and (buffer-not-empty?) vim.wo.spell) "ﮒ" ""))

View file

@ -8,9 +8,12 @@
:--hidden
:-L
:-g
:!.git/*]})
:!.git/*
:-g
:!node_modules/*]})
ok? (pcall builtin.git_files git-opts)]
(when (not ok?)
(builtin.find_files find-opts))))
mod)

View file

@ -1,11 +1,18 @@
(let [mod {}
o vim.opt
g vim.g
cmd vim.cmd]
cmd vim.cmd
dracula (require :dracula)
dracula-colors (dracula.colors)
highlight (partial vim.api.nvim_set_hl 0)]
(fn mod.setup []
(set g.dracula_show_end_of_buffer false)
(set g.dracula_italic_comment true)
(set o.background :dark)
(cmd "colorscheme dracula"))
(cmd "colorscheme dracula")
(highlight :MatchParen {:fg dracula-colors.orange :bold true :italic true})
(highlight :MatchWord {:italic true})
(cmd "highlight link MatchupVirtualText Comment"))
mod)

View file

@ -23,6 +23,7 @@
(cmp.setup {:sources (cmp.config.sources [{:name :nvim_lsp}
{:name :luasnip}
{:name :nvim_lsp_signature_help}
{:name :nvim_lua}]
[{:name :treesitter}
{:name :buffer}
@ -53,6 +54,7 @@
:luasnip "[LuaSnip]"
:nvim_lsp "[LSP]"
:nvim_lsp_document_symbol "[Symbol]"
:nvim_lsp_signature_help "[param]"
:nvim_lua "[Lua]"
:path "[Path]"
:treesitter "[Treesitter]"}})}})

View file

@ -1,14 +1,13 @@
(let [lsp (require :lspconfig)
lsp-status (require :lsp-status)
illuminate (require :illuminate)
cmp (require :cmp_nvim_lsp)
nifoc-lsp (require :nifoc.lsp)
diagnostic (require :nifoc.diagnostic)
formatting (require :nifoc.formatting)]
(fn custom-attach [client bufnr]
(when client.server_capabilities.documentSymbolProvider
(lsp-status.on_attach client bufnr))
(when client.server_capabilities.documentHighlightProvider
(illuminate.on_attach client bufnr))
(nifoc-lsp.on-attach client bufnr)
(diagnostic.maybe-enable-lsp client bufnr)
(formatting.maybe-enable-lsp client bufnr))
@ -17,11 +16,6 @@
(set client.server_capabilities.documentRangeFormattingProvider false)
(custom-attach client bufnr))
;; Setup
(lsp-status.config {:current_function true
:show_filename false
:diagnostics false})
(lsp-status.register_progress)
;; Custom handler
(tset vim.lsp.handlers :textDocument/hover
(vim.lsp.with vim.lsp.handlers.hover {:border :rounded}))
@ -29,9 +23,7 @@
(vim.lsp.with vim.lsp.handlers.signature_help {:border :rounded}))
;; Servers
(let [default-capabilities (vim.lsp.protocol.make_client_capabilities)
capabilities (vim.tbl_extend :keep
(cmp.update_capabilities default-capabilities)
lsp-status.capabilities)
capabilities (cmp.update_capabilities default-capabilities)
flags {:allow_incremental_sync true :debounce_text_changes 700}
default-config {:on_attach custom-attach : capabilities : flags}
default-config-no-format {:on_attach custom-attach-no-format

View file

@ -1,3 +1,6 @@
(let [g vim.g]
(set g.matchup_matchparen_deferred true)
(set g.matchup_matchparen_offscreen {:method :popup}))
(let [matchup (require :match-up)]
(matchup.setup {:matchparen {:deferred true
:offscreen {:method :popup}
:start_sign ""
:end_sign ""}}))

View file

@ -61,3 +61,4 @@
:autotag {:enable true}
:playground {:enable true}
:nifoc_hooks {:enable true}}))

View file

@ -73,11 +73,11 @@
]
},
"locked": {
"lastModified": 1651007090,
"narHash": "sha256-C/OoQRzTUOWEr1sd3xTKA2GudA1YG1XB3MlL6KfTchg=",
"lastModified": 1651415224,
"narHash": "sha256-O/EzwxUMa1OawWEwhS10Xki7RX3+hSgaJJziHeI4d7c=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "778af87a981eb2bfa3566dff8c3fb510856329ef",
"rev": "26858fc0dbed71fa0609490fc2f2643e0d175328",
"type": "github"
},
"original": {
@ -96,11 +96,11 @@
},
"locked": {
"dir": "contrib",
"lastModified": 1651034292,
"narHash": "sha256-DWUR3vEA/By4d4PqhPCHrbSD1BGBgJt6xBr6jdwC/dU=",
"lastModified": 1651381075,
"narHash": "sha256-jVU1WolekCTYM6O/8hpVVkpff+sT1EHPHu11ckdx08Q=",
"owner": "neovim",
"repo": "neovim",
"rev": "0d41c4dee126b6d93ee8ed82302af47df9a50576",
"rev": "07660193a38918aa6a17ec691c4e8b021436ed67",
"type": "github"
},
"original": {
@ -119,11 +119,11 @@
]
},
"locked": {
"lastModified": 1651047663,
"narHash": "sha256-i62DXKI21jaQOPRPQmMB0mOd4X/8juv45vxWPLbSFjQ=",
"lastModified": 1651392941,
"narHash": "sha256-Gv377HY45bPZj0cKPo5BJGxDHI+TN62MNWF/n/iO0Q8=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "dc34cc5005e63138ebbe464ffdbd5e85ce289d1f",
"rev": "efb684030fa093f0a5f0327994fea1ab790859e6",
"type": "github"
},
"original": {
@ -154,11 +154,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1651024496,
"narHash": "sha256-uKSrrw/neSkxX6TXPSaMyfu7iKzFrK7F6HOt6vQefGY=",
"lastModified": 1651369430,
"narHash": "sha256-d86uUm0s11exU9zLo2K1AwtJQJDKubFpoF0Iw767uT4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d9e593ed5889f3906dc72811c45bf684be8865cf",
"rev": "b283b64580d1872333a99af2b4cef91bb84580cf",
"type": "github"
},
"original": {
@ -186,11 +186,11 @@
]
},
"locked": {
"lastModified": 1651020475,
"narHash": "sha256-DZ06GIJFVjqMAHjQm0rq76f2DxBBHQtxf6OVeYW9eXc=",
"lastModified": 1651366322,
"narHash": "sha256-bqYxGGxF4rBcowUQSO2z3ZWeuecSiYTIyy2q3xP1fgg=",
"owner": "arqv",
"repo": "zig-overlay",
"rev": "008a410310a1c152274b6d9e80242a31d06f57b2",
"rev": "145dc6d35b8dbc4ba3a9507c98d09e36a8a43502",
"type": "github"
},
"original": {

View file

@ -267,7 +267,6 @@ in
# LSP
lspkind-nvim
lsp-status-nvim
{
plugin = vim-illuminate;

View file

@ -69,12 +69,12 @@
};
leap-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "leap.nvim";
version = "2022-04-26";
version = "2022-04-28";
src = pkgs.fetchFromGitHub {
owner = "ggandor";
repo = "leap.nvim";
rev = "dc1dc740fbf0d685749540392c029ddf6179b30d";
sha256 = "1gadp3jxzh7msm1q4imkww67aa5911s9m0fv3bz5p5i9nvwq6mpm";
rev = "c8a7d9ee19b476c0cd0f45b1af9d4b94e5223ae3";
sha256 = "18zh5qp713vviacgjxm729mnm0yndz5ddaicjaygwy5m8hyfpa13";
fetchSubmodules = false;
};
};
@ -91,12 +91,12 @@
};
nvim-treesitter = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-treesitter";
version = "2022-04-27";
version = "2022-05-01";
src = pkgs.fetchFromGitHub {
owner = "nvim-treesitter";
repo = "nvim-treesitter";
rev = "9fdd6765fc05632c2f3af1ad825dc4e9cc0b041f";
sha256 = "17q63fm7sg4rbp9d0njg686nkxxms3714l5aqq1mday0fjrjv15r";
rev = "44d2898f0feaf297728bf3c05e980b667fb6ad4a";
sha256 = "1435yvrrhhngnr2s390qjwyg1k61hwyn0kirgf14bsiw3n9aja5v";
fetchSubmodules = false;
};
};
@ -113,23 +113,23 @@
};
playground = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "playground";
version = "2022-04-08";
version = "2022-05-01";
src = pkgs.fetchFromGitHub {
owner = "nvim-treesitter";
repo = "playground";
rev = "13e2d2d63ce7bc5d875e8bdf89cb070bc8cc7a00";
sha256 = "1klkg3n3rymb6b9im7hq9yq26mqf2v79snsqbx72am649c6qc0ns";
rev = "dd250b05d41e16f4e2a8d27270b035125dc27dc5";
sha256 = "16jf6gkbaj6n25zfmh1rbvbybmcp514b7pd03b1mmnlvcp8dsdg6";
fetchSubmodules = false;
};
};
telescope-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "telescope.nvim";
version = "2022-04-27";
version = "2022-05-01";
src = pkgs.fetchFromGitHub {
owner = "nvim-telescope";
repo = "telescope.nvim";
rev = "4449f709c36503e65e40d9e61bf742ef861c7269";
sha256 = "19mh83jard7g8gdmz302ar55sh7jj3mc4gmlr4bqig89l1zisk7w";
rev = "544c5ee40752ac5552595da86a62abaa39e2dfa9";
sha256 = "1qbnpy9njp8g7fwqj8x7dpncaii5ykkgpiqd8abjdaxvnvi3yik8";
fetchSubmodules = false;
};
};
@ -153,12 +153,12 @@
};
telescope-ui-select-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "telescope-ui-select.nvim";
version = "2022-04-24";
version = "2022-04-30";
src = pkgs.fetchFromGitHub {
owner = "nvim-telescope";
repo = "telescope-ui-select.nvim";
rev = "78cda7ed94663416f401ca114bde124f178cec05";
sha256 = "1gd1qg4b3pr4vxhrvfdmghpjfn7i7jscp7gih16jmblhmc6dc44i";
rev = "62ea5e58c7bbe191297b983a9e7e89420f581369";
sha256 = "09mbi1x2r2xsbgfmmpb7113jppjmfwym4sr7nfvpc9glgqlkd4zw";
fetchSubmodules = false;
};
};
@ -175,56 +175,56 @@
};
nvim-lspconfig = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-lspconfig";
version = "2022-04-27";
version = "2022-04-28";
src = pkgs.fetchFromGitHub {
owner = "neovim";
repo = "nvim-lspconfig";
rev = "86df1c83ec69e5bbcde48de74c440b71a629b2f6";
sha256 = "1ikw17j4zwrck0xyfka9466kh3z4xcir6ixpz0snxkb7x4cnifjm";
rev = "21102d5e3b6ffc6929d60418581ac1a29ee9eddd";
sha256 = "16hdgxzbb31253178kyy1j77qpskq80dlnfdfxj2bh761zc237rn";
fetchSubmodules = false;
};
};
nvim-lint = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-lint";
version = "2022-04-27";
version = "2022-05-01";
src = pkgs.fetchFromGitHub {
owner = "mfussenegger";
repo = "nvim-lint";
rev = "d754a5f062ca62bc8c3e7ecee7d514ba1dfc4b23";
sha256 = "1bvqwigcdapl7rzmjacaghjmlwa3j29i4pxvhbdp9accc3myyc5i";
rev = "48067bda493897488047763a863da1683e29e490";
sha256 = "18ap0g03vlr3il7vmhab79h49l3181lwswy3q5nhwj1dfik09yj0";
fetchSubmodules = false;
};
};
LuaSnip = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "LuaSnip";
version = "2022-04-27";
version = "2022-05-01";
src = pkgs.fetchFromGitHub {
owner = "L3MON4D3";
repo = "LuaSnip";
rev = "0e9139119d3ca4b858ad7c181c72a97932699b9c";
sha256 = "1ir6gdl7i7snpm71iy2s81pw1lgp1dbh225knm2n8qxx0szlvrny";
rev = "1dbafec2379bd836bd09c4659d4c6e1a70eb380e";
sha256 = "1y0jp1saggg59lpicyvjbklg3fb5qmbmh8q7gacx27zgp26hz66r";
fetchSubmodules = false;
};
};
nvim-cmp = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-cmp";
version = "2022-04-21";
version = "2022-05-01";
src = pkgs.fetchFromGitHub {
owner = "hrsh7th";
repo = "nvim-cmp";
rev = "433af3dffce64cbd3f99bdac9734768a6cc41951";
sha256 = "0r3va6syk6vfhs909p4r5p4h3ifyy5f4rk0m9jnvwblg9cjy17sw";
rev = "baa8646c248486fdd46e8a087ae5623165901b9f";
sha256 = "1p85phfq6q9ddk4d6flz7409z4p7d9z0zvr7dj72qny44y7d4yz2";
fetchSubmodules = false;
};
};
cmp-nvim-lsp = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "cmp-nvim-lsp";
version = "2022-01-15";
version = "2022-05-01";
src = pkgs.fetchFromGitHub {
owner = "hrsh7th";
repo = "cmp-nvim-lsp";
rev = "ebdfc204afb87f15ce3d3d3f5df0b8181443b5ba";
sha256 = "0kmaxxdxlp1s5w36khnw0sdrbv1lr3p5n9r90h6h7wv842n4mnca";
rev = "e6b5feb2e6560b61f31c756fb9231a0d7b10c73d";
sha256 = "0jzgd9g874w507y40fzggbm40n467g8br5xcmgf2mscdb9kcsgvc";
fetchSubmodules = false;
};
};
@ -318,12 +318,12 @@
};
nvim-autopairs = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-autopairs";
version = "2022-04-23";
version = "2022-04-29";
src = pkgs.fetchFromGitHub {
owner = "windwp";
repo = "nvim-autopairs";
rev = "3d7b552eb4db6a3e081bf791e9e03e0dd58b7152";
sha256 = "1w7pik465dlwpfv5nw2yg2y7g8j06rxvqg2w2cdax7d1h75jgmiv";
rev = "63779ea99ed43ab22660ac6ae5b506a40bf41aeb";
sha256 = "0lc03xjsamy8fpfwy6ag9r8cx1cp0my461l0wvbgznzr1qkq325y";
fetchSubmodules = false;
};
};
@ -362,12 +362,12 @@
};
lualine-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "lualine.nvim";
version = "2022-04-24";
version = "2022-04-30";
src = pkgs.fetchFromGitHub {
owner = "nvim-lualine";
repo = "lualine.nvim";
rev = "de2c4beaf50552647273b5eaa33095e90a6d00a0";
sha256 = "0whcwy5xmkmmj7lb4w9g31rm6clx1pcnng3q22hcwyvrlxbkk263";
rev = "030eb62bc46386d9112cfa70dd0baa8bcc1cc133";
sha256 = "038gbl7lcsw58a6wwm4smn3f7majgx387fv25mbm21g1n6j1i79w";
fetchSubmodules = false;
};
};
@ -428,12 +428,12 @@
};
gitsigns-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "gitsigns.nvim";
version = "2022-04-27";
version = "2022-04-29";
src = pkgs.fetchFromGitHub {
owner = "lewis6991";
repo = "gitsigns.nvim";
rev = "5f1f0c9afd2f7293cb8f4a6f4b296ed9544f0a1b";
sha256 = "1bkq94a3k6j66v6156a6ym0vml85ma1zbdfvx9bf9bd6m6sjs35r";
rev = "b800663f4535838a819ac6d8396bd01b29332138";
sha256 = "0v45cwa2rdlgzq7livmyrzxhfqrzzgz8fmrp5k1ci485mcbhfffd";
fetchSubmodules = false;
};
};
@ -450,12 +450,12 @@
};
nvim-notify = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-notify";
version = "2022-04-27";
version = "2022-05-01";
src = pkgs.fetchFromGitHub {
owner = "rcarriga";
repo = "nvim-notify";
rev = "6f298f219f373b657b40dab7468bbd19e9ba8159";
sha256 = "122qrzfrj9sqhjz34gxrwvmslkq050h9f6dxalkwvbvnyvhmvf17";
rev = "ebe78bea13b60640816658ae798a199bd5118eb1";
sha256 = "0mzbqfc5kw4qa9hifjkzf3i1adz38g1lg9m6395y3bc6zry73dxp";
fetchSubmodules = false;
};
};