LSP Rewrite
This commit is contained in:
parent
5519206fdd
commit
d9ac8b2bd1
5 changed files with 70 additions and 108 deletions
|
|
@ -1,8 +1,4 @@
|
||||||
vim.keymap.set("n", "<leader>e", function ()
|
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")
|
vim.cmd("Lf")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,64 +1,55 @@
|
||||||
local lsp = require('lsp-zero')
|
-- LANGUAGE SERVERS
|
||||||
lsp.preset('recommended')
|
local lsp_zero = require('lsp-zero')
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
lsp.ensure_installed({
|
lsp_zero.on_attach(function(client, bufnr)
|
||||||
"lua_ls", -- Lua
|
-- see :help lsp-zero-keybindings
|
||||||
"rust_analyzer", -- Rust
|
-- to learn the available actions
|
||||||
"pyright", -- Python
|
lsp_zero.default_keymaps({buffer = bufnr})
|
||||||
"texlab", -- Latex
|
end)
|
||||||
"clangd", -- C
|
|
||||||
"jdtls", -- Java
|
|
||||||
"html", -- Html
|
|
||||||
"bashls", -- Bash
|
|
||||||
})
|
|
||||||
|
|
||||||
local ensure_installed_extras = {
|
lspconfig.lua_ls.setup({
|
||||||
}
|
settings = {
|
||||||
|
Lua = {
|
||||||
local cmp = require("cmp")
|
diagnostics = {
|
||||||
local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
-- Making sure that lua recognizes the global variable 'vim'
|
||||||
local cmp_mappings = lsp.defaults.cmp_mappings({
|
globals = { 'vim' },
|
||||||
["<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' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
lsp.configure('pyright', {
|
lspconfig.clangd.setup({
|
||||||
settings = {
|
capabilities = lsp_capabilities,
|
||||||
python = {
|
|
||||||
analysis = {
|
|
||||||
typeCheckingMode = "off",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
lsp.setup()
|
-- AUTOCOMPLETION
|
||||||
|
|
||||||
-- Install extra packages (linters, formatters, et c)
|
local cmp = require('cmp')
|
||||||
local registry = require("mason-registry")
|
local cmp_action = require('lsp-zero').cmp_action()
|
||||||
for _, extra in ipairs(ensure_installed_extras) do
|
|
||||||
if not registry.is_installed(extra) then
|
cmp.setup({
|
||||||
vim.cmd(string.format("MasonInstall %s", extra))
|
sources = {
|
||||||
end
|
{ name = "luasnip", option = { show_autosnippets = true } },
|
||||||
end
|
{ 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}),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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"
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
@ -14,23 +14,17 @@ local packer_bootstrap = ensure_packer()
|
||||||
return require("packer").startup(function(use)
|
return require("packer").startup(function(use)
|
||||||
use "wbthomason/packer.nvim"
|
use "wbthomason/packer.nvim"
|
||||||
|
|
||||||
-- Org mode
|
-- -- Dashboard
|
||||||
use {
|
-- use {
|
||||||
"nvim-neorg/neorg",
|
-- 'glepnir/dashboard-nvim',
|
||||||
run = ":Neorg sync-parsers",
|
-- event = 'VimEnter',
|
||||||
}
|
-- requires = {'nvim-tree/nvim-web-devicons'},
|
||||||
|
-- config = function()
|
||||||
-- Dashboard
|
-- require('dashboard').setup {
|
||||||
use {
|
-- -- config
|
||||||
'glepnir/dashboard-nvim',
|
-- }
|
||||||
event = 'VimEnter',
|
-- end,
|
||||||
requires = {'nvim-tree/nvim-web-devicons'},
|
-- }
|
||||||
config = function()
|
|
||||||
require('dashboard').setup {
|
|
||||||
-- config
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- File manager in nvim
|
-- File manager in nvim
|
||||||
use {
|
use {
|
||||||
|
|
@ -43,7 +37,7 @@ return require("packer").startup(function(use)
|
||||||
|
|
||||||
-- Find files and strings
|
-- Find files and strings
|
||||||
use {
|
use {
|
||||||
"nvim-telescope/telescope.nvim", tag = "0.1.0",
|
"nvim-telescope/telescope.nvim", tag = "0.1.4",
|
||||||
requires = { {"nvim-lua/plenary.nvim"} }
|
requires = { {"nvim-lua/plenary.nvim"} }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,7 +51,7 @@ return require("packer").startup(function(use)
|
||||||
use 'Mofiqul/vscode.nvim'
|
use 'Mofiqul/vscode.nvim'
|
||||||
|
|
||||||
-- Referencing a hex code highlights it in that color
|
-- 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
|
-- Relative line numbers disappear when not actively in buffer
|
||||||
use "jeffkreeftmeijer/vim-numbertoggle"
|
use "jeffkreeftmeijer/vim-numbertoggle"
|
||||||
|
|
@ -84,20 +78,18 @@ return require("packer").startup(function(use)
|
||||||
-- LSP
|
-- LSP
|
||||||
use {
|
use {
|
||||||
'VonHeikemen/lsp-zero.nvim',
|
'VonHeikemen/lsp-zero.nvim',
|
||||||
branch = 'v1.x',
|
branch = 'v3.x',
|
||||||
requires = {
|
requires = {
|
||||||
-- LSP Support
|
-- LSP Support
|
||||||
{'neovim/nvim-lspconfig'}, -- Required
|
{'neovim/nvim-lspconfig'}, -- Required
|
||||||
{'williamboman/mason.nvim'}, -- Optional
|
|
||||||
{'williamboman/mason-lspconfig.nvim'}, -- Optional
|
|
||||||
|
|
||||||
-- Autocompletion
|
-- Autocompletion
|
||||||
{'hrsh7th/nvim-cmp'}, -- Required
|
{'hrsh7th/nvim-cmp'}, -- Required
|
||||||
{'hrsh7th/cmp-nvim-lsp'}, -- Required
|
{'hrsh7th/cmp-nvim-lsp'}, -- Required
|
||||||
{'hrsh7th/cmp-buffer'}, -- Optional
|
{'hrsh7th/cmp-buffer'}, -- Optional
|
||||||
{'hrsh7th/cmp-path'}, -- Optional
|
{'hrsh7th/cmp-path'}, -- Optional
|
||||||
{'saadparwaiz1/cmp_luasnip'}, -- Optional
|
{'saadparwaiz1/cmp_luasnip'}, -- Optional
|
||||||
{'hrsh7th/cmp-nvim-lua'}, -- Optional
|
{'hrsh7th/cmp-nvim-lua'}, -- Optional
|
||||||
|
|
||||||
-- Snippets
|
-- Snippets
|
||||||
{'L3MON4D3/LuaSnip'}, -- Required
|
{'L3MON4D3/LuaSnip'}, -- Required
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ vim.opt.signcolumn = "auto"
|
||||||
|
|
||||||
vim.o.shell = "zsh"
|
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
|
-- Local settings for when in :terminal mode
|
||||||
-- I don't believe this functionality has been ported to lua.
|
-- I don't believe this functionality has been ported to lua.
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue