diff --git a/fnl/plugin.fnl b/fnl/plugin.fnl index 9566ec3..d9dcbde 100644 --- a/fnl/plugin.fnl +++ b/fnl/plugin.fnl @@ -16,9 +16,9 @@ (use! :nvim-treesitter/nvim-treesitter :config (setup! :nvim-treesitter.configs - :ensure_installed :all - :sync_install false - :auto_install true + ;:ensure_installed :all + ;:sync_install false + ;:auto_install true :highlight { :enable true :additional_vim_regex_highlighting false } :indent { :enable true })) @@ -39,12 +39,13 @@ (setup! :lualine :options { :section_separators "" :component_separators "│" } - :sections { :lualine_x [ - { 1 #(.. "recording @" (vim.fn.reg_recording)) - :cond #(not= (# (vim.fn.reg_recording)) 0) } - :encoding - :fileformat - :filetype ]})) + ; :sections { :lualine_x [ + ; { 1 #(.. "recording @" (vim.fn.reg_recording)) + ; :cond #(not= (# (vim.fn.reg_recording)) 0) } + ; :encoding + ; :fileformat + ; :filetype ]} + )) ;; bufferline.nvim (use! :akinsho/bufferline.nvim @@ -60,10 +61,64 @@ ;; telescope (a fuzzy finder) (use! :nvim-telescope/telescope.nvim - :requires [ :nvim-lua/plenary.nvim ] + :cmd :Telescope + :module :telescope + :requires [ { 1 :nvim-lua/plenary.nvim + :opt true } + { 1 :nvim-telescope/telescope-ui-select.nvim + :opt true } + { 1 :nvim-telescope/telescope-fzf-native.nvim + :opt true + :run :make }] + :setup + (bind! :n :fq "Telescope quickfix") + (bind! :n :fr "Telescope registers") + (bind! :n :fj "Telescope jumplist") + (bind! :n :fa "Telescope marks") + (bind! :n :fh "Telescope help_tags") + (bind! :n :g "Telescope live_grep") + (bind! :n :fg "Telescope live_grep") + (bind! :n :d "Telescope treesitter") + (bind! :n :b "Telescope buffers") + (bind! :n :fu "Telescope git_status") + (bind! :n :fm "Telescope man_pages") + (bind! :n :fe "Telescope diagnostics") + (bind! :n :fl "Telescope loclist") + (bind! :n :fp "Telescope spell_suggest") + (bind! :n :fo "Telescope vim_options") + (bind! :n :c "Telescope command_history") + (bind! :n :i "Telescope find_files") + (bind! :n :i "Telescope find_files") + (bind! :n :z= "Telescope spell_suggest") + (fn list-git-or-default [] + (let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")] + (if (= code 0) + (vim.cmd "Telescope git_files") + (vim.cmd "Telescope find_files")))) + (bind! :n :ff list-git-or-default) + (bind! :n :u list-git-or-default) + (fn jump-or-open-terminal [] + "If no terminal buffer exists, create one. Otherwise, open new one." + (var term_count 0) + (var last_id 0) + (var terms [ ]) + (each [_ id (pairs (vim.api.nvim_list_bufs))] + (let [name (vim.api.nvim_buf_get_name id)] + (when (vim.startswith name "term://") + (table.insert terms name) + (set term_count (+ term_count 1)) + (set last_id id)))) + (if (= term_count 0) + (vim.cmd.terminal) + (= term_count 1) + (vim.cmd.buffer last_id) + (vim.cmd "Telescope buffers default_text=\"term://\""))) + (bind! :n :t jump-or-open-terminal) :config - (let [builtin (require :telescope.builtin) - actions (require :telescope.actions)] + (vim.cmd "PackerLoad plenary.nvim") + (vim.cmd "PackerLoad telescope-ui-select.nvim") + (vim.cmd "PackerLoad telescope-fzf-native.nvim") + (let [actions (require :telescope.actions)] (setup! :telescope :defaults { :mappings { @@ -75,104 +130,14 @@ :pickers { :buffers { ;;:ignore_current_buffer true - :sort_lastused true }}) - (bind! :n :fq builtin.quickfix) - (bind! :n :fr builtin.registers) - (bind! :n :fj builtin.jumplist) - (bind! :n :fa builtin.marks) - (bind! :n :fh builtin.help_tags) - (bind! :n :g builtin.live_grep) - (bind! :n :fg builtin.live_grep) - (bind! :n :b builtin.buffers) - (bind! :n :gb builtin.buffers) - (bind! :n :fu builtin.git_status) - (bind! :n :fm builtin.man_pages) - (bind! :n :fe builtin.diagnostics) - (bind! :n :d builtin.loclist) - (bind! :n :fp builtin.spell_suggest) - (bind! :n :i builtin.find_files) - (bind! :n :z= builtin.spell_suggest) - (fn list-git-or-default [] - (let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")] - (if (= code 0) - (builtin.git_files) - (builtin.find_files)))) - (bind! :n :ff list-git-or-default) - (bind! :n :u list-git-or-default) - (fn jump-or-open-terminal [] - "If no terminal buffer exists, create one. Otherwise, open new one." - (var term_count 0) - (var last_id 0) - (var terms [ ]) - (each [_ id (pairs (vim.api.nvim_list_bufs))] - (let [name (vim.api.nvim_buf_get_name id)] - (when (vim.startswith name "term://") - (table.insert terms name) - (set term_count (+ term_count 1)) - (set last_id id)))) - (if (= term_count 0) - (vim.cmd.terminal) - (= term_count 1) - (vim.cmd.buffer last_id) - (builtin.buffers { :default_text "term://" }))) - (bind! :n :t jump-or-open-terminal))) - - ;; dressing.nvim nicer vim.ui stuff - (use! :stevearc/dressing.nvim - :after :telescope.nvim - :config - (setup! :dressing)) - - ;; fzf (a fuzzy finder) - ;(use! :ibhagwan/fzf-lua - ; :cmd :FzfLua - ; :setup - ; (bind! :n :fq "FzfLua quickfix") - ; (bind! :n :fr "FzfLua registers") - ; (bind! :n :fj "FzfLua jumps") - ; (bind! :n :fa "FzfLua marks") - ; (bind! :n :fh "FzfLua help_tags") - ; (bind! :n :g "FzfLua live_grep") - ; (bind! :n :fg "FzfLua live_grep") - ; (bind! :n :G "FzfLua grep") - ; (bind! :n :fG "FzfLua grep") - ; (bind! :n :b "FzfLua buffers") - ; (bind! :n :gb "FzfLua buffers") - ; (bind! :n :fu "FzfLua git_status") - ; (bind! :n :fm "FzfLua man_pages") - ; (bind! :n :fe "FzfLua diagnostics_document") - ; (bind! :n :fE "FzfLua diagnostics_workspace") - ; (bind! :n :d "FzfLua loclist") - ; (bind! :n :fp "FzfLua spell_suggest") - ; (bind! :n :i "FzfLua files") - ; (bind! :n :z= "FzfLua spell_suggest") - ; (fn list-git-or-default [] - ; (let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")] - ; (if (= code 0) - ; (vim.cmd "FzfLua git_files") - ; (vim.cmd "FzfLua files")))) - ; (bind! :n :ff list-git-or-default) - ; (bind! :n :u list-git-or-default) - ; (fn jump-or-open-terminal [] - ; "If no terminal buffer exists, create one. Otherwise, open new one." - ; (var term_count 0) - ; (var last_id 0) - ; (var terms [ ]) - ; (each [_ id (pairs (vim.api.nvim_list_bufs))] - ; (let [name (vim.api.nvim_buf_get_name id)] - ; (when (vim.startswith name "term://") - ; (table.insert terms name) - ; (set term_count (+ term_count 1)) - ; (set last_id id)))) - ; (if (= term_count 0) - ; (vim.cmd.terminal) - ; (= term_count 1) - ; (vim.cmd.buffer last_id) - ; (vim.cmd "FzfLua buffers query=term://"))) - ; (bind! :n :t jump-or-open-terminal) - ; :config - ; (let [fzf (require :fzf-lua)] - ; (fzf.register_ui_select))) + :sort_lastused true }} + :extensions { + :ui-select [ + (module-call! :telescope.themes :get_dropdown) + ] + }) + (module-call! :telescope :load_extension :ui-select) + (module-call! :telescope :load_extension :fzf))) ;; Nvim surround (use! :kylechui/nvim-surround @@ -202,6 +167,7 @@ ;; Comment.nvim (use! :numToStr/Comment.nvim + :keys [ :gc :gb ] :config (setup! :Comment)) @@ -277,7 +243,7 @@ (bind! :n :ci "IconPickerNormal") (bind! :n :cy "IconPickerYank") :config - ;;(vim.cmd "PackerLoad fzf-lua") + (vim.cmd "PackerLoad telescope.nvim") (setup! :icon-picker :disable_legacy_commands true)) @@ -296,6 +262,7 @@ :cmd [ :Format :FormatWrite ] :setup (bind! :n :o "Format") + (bind! :x :o ":Format") :config (setup! :formatter :logging true @@ -335,6 +302,7 @@ ;; nvim-jdtls (use! :mfussenegger/nvim-jdtls + :ft :java :after :nvim-lspconfig :config (module-call! :plugin.jdtls :configure)) diff --git a/fnl/plugin/lsp.fnl b/fnl/plugin/lsp.fnl index a2a053d..3addbee 100644 --- a/fnl/plugin/lsp.fnl +++ b/fnl/plugin/lsp.fnl @@ -2,47 +2,40 @@ (import-macros {: bind!} :macros) -(fn on-attach [_ buf] +(fn on-attach [client buf] ((. (. (require :cmp) :setup) :buffer) { :sources [{ :name "nvim_lsp" :priority 1 :group 1 } { :name "snippy" :priority 1 :group 2 } { :name "buffer" :priority 0 :group 3 } { :name "path" :priority 0 :group 4 }]}) (bind! :n :gD vim.lsp.buf.declaration buf) - ;; (bind! :n :gd vim.lsp.buf.definition buf) + ; (bind! :n :gd vim.lsp.buf.definition buf) (bind! :n :K vim.lsp.buf.hover buf) - ;; (bind! :n :gI vim.lsp.buf.implementation buf) + ; (bind! :n :gI vim.lsp.buf.implementation buf) (bind! :n : vim.lsp.buf.signature_help buf) (bind! :n :wa vim.lsp.buf.add_workspace_folder buf) (bind! :n :wr vim.lsp.buf.remove_workspace_folder buf) (bind! :n :wl #(print (vim.inspect (vim.lsp.buf.list_workspace_folders))) buf) - (bind! :n :D vim.lsp.buf.type_definition buf) + ; (bind! :n :D vim.lsp.buf.type_definition buf) (bind! :n :rn vim.lsp.buf.rename buf) (bind! :n :cn vim.lsp.buf.code_action buf) ; (bind! :n :gr vim.lsp.buf.references buf) - ; (bind! :n :o #(vim.lsp.buf.format { :async true }) buf) - - ;; Some fzf commands - ;(bind! :n :gr "FzfLua lsp_references" buf) - ;(bind! :n :s "FzfLua lsp_live_workspace_symbols" buf) - ;(bind! :n :fs "FzfLua lsp_live_workspace_symbols" buf) - ;(bind! :n :fS "FzfLua lsp_workspace_symbols" buf) - ;(bind! :n :d "FzfLua lsp_document_symbols" buf) - ;(bind! :n :fd "FzfLua lsp_document_symbols" buf) - ;(bind! :n :cn "FzfLua lsp_code_actions" buf) + ;(when client.server_capabilities.documentFormattingProvider + ; (bind! :n :o #(vim.lsp.buf.format { :async true }) buf)) ;; Some telescope commands - (let [builtin (require :telescope.builtin)] - (bind! :n :gr builtin.lsp_references buf) - (bind! :n :s builtin.lsp_live_workspace_symbols buf) - (bind! :n :fs builtin.lsp_live_workspace_symbols buf) - (bind! :n :fS builtin.lsp_workspace_symbols buf) - (bind! :n :d builtin.lsp_document_symbols buf) - (bind! :n :fd builtin.lsp_document_symbols buf) - (bind! :n :cn builtin.lsp_code_actions buf) - (bind! :n :gd vim.lsp.buf.definition buf) - (bind! :n :gI vim.lsp.buf.implementation buf))) + (bind! :n :s "Telescope lsp_dynamic_workspace_symbols" buf) + (bind! :n :fs "Telescope lsp_dynamic_workspace_symbols" buf) + (bind! :n :fS "Telescope lsp_workspace_symbols" buf) + ;(print (vim.inspect client.server_capabilities)) + (when client.server_capabilities.documentSymbolProvider + (bind! :n :d "Telescope lsp_document_symbols" buf) + (bind! :n :fd "Telescope lsp_document_symbols" buf)) + (bind! :n :gr "Telescope lsp_references" buf) + (bind! :n :gd "Telescope lsp_definitions" buf) + (bind! :n :gI "Telescope lsp_implementations" buf) + (bind! :n :D "Telescope lsp_type_definitions" buf)) (fn get-data-dir [server root]