Compare commits

...

2 Commits

Author SHA1 Message Date
Trevor Vallender 83f68c0c44 LSP/Go improvements 2024-03-16 11:38:26 +00:00
Trevor Vallender 8080741d8f Move Treesitter config 2024-03-16 11:37:05 +00:00
7 changed files with 156 additions and 135 deletions

View File

@ -5,7 +5,6 @@ require('completion') -- Completion
require('lsp') -- LSP
require('remap') -- Keymaps
require('tree') -- Nvim-tree
require('treesitter') -- Treesitter
require('appearance') -- Appearance
require('telescope').setup{

View File

@ -8,24 +8,28 @@
"cmp-tmux": { "branch": "main", "commit": "95b1b921802e6f60627b3e76afb9380fddd87f9a" },
"cmp-treesitter": { "branch": "master", "commit": "13e4ef8f4dd5639fca2eb9150e68f47639a9b37d" },
"cmp_kitty": { "branch": "main", "commit": "a0716db2efb4c452600ef1e4a3ca610889279118" },
"codeium.vim": { "branch": "main", "commit": "f2d90dedb45e35f7563d2ce3a31c6928f79de678" },
"codeium.vim": { "branch": "main", "commit": "bef9cbaa5c19ab85d8048f364bfc0ac8c7ab335d" },
"git-messenger.vim": { "branch": "master", "commit": "8a61bdfa351d4df9a9118ee1d3f45edbed617072" },
"go.nvim": { "branch": "master", "commit": "9ac3e6faa32d01479973f4ca368d00b7ae328646" },
"gruvbox.nvim": { "branch": "main", "commit": "6e4027ae957cddf7b193adfaec4a8f9e03b4555f" },
"guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" },
"lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"lualine.nvim": { "branch": "master", "commit": "8b56462bfb746760465264de41b4907310f113ec" },
"lualine.nvim": { "branch": "master", "commit": "af4c3cf17206810880d2a93562e0a4c0d901c684" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "82c7cb08ddb836ad938b2708e50085f12a8825d2" },
"mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" },
"noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" },
"nui.nvim": { "branch": "main", "commit": "fbb139c6f14896b434d0229099e1acd863ae6bec" },
"nui.nvim": { "branch": "main", "commit": "3dc46d725f7b94bee5117c0a699b57b1902b5d65" },
"nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" },
"nvim-dap": { "branch": "master", "commit": "fc880e82059eb21c0fa896be60146e5f17680648" },
"nvim-dap": { "branch": "master", "commit": "c43c2473ecb482a9d91f32c1d4c0098fffad3c7d" },
"nvim-dap-ui": { "branch": "master", "commit": "9720eb5fa2f41988e8770f973cd11b76dd568a5d" },
"nvim-html-css": { "branch": "main", "commit": "c072b05c56a40d3ec7874fa487723e6bef5d97f8" },
"nvim-lspconfig": { "branch": "master", "commit": "7f5cf1121f772850a30bdaf83fb448e88846aa58" },
"nvim-tree.lua": { "branch": "master", "commit": "efafd73efa9bc8c26282aed563ba0f01c7465b06" },
"nvim-treesitter": { "branch": "master", "commit": "70f03829afa31f8b619b56296cdcaa921118d912" },
"nvim-lspconfig": { "branch": "master", "commit": "5b364bd4db0fb68a56ffe427a370920854acb834" },
"nvim-tree.lua": { "branch": "master", "commit": "f7c09bd72e50e1795bd3afb9e2a2b157b4bfb3c3" },
"nvim-treesitter": { "branch": "master", "commit": "f87882858438834d2fbb6379aa2be37de901751b" },
"nvim-treesitter-endwise": { "branch": "master", "commit": "60e8c288e011403f248b5f6478dde12bed8a6c55" },
"nvim-web-devicons": { "branch": "master", "commit": "4adea17610d140a99c313e3f79a9dc01825d59ae" },
"plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
"nvim-web-devicons": { "branch": "master", "commit": "cb0c967c9723a76ccb1be0cc3a9a10e577d2f6ec" },
"plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" },
"repl.nvim": { "branch": "master", "commit": "ec202eb5786b305c7d73b8cab5ee8fe69a2534a7" },
"telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" },
"vim-cool": { "branch": "master", "commit": "662e7b11064cbeedad17c45d2fe926e78d3cd0b6" },

View File

@ -1,84 +1,3 @@
-- textDocument/diagnostic support until 0.10.0 is released
_timers = {}
local function setup_diagnostics(client, buffer)
if require("vim.lsp.diagnostic")._enable then
return
end
local diagnostic_handler = function()
local params = vim.lsp.util.make_text_document_params(buffer)
client.request("textDocument/diagnostic", { textDocument = params }, function(err, result)
if err then
local err_msg = string.format("diagnostics error - %s", vim.inspect(err))
vim.lsp.log.error(err_msg)
end
local diagnostic_items = {}
if result then
diagnostic_items = result.items
end
vim.lsp.diagnostic.on_publish_diagnostics(
nil,
vim.tbl_extend("keep", params, { diagnostics = diagnostic_items }),
{ client_id = client.id }
)
end)
end
diagnostic_handler() -- to request diagnostics on buffer when first attaching
vim.api.nvim_buf_attach(buffer, false, {
on_lines = function()
if _timers[buffer] then
vim.fn.timer_stop(_timers[buffer])
end
_timers[buffer] = vim.fn.timer_start(200, diagnostic_handler)
end,
on_detach = function()
if _timers[buffer] then
vim.fn.timer_stop(_timers[buffer])
end
end,
})
end
-- adds ShowRubyDeps command to show dependencies in the quickfix list.
-- add the `all` argument to show indirect dependencies as well
local function add_ruby_deps_command(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, "ShowRubyDeps",
function(opts)
local params = vim.lsp.util.make_text_document_params()
local showAll = opts.args == "all"
client.request("rubyLsp/workspace/dependencies", params,
function(error, result)
if error then
print("Error showing deps: " .. error)
return
end
local qf_list = {}
for _, item in ipairs(result) do
if showAll or item.dependency then
table.insert(qf_list, {
text = string.format("%s (%s) - %s",
item.name,
item.version,
item.dependency),
filename = item.path
})
end
end
vim.fn.setqflist(qf_list)
vim.cmd('copen')
end, bufnr)
end, {nargs = "?", complete = function()
return {"all"}
end})
end
@ -86,38 +5,6 @@ end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
-- LSP servers
-- Stimulus
require'lspconfig'.stimulus_ls.setup{}
-- Ruby
require("lspconfig").ruby_ls.setup({
on_attach = function(client, buffer)
setup_diagnostics(client, buffer)
add_ruby_deps_command(client, buffer)
end,
})
-- CSS
require'lspconfig'.cssls.setup {
capabilities = capabilities,
}
-- SQL
require'lspconfig'.sqlls.setup{}
-- JavaScript
require'lspconfig'.eslint.setup{}
-- HTML
require'lspconfig'.html.setup {
capabilities = capabilities,
}
-- JSON
require'lspconfig'.jsonls.setup {
capabilities = capabilities,
}
-- BASH
require'lspconfig'.bashls.setup{}
-- Cucumber
require'lspconfig'.cucumber_language_server.setup{}
-- Docker
require'lspconfig'.dockerls.setup{}
require'lspconfig'local dap, dapui = require("dap"), require("dapui")
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()

View File

@ -1,12 +0,0 @@
-- Treesitter
require'nvim-treesitter.configs'.setup({
sync_install = false,
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
endwise = {
enable = true,
},
})

View File

@ -0,0 +1,14 @@
return {
"ray-x/go.nvim",
dependencies = { -- optional packages
"ray-x/guihua.lua",
"neovim/nvim-lspconfig",
"nvim-treesitter/nvim-treesitter",
},
config = function()
require("go").setup()
end,
event = {"CmdlineEnter"},
ft = {"go", 'gomod'},
build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries
}

View File

@ -1,6 +1,109 @@
return {
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
},
config = function()
-- textDocument/diagnostic support until 0.10.0 is released
_timers = {}
local function setup_diagnostics(client, buffer)
if require("vim.lsp.diagnostic")._enable then
return
end
local diagnostic_handler = function()
local params = vim.lsp.util.make_text_document_params(buffer)
client.request("textDocument/diagnostic", { textDocument = params }, function(err, result)
if err then
local err_msg = string.format("diagnostics error - %s", vim.inspect(err))
vim.lsp.log.error(err_msg)
end
local diagnostic_items = {}
if result then
diagnostic_items = result.items
end
vim.lsp.diagnostic.on_publish_diagnostics(
nil,
vim.tbl_extend("keep", params, { diagnostics = diagnostic_items }),
{ client_id = client.id }
)
end)
end
diagnostic_handler() -- to request diagnostics on buffer when first attaching
vim.api.nvim_buf_attach(buffer, false, {
on_lines = function()
if _timers[buffer] then
vim.fn.timer_stop(_timers[buffer])
end
_timers[buffer] = vim.fn.timer_start(200, diagnostic_handler)
end,
on_detach = function()
if _timers[buffer] then
vim.fn.timer_stop(_timers[buffer])
end
end,
})
end
-- adds ShowRubyDeps command to show dependencies in the quickfix list.
-- add the `all` argument to show indirect dependencies as well
local function add_ruby_deps_command(client, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, "ShowRubyDeps",
function(opts)
local params = vim.lsp.util.make_text_document_params()
local showAll = opts.args == "all"
client.request("rubyLsp/workspace/dependencies", params,
function(error, result)
if error then
print("Error showing deps: " .. error)
return
end
local qf_list = {}
for _, item in ipairs(result) do
if showAll or item.dependency then
table.insert(qf_list, {
text = string.format("%s (%s) - %s",
item.name,
item.version,
item.dependency),
filename = item.path
})
end
end
vim.fn.setqflist(qf_list)
vim.cmd('copen')
end, bufnr)
end, {nargs = "?", complete = function()
return {"all"}
end})
end
require("mason").setup()
require("mason-lspconfig").setup({
automatic_installation = true,
})
require("mason-lspconfig").setup_handlers({
function(server_name)
require("lspconfig")[server_name].setup({})
end,
["ruby_ls"] = function()
require("lspconfig").ruby_ls.setup({
on_attach = function(client, buffer)
setup_diagnostics(client, buffer)
add_ruby_deps_command(client, buffer)
end,
})
end
})
vim.keymap.set('n', '<leader>ld', function() vim.lsp.buf.definition() end, bufopts)
vim.keymap.set('n', '<leader>la', function() vim.lsp.buf.code_action() end, bufopts)
vim.keymap.set('n', '<leader>lK', vim.lsp.buf.signature_help, {})
vim.keymap.set('n', '<leader>lq', vim.diagnostic.setloclist, {})

View File

@ -1,4 +1,30 @@
return {
"nvim-treesitter/nvim-treesitter",
config = function()
require'nvim-treesitter.configs'.setup({
sync_install = false,
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
endwise = {
enable = true,
},
ensure_installed = {
"ruby",
"javascript",
"json",
"html",
"bash",
"css",
"go",
"dockerfile",
"lua",
"gitignore",
"yaml",
}
})
end
}