Skip to content

Commit

Permalink
move stuff and stuff and stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
mosheavni committed Jan 1, 2025
1 parent 36e76b1 commit 649700e
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 298 deletions.
16 changes: 15 additions & 1 deletion nvim/.config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@ local M = {
event = { 'BufReadPre', 'BufNewFile' },
}

M.init = require('user.lsp.config').init
M.init = function()
_G.start_ls = function()
local ft = vim.api.nvim_get_option_value('filetype', { buf = 0 })
local file_name = _G.tmp_write { should_delete = false, new = false, ft = ft }
-- load lsp
require 'lspconfig'
return file_name
end
vim.keymap.set('n', '<leader>ls', _G.start_ls)
require('user.menu').add_actions('LSP', {
['Start LSP (<leader>ls)'] = function()
_G.start_ls()
end,
})
end

M.config = require('user.lsp.config').setup

Expand Down
2 changes: 0 additions & 2 deletions nvim/.config/nvim/lua/plugins/null-ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ local M = {
}
M.config = function()
local null_ls = require 'null-ls'
local default_on_attach = require('user.lsp.on-attach').default

-- null-ls
null_ls.setup {
on_attach = default_on_attach,
debug = true,
sources = {
null_ls.builtins.code_actions.gitsigns,
Expand Down
94 changes: 46 additions & 48 deletions nvim/.config/nvim/lua/user/lsp/config.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
local M = {
diagnostic_signs = {
[vim.diagnostic.severity.ERROR] = '',
[vim.diagnostic.severity.WARN] = '',
[vim.diagnostic.severity.HINT] = '',
[vim.diagnostic.severity.INFO] = '',
},
capabilities = {
textDocument = {
completion = {
Expand All @@ -14,28 +20,17 @@ local M = {
},
}

M.setup_capabilities = function()
------------------
-- Capabilities --
------------------
local cmp_default_capabilities = require('cmp_nvim_lsp').default_capabilities()
-- local cmp_default_capabilities = require('blink.cmp').get_lsp_capabilities()
M.setup = function()
require('user.lsp.actions').setup()

M.capabilities = vim.tbl_deep_extend('force', vim.lsp.protocol.make_client_capabilities(), cmp_default_capabilities, M.capabilities or {}, {})
end
-- Set formatting of lsp log
require('vim.lsp.log').set_format_func(vim.inspect)

M.diagnostic_signs = {
[vim.diagnostic.severity.ERROR] = '',
[vim.diagnostic.severity.WARN] = '',
[vim.diagnostic.severity.HINT] = '',
[vim.diagnostic.severity.INFO] = '',
}
-- set up capabilities
local cmp_default_capabilities = require('cmp_nvim_lsp').default_capabilities()
M.capabilities = vim.tbl_deep_extend('force', vim.lsp.protocol.make_client_capabilities(), cmp_default_capabilities, M.capabilities or {}, {})

M.diagnostics = function()
-----------------
-- Diagnostics --
-----------------
-- show icons in the sidebar
-- Diagnostics
vim.diagnostic.config {
jump = { float = true },
signs = { text = M.diagnostic_signs },
Expand All @@ -45,41 +40,44 @@ M.diagnostics = function()
},
float = { border = 'rounded' },
}
end

M.init = function()
_G.start_ls = function()
local ft = vim.api.nvim_get_option_value('filetype', { buf = 0 })
local file_name = _G.tmp_write { should_delete = false, new = false, ft = ft }
-- load lsp
require 'lspconfig'
return file_name
end
vim.keymap.set('n', '<leader>ls', _G.start_ls)
require('user.menu').add_actions('LSP', {
['Start LSP (<leader>ls)'] = function()
_G.start_ls()
end,
})
end

M.setup = function()
require('user.lsp.actions').setup()

-- Set formatting of lsp log
require('vim.lsp.log').set_format_func(vim.inspect)

-- set up capabilities
M.setup_capabilities()

-- set up diagnostics configuration
M.diagnostics()

-- set up mason to install lsp servers
require('mason-lspconfig').setup { automatic_installation = true }

-- setup lsp servers
require('user.lsp.servers').setup()

-- on attach
local on_attach_aug = vim.api.nvim_create_augroup('UserLspAttach', { clear = true })
vim.api.nvim_create_autocmd('LspAttach', {
group = on_attach_aug,
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
local bufnr = ev.buf
require 'user.lsp.keymaps'(bufnr)
if client and client.server_capabilities.documentSymbolProvider then
require('nvim-navic').attach(client, bufnr)
end

-- if client.server_capabilities.code_lens then
-- autocmd({ 'BufEnter', 'InsertLeave', 'InsertEnter' }, {
-- desc = 'Auto show code lenses',
-- group = on_attach_aug,
-- buffer = bufnr,
-- command = 'silent! lua vim.lsp.codelens.refresh({bufnr=' .. bufnr .. '})',
-- })
-- end
-- if client.server_capabilities.document_highlight then
-- -- Highlight text at cursor position
-- vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
-- desc = 'Highlight references to current symbol under cursor',
-- group = on_attach_aug,
-- buffer = bufnr,
-- command = 'silent! lua vim.lsp.buf.document_highlight()',
-- })
-- end
end,
})
end

return M
97 changes: 0 additions & 97 deletions nvim/.config/nvim/lua/user/lsp/formatting.lua

This file was deleted.

71 changes: 0 additions & 71 deletions nvim/.config/nvim/lua/user/lsp/on-attach.lua

This file was deleted.

Loading

0 comments on commit 649700e

Please sign in to comment.