Skip to content

Commit

Permalink
Migrate Lsp -> no more zero
Browse files Browse the repository at this point in the history
  • Loading branch information
TechDufus committed Dec 4, 2024
1 parent bfb854b commit 55ebfbb
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 148 deletions.
22 changes: 6 additions & 16 deletions roles/neovim/files/lua/plugins/avante.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,39 @@ return {
lazy = false,
version = false, -- set this if you want to always pull the latest change
opts = {
-- add any opts here
provider = "copilot",
-- auto_suggestions_provider = "copilot",
-- openai = {
-- model = "gpt-4o-mini",
-- }
auto_suggestions_provider = "copilot",
windows = {
input = {
prefix = ""
},
},
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
build = "make",
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
build = "make", -- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
dependencies = {
"nvim-treesitter/nvim-treesitter",
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
--- The below dependencies are optional,
-- The below dependencies are optional
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
"zbirenbaum/copilot.lua", -- for providers='copilot'
{
-- support for image pasting
"HakonHarnes/img-clip.nvim",
"HakonHarnes/img-clip.nvim", -- support for image pasting
event = "VeryLazy",
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
use_absolute_path = true, -- required for Windows users
},
},
},
{
-- Make sure to set this up properly if you have lazy=true
'MeanderingProgrammer/render-markdown.nvim',
'MeanderingProgrammer/render-markdown.nvim', -- Make sure to set this up properly if you have lazy=true
opts = {
file_types = { "markdown", "Avante" },
},
Expand Down
12 changes: 0 additions & 12 deletions roles/neovim/files/lua/plugins/chatgpt.lua

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,128 +1,15 @@
return {
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x',
'williamboman/mason.nvim',
lazy = false,
dependencies = {
-- LSP Support
{ 'neovim/nvim-lspconfig' }, -- Required
{
-- Optional
'williamboman/mason.nvim',
build = ":MasonUpdate",
},
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional

-- Autocompletion
{ 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'L3MON4D3/LuaSnip' }, -- Required
opts = {},
},

{ 'onsails/lspkind.nvim' },
},
-- Autocompletion
{
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
config = function()
-- LSP servers and clients are able to communicate to each other what features they support.
-- By default, Neovim doesn't support everything that is in the LSP Specification.
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
-- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())

require('mason.settings').set({
ui = {
border = 'rounded'
}
})
local lsp = require('lsp-zero').preset("recommended")

require('mason').setup({})
require('mason-lspconfig').setup({
ensure_installed = {
'gopls',
'ansiblels',
'bashls',
'dockerls',
'jsonls',
'powershell_es',
'solargraph',
'terraformls',
'lua_ls',
'yamlls',
'cssls',
'gopls',
'jsonls',
'lua_ls',
'pylsp',
},
handlers = {
-- this first function is the "default handler"
-- it applies to every language server without a "custom handler"
function(server_name)
require('lspconfig')[server_name].setup({})
end,
}
})

lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({ buffer = bufnr })
end)

-- require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
require('lspconfig').lua_ls.setup({
settings = {
Lua = {
diagnostics = {
globals = { 'vim', 'hs', 'spoon' },
disable = { 'lowercase-global' },
},
},
},
})

-- ansiblels disable settings
require('lspconfig').ansiblels.setup({
settings = {
ansible = {
diagnostics = {
disable = { 'name[template]' }
},
},
},
})

-- lsp.skip_server_setup({ 'gopls' })
-- the function below will be executed whenever
-- a language server is attached to a buffer
lsp.on_attach(function(client, bufnr)
local noremap = { buffer = bufnr, remap = false }
local bind = vim.keymap.set

bind('n', '<leader>r', '<cmd>lua vim.lsp.buf.rename()<cr>', noremap)
-- Mappings.
bind('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', noremap)
bind('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', noremap)
bind('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', noremap)
bind('n', 'gi', '<cmd>lua require("telescope.builtin").lsp_implementations()<CR>', noremap)
bind('n', 'gt', '<cmd>lua require("telescope.builtin").lsp_type_definitions()<CR>', noremap)
bind('n', '<Leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', noremap)
bind('n', '<Leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', noremap)
bind('n', 'gr', '<cmd>lua require("telescope.builtin").lsp_references()<CR>', noremap)
bind('n', '<Leader>dl', '<cmd>Telescope diagnostics<CR>', noremap)
bind('n', '<Leader>ld', '<cmd>lua vim.diagnostic.open_float()<CR>', noremap)
bind('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', noremap)
bind('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', noremap)
bind('n', '<Leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', noremap)
bind("n", "<Leader>f", "<cmd>lua vim.lsp.buf.format({ async = true })<CR>", noremap)
-- if client is gopls then define bindings
if client.name == 'gopls' then
bind("n", "<Leader>gtf", "<cmd>GoTestFile<CR>", noremap)
bind("n", "<Leader>gtff", "<cmd>GoTestFunc<CR>", noremap)
bind("n", "<Leader>gtt", "<cmd>GoTest<CR>", noremap)
bind("n", "<Leader>gta", "<cmd>GoTestAll<CR>", noremap)
end
end)
lsp.setup()

-- cmp icons
local cmp = require('cmp')
local icons = require('techdufus.core.icons')
Expand Down Expand Up @@ -248,6 +135,111 @@ return {
end
},

-- LSP
{
'neovim/nvim-lspconfig',
cmd = { 'LspInfo', 'LspInstall', 'LspStart' },
event = { 'BufReadPre', 'BufNewFile' },
dependencies = {
{ 'hrsh7th/cmp-nvim-lsp' },
{ 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' },
},
config = function()
local lsp_defaults = require('lspconfig').util.default_config

-- Add cmp_nvim_lsp capabilities settings to lspconfig
-- This should be executed before you configure any language server
lsp_defaults.capabilities = vim.tbl_deep_extend(
'force',
lsp_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
)

-- LspAttach is where you enable features that only work
-- if there is a language server active in the file
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function(event)
local noremap = { buffer = event.buf, remap = false }
local bind = vim.keymap.set

bind('n', '<leader>r', '<cmd>lua vim.lsp.buf.rename()<cr>', noremap)
-- Mappings.
bind('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', noremap)
bind('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', noremap)
bind('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', noremap)
bind('n', 'gi', '<cmd>lua require("telescope.builtin").lsp_implementations()<CR>', noremap)
bind('n', 'gt', '<cmd>lua require("telescope.builtin").lsp_type_definitions()<CR>', noremap)
bind('n', '<Leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', noremap)
bind('n', '<Leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', noremap)
bind('n', 'gr', '<cmd>lua require("telescope.builtin").lsp_references()<CR>', noremap)
bind('n', '<Leader>dl', '<cmd>Telescope diagnostics<CR>', noremap)
bind('n', '<Leader>ld', '<cmd>lua vim.diagnostic.open_float()<CR>', noremap)
bind('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', noremap)
bind('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', noremap)
bind('n', '<Leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', noremap)
bind("n", "<Leader>f", "<cmd>lua vim.lsp.buf.format({ async = true })<CR>", noremap)
-- if client is gopls then define bindings
if vim.lsp.get_client_by_id() == 'gopls' then
bind("n", "<Leader>gtf", "<cmd>GoTestFile<CR>", noremap)
bind("n", "<Leader>gtff", "<cmd>GoTestFunc<CR>", noremap)
bind("n", "<Leader>gtt", "<cmd>GoTest<CR>", noremap)
bind("n", "<Leader>gta", "<cmd>GoTestAll<CR>", noremap)
end
end,
})


require('mason-lspconfig').setup({
ensure_installed = {
'gopls',
'ansiblels',
'bashls',
'dockerls',
'jsonls',
'powershell_es',
'solargraph',
'terraformls',
'lua_ls',
'yamlls',
'cssls',
'gopls',
'jsonls',
'lua_ls',
'pylsp',
},
handlers = {
-- this first function is the "default handler"
-- it applies to every language server without a "custom handler"
function(server_name)
require('lspconfig')[server_name].setup({})
end,
}
})
require('lspconfig').lua_ls.setup({
settings = {
Lua = {
diagnostics = {
globals = { 'vim', 'hs', 'spoon' },
disable = { 'lowercase-global' },
},
},
},
})

-- ansiblels disable settings
require('lspconfig').ansiblels.setup({
settings = {
ansible = {
diagnostics = {
disable = { 'name[template]' }
},
},
},
})
end
},
-- inlay hints
{
'simrat39/inlay-hints.nvim',
Expand Down
20 changes: 20 additions & 0 deletions roles/neovim/files/lua/plugins/smear-cursor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
return {
"sphamba/smear-cursor.nvim",
opts = {
-- How fast the smear's head moves towards the target.
-- 0: no movement, 1: instantaneous, default: 0.6
stiffness = 0.7,

-- How fast the smear's tail moves towards the head.
-- 0: no movement, 1: instantaneous, default: 0.3
trailing_stiffness = 0.4,

-- How much the tail slows down when getting close to the head.
-- 0: no slowdown, more: more slowdown, default: 0.1
trailing_exponent = 0.2,

-- Stop animating when the smear's tail is within this distance (in characters) from the target.
-- Default: 0.1
distance_stop_animating = 0.3,
}
}

0 comments on commit 55ebfbb

Please sign in to comment.