]> git.huck.website - nvim.git/commitdiff
fix: lsp - treesitter integration
authorHuck Boles <huck@huck.website>
Wed, 17 May 2023 14:03:41 +0000 (09:03 -0500)
committerHuck Boles <huck@huck.website>
Wed, 17 May 2023 14:03:41 +0000 (09:03 -0500)
lua/huck/functions.lua
lua/plugins/lsp.lua
lua/plugins/telescope.lua
lua/plugins/treesitter.lua

index cbf591537a712ccb52c814d1c87446d3c3a022c9..235bbd50264c83d31939b9acb059585dc886fe34 100644 (file)
@@ -31,11 +31,3 @@ vim.api.nvim_create_autocmd("BufNewFile", {
         end
     end,
 })
-
--- auto format code on save
-vim.api.nvim_create_autocmd("BufWritePre", {
-    pattern = { "*" },
-    callback = function()
-        vim.lsp.buf.format()
-    end,
-})
index e2149d615d4697e98e2a432b9ea69cf73cb28eac..01da9922f0527d06c5bd1496b443769969c0cd02 100644 (file)
@@ -3,6 +3,7 @@ return {
         "jose-elias-alvarez/null-ls.nvim",
         dependencies = {
             "plenary.nvim",
+            "nvim-treesitter",
             {
                 "jay-babu/mason-null-ls.nvim",
                 dependencies = { "mason.nvim" },
@@ -46,6 +47,7 @@ return {
     {
         "williamboman/mason-lspconfig",
         dependencies = {
+            "nvim-treesitter",
             {
                 "williamboman/mason.nvim",
                 build = ":MasonUpdate",
@@ -75,6 +77,7 @@ return {
             "Maan2003/lsp_lines.nvim",
         },
         config = function()
+            -- servers to setup
             local lsp = require("lspconfig")
             lsp.awk_ls.setup({})
             lsp.bashls.setup({})
@@ -87,22 +90,11 @@ return {
             lsp.lua_ls.setup({})
             lsp.marksman.setup({})
             lsp.solargraph.setup({})
-            -- lsp.sorbet.setup({})
             lsp.rust_analyzer.setup({})
             lsp.taplo.setup({})
             lsp.yamlls.setup({})
 
-            local border = {
-                { "┏", "FloatBorder" },
-                { "━", "FloatBorder" },
-                { "┓", "FloatBorder" },
-                { "┃", "FloatBorder" },
-                { "┛", "FloatBorder" },
-                { "━", "FloatBorder" },
-                { "┗", "FloatBorder" },
-                { "┃", "FloatBorder" },
-            }
-
+            -- diagnostic settings
             vim.lsp.diagnostics = {
                 signs = true,
                 underline = true,
@@ -110,18 +102,39 @@ return {
                 severity_sort = { reverse = false },
             }
 
+            -- custom signs
             local signs = { Error = ">>", Warn = "> ", Hint = "- ", Info = "  " }
             for type, icon in pairs(signs) do
                 local hl = "DiagnosticSign" .. type
                 vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
             end
 
+            -- borders on windows
+            local border = {
+                { "┏", "FloatBorder" },
+                { "━", "FloatBorder" },
+                { "┓", "FloatBorder" },
+                { "┃", "FloatBorder" },
+                { "┛", "FloatBorder" },
+                { "━", "FloatBorder" },
+                { "┗", "FloatBorder" },
+                { "┃", "FloatBorder" },
+            }
+
             local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
             function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
                 opts = opts or {}
                 opts.border = opts.border or border
                 return orig_util_open_floating_preview(contents, syntax, opts, ...)
             end
+
+            -- auto format code on save
+            vim.api.nvim_create_autocmd("BufWritePre", {
+                pattern = { "*" },
+                callback = function()
+                    vim.lsp.buf.format()
+                end,
+            })
         end,
     },
 }
index fe1ef0ca87b5963df668f7738f81ca3201083baa..625b3f83243eacb499b89ad9935d395fd1ba6a08 100644 (file)
@@ -39,6 +39,33 @@ return {
             }
 
             require('telescope').load_extension('fzf')
+
+            -- give telescope window if opened with no command
+            vim.api.nvim_create_autocmd('VimEnter', {
+                pattern = '*',
+                callback = function()
+                local arg = vim.api.nvim_eval('argv(0)')
+                if arg and (vim.fn.isdirectory(arg) ~= 0 or arg == "") then
+                    vim.defer_fn(function()
+                        local function is_git_repo()
+                            vim.fn.system("git rev-parse --is-inside-work-tree")
+                            return vim.v.shell_error == 0
+                        end
+                        local function get_git_root()
+                            local dot_git_path = vim.fn.finddir(".git", ".;")
+                            return vim.fn.fnamemodify(dot_git_path, ":h")
+                        end
+                        local opts = {}
+                        if is_git_repo() then
+                            opts = {
+                                cwd = get_git_root(),
+                            }
+                        end
+                        require("telescope.builtin").find_files(opts)
+                    end, 10)
+                end
+                end
+            })
         end
     },
 }
index b87674f529e4e47d52b145adabf0cf9db96d08a6..12fa5899cd14b1da2b3733318ce042eb93a865fa 100644 (file)
@@ -10,7 +10,7 @@ return {
                 sync_install = true,
                 auto_install = true,
                 highlight = { enable = true },
-                indent = { enable = true },
+                indent = { enable = false },
             }
         end
     },