LSP Rewrite

This commit is contained in:
agryphus 2023-12-05 23:56:09 -05:00
parent 5519206fdd
commit d9ac8b2bd1
5 changed files with 70 additions and 108 deletions

View file

@ -1,8 +1,4 @@
vim.keymap.set("n", "<leader>e", function ()
vim.g.lf_command_override = string.format('LF_OVERRIDE_X=%d LF_OVERRIDE_Y=%d lf',
math.floor(vim.go.columns * 0.5),
math.ceil(vim.go.lines * 0.25)
)
vim.cmd("Lf")
end)

View file

@ -1,64 +1,55 @@
local lsp = require('lsp-zero')
lsp.preset('recommended')
-- LANGUAGE SERVERS
local lsp_zero = require('lsp-zero')
local lspconfig = require("lspconfig")
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
lsp.ensure_installed({
"lua_ls", -- Lua
"rust_analyzer", -- Rust
"pyright", -- Python
"texlab", -- Latex
"clangd", -- C
"jdtls", -- Java
"html", -- Html
"bashls", -- Bash
})
lsp_zero.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp_zero.default_keymaps({buffer = bufnr})
end)
local ensure_installed_extras = {
}
local cmp = require("cmp")
local cmp_select = {behavior = cmp.SelectBehavior.Select}
local cmp_mappings = lsp.defaults.cmp_mappings({
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
})
lsp.set_preferences({
sign_icons = { }
})
lsp.setup_nvim_cmp({
mapping = cmp_mappings
})
lsp.configure('lua_ls', {
settings = {
Lua = {
diagnostics = {
-- Making sure that lua recognizes the global variable 'vim'
globals = { 'vim' },
},
},
lspconfig.lua_ls.setup({
settings = {
Lua = {
diagnostics = {
-- Making sure that lua recognizes the global variable 'vim'
globals = { 'vim' },
},
},
},
})
lsp.configure('pyright', {
settings = {
python = {
analysis = {
typeCheckingMode = "off",
},
},
},
lspconfig.clangd.setup({
capabilities = lsp_capabilities,
})
lsp.setup()
-- AUTOCOMPLETION
-- Install extra packages (linters, formatters, et c)
local registry = require("mason-registry")
for _, extra in ipairs(ensure_installed_extras) do
if not registry.is_installed(extra) then
vim.cmd(string.format("MasonInstall %s", extra))
end
end
local cmp = require('cmp')
local cmp_action = require('lsp-zero').cmp_action()
cmp.setup({
sources = {
{ name = "luasnip", option = { show_autosnippets = true } },
{ name = "nvim_lua" },
{ name = "nvim_lsp" },
{ name = "path" }, -- Auto complete paths
},
mapping = {
-- Navigate between completion item
['<M-k>'] = cmp.mapping.select_prev_item(),
['<M-j>'] = cmp.mapping.select_next_item(),
-- toggle completion
['<M-u>'] = cmp_action.toggle_completion(),
-- navigate between snippet placeholder
['<C-a>'] = cmp_action.luasnip_jump_backward(),
['<C-d>'] = cmp_action.luasnip_jump_forward(),
-- Confirm item
['<Tab>'] = cmp.mapping.confirm({select = true}),
}
})

View file

@ -1,20 +0,0 @@
require('neorg').setup {
load = {
["core.defaults"] = {},
["core.concealer"] = {},
["core.dirman"] = {
config = {
workspaces = {
notes = "~/dox/norg/notes",
school = "~/school/",
},
},
},
},
}
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*.norg"},
command = "set conceallevel=3"
})

View file

@ -14,23 +14,17 @@ local packer_bootstrap = ensure_packer()
return require("packer").startup(function(use)
use "wbthomason/packer.nvim"
-- Org mode
use {
"nvim-neorg/neorg",
run = ":Neorg sync-parsers",
}
-- Dashboard
use {
'glepnir/dashboard-nvim',
event = 'VimEnter',
requires = {'nvim-tree/nvim-web-devicons'},
config = function()
require('dashboard').setup {
-- config
}
end,
}
-- -- Dashboard
-- use {
-- 'glepnir/dashboard-nvim',
-- event = 'VimEnter',
-- requires = {'nvim-tree/nvim-web-devicons'},
-- config = function()
-- require('dashboard').setup {
-- -- config
-- }
-- end,
-- }
-- File manager in nvim
use {
@ -43,7 +37,7 @@ return require("packer").startup(function(use)
-- Find files and strings
use {
"nvim-telescope/telescope.nvim", tag = "0.1.0",
"nvim-telescope/telescope.nvim", tag = "0.1.4",
requires = { {"nvim-lua/plenary.nvim"} }
}
@ -57,7 +51,7 @@ return require("packer").startup(function(use)
use 'Mofiqul/vscode.nvim'
-- Referencing a hex code highlights it in that color
use "lilydjwg/colorizer"
use "norcalli/nvim-colorizer.lua"
-- Relative line numbers disappear when not actively in buffer
use "jeffkreeftmeijer/vim-numbertoggle"
@ -84,20 +78,18 @@ return require("packer").startup(function(use)
-- LSP
use {
'VonHeikemen/lsp-zero.nvim',
branch = 'v1.x',
branch = 'v3.x',
requires = {
-- LSP Support
{'neovim/nvim-lspconfig'}, -- Required
{'williamboman/mason.nvim'}, -- Optional
{'williamboman/mason-lspconfig.nvim'}, -- Optional
{'neovim/nvim-lspconfig'}, -- Required
-- Autocompletion
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'hrsh7th/cmp-buffer'}, -- Optional
{'hrsh7th/cmp-path'}, -- Optional
{'saadparwaiz1/cmp_luasnip'}, -- Optional
{'hrsh7th/cmp-nvim-lua'}, -- Optional
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'hrsh7th/cmp-buffer'}, -- Optional
{'hrsh7th/cmp-path'}, -- Optional
{'saadparwaiz1/cmp_luasnip'}, -- Optional
{'hrsh7th/cmp-nvim-lua'}, -- Optional
-- Snippets
{'L3MON4D3/LuaSnip'}, -- Required

View file

@ -17,6 +17,9 @@ vim.opt.signcolumn = "auto"
vim.o.shell = "zsh"
-- Do not map q to :q in man mode
vim.g.no_man_maps = true;
-- Local settings for when in :terminal mode
-- I don't believe this functionality has been ported to lua.
vim.cmd([[