From 3a876275819358a07e7b28e9f2c894ddcc421496 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sun, 14 May 2023 18:30:12 -0700 Subject: [PATCH] Fix null-ls keybinds --- fnl/plugin/lsp.fnl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fnl/plugin/lsp.fnl b/fnl/plugin/lsp.fnl index 80dea09..5ddc2ee 100644 --- a/fnl/plugin/lsp.fnl +++ b/fnl/plugin/lsp.fnl @@ -29,6 +29,9 @@ (= client.name :rust_analyzer))) :async true }) buf) + ;; Use builtin formatexpr + (vim.api.nvim_buf_set_option buf :formatexpr "") + ;; Some telescope commands (bind! :n :s "Telescope lsp_dynamic_workspace_symbols" buf) (bind! :n :fs "Telescope lsp_dynamic_workspace_symbols" buf) @@ -111,6 +114,15 @@ (fn setup-null-ls [] (let [builtins (. (require :null-ls) :builtins)] (setup! :null-ls + :on_attach (fn [client buf] + (bind! [ :n :v ] :o + #(vim.lsp.buf.format { :filter + ;; use null-ls for formatting + (fn [client] (or + (= client.name :null-ls) + (= client.name :rust_analyzer))) + :async true }) buf) + (vim.api.nvim_buf_set_option buf :formatexpr "")) :sources [ builtins.formatting.astyle builtins.formatting.prettier