diff --git a/.editorconfig b/.editorconfig index 740aa28..4899cdc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,14 +1,15 @@ -[*.lua] -# [basic] - +[*] # optional space/tab indent_style = space # if indent_style is space, this is valid -indent_size = 4 +indent_size = 2 # if indent_style is tab, this is valid -tab_width = 4 +tab_width = 2 # none/single/double -quote_style = none +quote_style = double + +[*.lua] +# [basic] continuation_indent = 4 diff --git a/fnl/lazy-setup.fnl b/fnl/lazy-setup.fnl index 0792784..a8d2b76 100644 --- a/fnl/lazy-setup.fnl +++ b/fnl/lazy-setup.fnl @@ -1,76 +1,34 @@ -(local lazypath (.. (vim.fn.stdpath "data") "/lazy/lazy.nvim")) - -(if (not (vim.loop.fs_stat lazypath)) - (vim.fn.system - ["git" - "clone" - "--filter=blob:none" - "https://github.com/folke/lazy.nvim.git" - "--branch=stable" - lazypath])) +(let [lazypath (.. (vim.fn.stdpath "data") "/lazy/lazy.nvim")] + (if (not (vim.loop.fs_stat lazypath)) + (vim.fn.system + ["git" + "clone" + "--filter=blob:none" + "https://github.com/folke/lazy.nvim.git" + "--branch=stable" + lazypath])) + (vim.opt.rtp:prepend lazypath)) (let [lazy (require :lazy)] (lazy.setup ["https://github.com/rktjmp/hotpot.nvim" {:url "https://github.com/nvim-telescope/telescope.nvim" - :tag "0.1.2" - :dependencies ["nvim-lua/plenary.nvim"]} + :tag "0.1.2" + :dependencies ["nvim-lua/plenary.nvim"]} {:url "https://github.com/nvim-telescope/telescope-fzf-native.nvim" - :build (.. "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release" - " && cmake --build build --config Release" - " && cmake --install build --prefix build" )} - ;; TODO LSP configurations... - ;; {:url "https://github.com/neovim/nvim-lspconfig" - ;; :dependencies - ;; ["https://github.com/williamboman/mason.nvim" - ;; "williamboman/mason-lspconfig.nvim" - ;; {:url "https://github.com/j-hui/fidget.nvim" - ;; :tag "legacy" - ;; :opts {}} ; NOTE: `opts = {}` is the same as calling `require("fidget").setup({})` - ;; "folke/neodev.nvim"]} + :build (.. "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release" + " && cmake --build build --config Release" + " && cmake --install build --prefix build" )} + {:url "https://github.com/neovim/nvim-lspconfig" + :dependencies + ["https://github.com/williamboman/mason.nvim" + "williamboman/mason-lspconfig.nvim" + {:url "https://github.com/j-hui/fidget.nvim" + :tag "legacy" + :opts {}} + "folke/neodev.nvim" + ]} ])) (let [telescope (require "telescope")] (pcall (telescope.load_extension :fzf))) - -;; TODO fix LSP stuff... -;; (let [neodev (require :neodev)] -;; (neodev.setup)) - -;; TODO mason can't find the modules it installs... -;; (let -;; [mason (require :mason) -;; mason-lspconfig (require :mason-lspconfig) -;; servers -;; {:lua_ls { -;; :Lua { -;; :workspace { :checkThirdParty false } -;; :telemetry { :enable false }}} -;; :fennel_language_server {} -;; :bash_language_server {} -;; :jq {} -;; } -;; on_attach (fn [_ bufnr] -;; (let -;; [nmap #(vim.keymap.set :n $1 $2 {:buffer bufnr :desc (.. "LSP: " $3)}) -;; telescope (require :telescope.builtin) -;; ] -;; (nmap :gd vim.lsp.buf.definition "[G]o to [D]efiniton") -;; (nmap :gr telescope.lsp_references "[G]o to [R]eferences") -;; (nmap :gI vim.lsp.buf.implementation "[G]o to [I]mplementation") -;; (vim.api.nvim_buf_create_user_command bufnr "Format" #(vim.lsp.buf.format) -;; "Format current buffer with LSP"))) -;; ] -;; (mason.setup) -;; (mason-lspconfig.setup) -;; (mason-lspconfig.setup_handlers -;; [(fn [server_name] (let -;; [server (require server_name) -;; settings (. servers server_name) -;; filetypes (or settings.filetypes []) -;; ] -;; (server.setup {:capabilities (vim.lsp.protocol.make_client_capabilities) -;; :on_attach on_attach -;; :settings settings -;; :filetypes filetypes}))) -;; ])) diff --git a/init.lua b/init.lua index 906b557..f14bcbf 100644 --- a/init.lua +++ b/init.lua @@ -1,13 +1,49 @@ local hotpot_path = vim.fn.stdpath('data') .. '/lazy/hotpot.nvim' - -vim.opt.rtp:prepend(hotpot_path) - if vim.fn.empty(vim.fn.glob(hotpot_path)) > 0 then print("Could not find hotpot.nvim, cloning new copy to", hotpot_path) vim.fn.system({'git', 'clone', 'https://github.com/rktjmp/hotpot.nvim', hotpot_path}) vim.cmd("helptags " .. hotpot_path .. "/doc") end +vim.opt.rtp:prepend(hotpot_path) require("hotpot") require("init") + +local servers = + {lua_ls = {Lua = {workspace = {checkThirdParty = false}, telemetry = {enable = false}}} + -- TODO :fennel_language_server {} + -- TODO :bash_language_server {} + -- TODO :jq {} + } + +local on_attach = function (_, bufnr) + local nmap = function (keys, fn, desc) + vim.keymap.set(keys, fn, {buffer = bufnr, desc = desc}) + end + local telescope = require("telescope.builtin") + + nmap("gd", vim.lsp.buf.definition, "[G]o to [D]efiniton") + nmap("gr", telescope.lsp_references, "[G]o to [R]eferences") + nmap("gI", vim.lsp.buf.implementation, "[G]o to [I]mplementation") + vim.api.nvim_buf_create_user_command(bufnr, "Format", function () + vim.lsp.buf.format() + end, "Format current buffer with LSP") +end + +require("neodev").setup() +require("mason").setup() + +local mason_lspconfig = require("mason-lspconfig") +mason_lspconfig.setup({ensure_installed = vim.tbl_keys(servers)}) +mason_lspconfig.setup_handlers({ + function (server_name) + local server = require(server_name) + server.setup({ + capabilities = vim.lsp.protocol.make_client_capabilities(), + on_attach = on_attach, + settings = servers[server_name], + filetypes = (servers[server_name] or {}).filetypes, + }) + end +}) diff --git a/lazy-lock.json b/lazy-lock.json index 035c33c..2e2ab84 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,12 +1,13 @@ { + "editorconfig.nvim": { "branch": "master", "commit": "5b9e303e1d6f7abfe616ce4cc8d3fffc554790bf" }, "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, "hotpot.nvim": { "branch": "master", "commit": "026eba9596b506ab6f807fd4aa93cd5f76255725" }, "lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "e86a4c84ff35240639643ffed56ee1c4d55f538e" }, "mason.nvim": { "branch": "main", "commit": "fe9e34a9ab4d64321cdc3ecab4ea1809239bb73f" }, - "neodev.nvim": { "branch": "main", "commit": "866b6b6e687a93ba98851a03a74bf6d9211b7299" }, + "neodev.nvim": { "branch": "main", "commit": "f57e5210d450b47aa02ea6d9e50a37414f570b4c" }, "nvim-lspconfig": { "branch": "master", "commit": "b6091272422bb0fbd729f7f5d17a56d37499c54f" }, "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, - "telescope.nvim": { "branch": "master", "commit": "1228f3b15ca3d9b95dcb92efda6a3448871030bd" } + "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" } } \ No newline at end of file