Update neovim dotfiles

This commit is contained in:
hok7z 2022-12-24 19:33:46 +02:00
parent 11983c4e91
commit 319e972dcc
15 changed files with 254 additions and 577 deletions

View File

@ -1,3 +0,0 @@
GuiFont! Iosevka:h15
GuiTabline 0
GuiPopupmenu 0

View File

@ -1,9 +1,4 @@
local core = {
"options",
"mappings",
"autocmds",
"plugins"
}
local core = {"options", "keybinds", "autocmds", "plugins"}
for _,source in ipairs(core) do
local status_ok,fault = pcall(require,'core.' .. source)

View File

@ -11,10 +11,3 @@ vim.api.nvim_create_autocmd({"BufEnter","BufWinEnter","WinEnter","CmdwinEnter"},
end
end,
})
vim.api.nvim_create_autocmd({"BufEnter","BufWinEnter"},{
pattern = {"*.json"},
callback = function()
vim.lsp.buf.formatting()
end,
})

View File

@ -1,88 +0,0 @@
return {
kind = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
},
diagnostic = {
default = {
{ name = "Error",icon = "", color = "Default" },
{ name = "Warn", icon = "", color = "Default" },
{ name = "Info", icon = "", color = "Default" },
{ name = "Hint", icon = "", color = "Default" },
},
catppuccin = {
{ name = "Error", icon = "", color = "Default" },
{ name = "Warn", icon = "", color = "Default" },
{ name = "Info", icon = "", color = "Default" },
{ name = "Hint", icon = "", color = "Default" }
},
},
ui = {
ArrowClosed = "",
ArrowOpen = "",
Lock = "",
Circle = "",
BigCircle = "",
BigUnfilledCircle = "",
Close = "",
NewFile = "",
Search = "",
Lightbulb = "",
Project = "",
Dashboard = "",
History = "",
Comment = "",
Bug = "",
Code = "",
Telescope = "",
Gear = "",
Package = "",
List = "",
SignIn = "",
SignOut = "",
Check = "",
Fire = "",
Note = "",
BookMark = "",
Pencil = "",
ChevronRight = "",
Table = "",
Calendar = "",
CloudDownload = "",
},
notify = {
ERROR = "",
WARN = "",
INFO = "",
DEBUG = "",
TRACE = "",
},
}

View File

@ -1,48 +1,34 @@
local keymap = vim.keymap.set
vim.g.mapleader = " "
keymap("n","<space>,",":nohlsearch<CR>")
keymap("n","<leader>m",":MarkdownPreview<CR>")
-- Block arrows
vim.api.nvim_set_keymap('', '<up>', '<nop>', {noremap = true})
vim.api.nvim_set_keymap('', '<down>', '<nop>', {noremap = true})
vim.api.nvim_set_keymap('', '<left>', '<nop>', {noremap = true})
vim.api.nvim_set_keymap('', '<right>', '<nop>',{noremap = true})
-- resize
keymap("n","<C-k>",":resize -2<CR>")
keymap("n","<C-j>",":resize 2<CR>")
keymap("n","<C-h>",":vertical resize -2<CR>")
keymap("n","<C-l>",":vertical resize 2<CR>")
keymap("n","<space>,",":nohlsearch<CR>")
-- tabs
keymap("n","<leader>tn",":tabnew <CR>")
keymap("n","<leader>tc",":tabclose<CR>")
-- NvimTree --
keymap("n","<C-n>",":NvimTreeToggle<CR>")
keymap("n","<leader>n",":NvimTreeFindFile<CR>")
keymap("n","<C-]>","gh defx#do_action('cd',getcwd())<CR>")
-- Telescope --
keymap("n","<leader>ff","<cmd> Telescope find_files <cr>")
keymap("n","<leader>fg","<cmd> Telescope live_grep <cr>")
keymap("n","<leader>fb","<cmd> Telescope buffers <cr>")
keymap("n","<leader>fh","<cmd> Telescope help_tags <cr>")
-- NvimTree --
keymap("n","<C-n>",":NvimTreeToggle<CR>")
keymap("n","<leader>n",":NvimTreeFindFile<CR>")
keymap("n","<C-]>","gh defx#do_action('cd',getcwd())<CR>")
-- barbar.nvim
keymap('n', '<A-,>', ':BufferPrevious<CR>')
keymap('n', '<A-.>', ':BufferNext<CR>')
keymap('n', '<A-,>', ':BufferPrevious<CR>')
-- Re-order to previous/next
keymap('n', '<A-<>', ':BufferMovePrevious<CR>')
keymap('n', '<A->>', ' :BufferMoveNext<CR>')
-- Goto buffer in position...
keymap('n', '<A-1>', ':BufferGoto 1<CR>')
keymap('n', '<A-2>', ':BufferGoto 2<CR>')
keymap('n', '<A-3>', ':BufferGoto 3<CR>')
@ -54,5 +40,4 @@ keymap('n', '<A-8>', ':BufferGoto 8<CR>')
keymap('n', '<A-9>', ':BufferGoto 9<CR>')
keymap('n', '<A-0>', ':BufferLast<CR>')
-- Close buffer
keymap('n', '<A-c>', ':BufferClose<CR>')

View File

@ -1,77 +1,28 @@
local opt = vim.opt
vim.g.did_load_filetypes = 1
opt.encoding = "utf-8"
opt.clipboard = "unnamedplus"
opt.swapfile = false
vim.g.icons = require("core.icons")
local ok, notify = pcall(require, "notify")
if ok then
vim.notify = notify
end
opt.termguicolors = true
opt.listchars = {eol = '', tab = '', trail = '·'}
vim.cmd[[colorscheme catppuccin-macchiato]]
local ok,utils = pcall(require,"core.utils")
if (not ok) then
vim.notify("Can't load utils")
end
-- utils.run_colorscheme("vscode",function()
-- -- https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#custom-menu-direction
-- utils.highlight("CmpItemAbbrDeprecated", {guibg=NONE,gui=strikethrough,guifg=#808080})
--
-- utils.highlight("CmpItemAbbrMatch", {guibg=NONE,guifg=#569CD6})
-- utils.highlight("CmpItemAbbrMatchFuzzy", {guibg=NONE,guifg=#569CD6})
--
-- utils.highlight("CmpItemKindVariable", {guibg=NONE,guifg=#9CDCFE})
-- utils.highlight("CmpItemKindInterface", {guibg=NONE,guifg=#9CDCFE})
-- utils.highlight("CmpItemKindText", {guibg=NONE,guifg=#9CDCFE})
--
-- utils.highlight("CmpItemKindFunction", {guibg=NONE,guifg=#C586C0})
-- utils.highlight("CmpItemKindMethod", {guibg=NONE,guifg=#C586C0})
--
-- utils.highlight("CmpItemKindKeyword", {guibg=NONE guifg=#D4D4D4})
-- utils.highlight("CmpItemKindProperty", {guibg=NONE guifg=#D4D4D4})
-- utils.highlight("CmpItemKindUnit", {guibg=NONE guifg=#D4D4D4})
--
-- vim.g.diagnostic_signs = vim.g.icons.diagnostics.default
-- end)
-- utils.run_colorscheme("github-dark",function()
-- require("github-theme").setup({
-- theme_style = "dark_default",
-- function_style = "italic",
-- sidebars = { "qf", "vista_kind", "terminal", "packer" },
-- hide_inactive_statusline = false,
-- })
--
-- vim.g.diagnostic_signs = {
-- {name = "Error",icon = " ", color = "Default"},
-- {name = "Warn", icon = " ", color = "Default"},
-- {name = "Info", icon = " ", color = "Default"},
-- {name = "Hint", icon = " ", color = "Default"},
-- }
-- end)
utils.run_colorscheme("catppuccin",function()
vim.g.catppucin_flavor = "mocha" -- latte, frappe, macchiato, mocha
vim.g.diagnostics_signs = vim.g.icons.diagnostic.catppuccin
end)
-- statusline = require("core.statusline")
-- opt.statusline = "%!luaeval('statusline.active()')"
opt.encoding = "utf-8"
opt.clipboard = "unnamedplus"
opt.swapfile = false
opt.number = true
opt.mouse = "a"
opt.relativenumber = true
vim.g.mapleader = " "
opt.list = true
opt.listchars = {tab = '| '}
vim.g.diagnostic_sings = {"", "", "", ""}
opt.mouse = "a"
opt.tabstop = 4
opt.shiftwidth = 4
opt.expandtab = true
opt.ts = 4
opt.sw = 4
opt.splitright = true

View File

@ -16,23 +16,44 @@ packer.startup{
function(use)
use {"wbthomason/packer.nvim"}
use {"nathom/filetype.nvim"}
use {
"lewis6991/impatient.nvim",
config = function() require('impatient') end
}
-- Colorchemes
use {"catppuccin/nvim", as = "catppuccin"}
use {"rebelot/kanagawa.nvim"}
use {"tiagovla/tokyodark.nvim"}
use {"folke/tokyonight.nvim"}
use {"navarasu/onedark.nvim"}
use {"rebelot/kanagawa.nvim"}
use {"projekt0n/github-nvim-theme"}
use {"Mofiqul/vscode.nvim"}
use {
"norcalli/nvim-colorizer.lua",
config = function() require'colorizer'.setup() end
}
use {"dstein64/vim-startuptime"}
use {
"kyazdani42/nvim-tree.lua",
requires = { "kyazdani42/nvim-web-devicons" },
config = function() require("plugins.nvim-tree") end
}
use {"rcarriga/nvim-notify"}
use {
"lewis6991/gitsigns.nvim",
config = function() require("gitsigns").setup{keymaps = {}} end
}
use {
"akinsho/toggleterm.nvim", tag = 'v2.*',
config = function() require("toggleterm").setup() end
}
use {
"windwp/nvim-autopairs",
config = function() require("nvim-autopairs").setup() end
}
use {
"lukas-reineke/indent-blankline.nvim",
config = function()
@ -43,35 +64,26 @@ packer.startup{
end
}
use {
"windwp/nvim-autopairs",
config = function() require("nvim-autopairs").setup() end
}
use {
"nacro90/numb.nvim",
config = function() require('numb').setup() end
}
use {
"numToStr/Comment.nvim",
config = function() require('Comment').setup() end
}
use {
"lewis6991/gitsigns.nvim",
config = function()
require("gitsigns").setup{keymaps = {}}
end
}
use {
"folke/todo-comments.nvim",
requires = "nvim-lua/plenary.nvim",
config = function() require("todo-comments").setup() end
}
use {"davidgranstrom/nvim-markdown-preview"}
use {
"nvim-treesitter/nvim-treesitter",
requires = {
"nvim-treesitter/playground",
"nvim-treesitter/nvim-treesitter-textobjects",
},
run = function() vim.cmd("TSUpdate") end,
config = function() require("plugins.treesitter") end
}
use {
"nvim-telescope/telescope.nvim",
@ -90,93 +102,20 @@ packer.startup{
end
}
use {
"akinsho/toggleterm.nvim", tag = 'v2.*',
config = function() require("toggleterm").setup() end
}
use {
"kyazdani42/nvim-tree.lua",
requires = { "kyazdani42/nvim-web-devicons" },
config = function() require("plugins.nvim-tree") end
}
use {
"rcarriga/nvim-notify",
config = function()
local notify = require("notify")
notify.setup{
level = "info",
stages = "fade_in_slide_out",
on_open = nil,
on_close = nil,
render = "default",
timeout = 5000,
max_width = nil,
max_height = nil,
background_colour = "Normal",
minimum_width = 50,
icons = vim.g.icons.notify,
}
end
}
-- TODO: write own statusline
-- use {
-- "nvim-lualine/lualine.nvim",
-- requires = { 'kyazdani42/nvim-web-devicons',opt = true},
-- config = function() require("plugins.lualine") end
-- }
use {
'romgrk/barbar.nvim',
requires = {'kyazdani42/nvim-web-devicons'},
config = function() require("plugins.barbar") end,
config = function() require("plugins.barbar") end
}
use {
'pwntester/octo.nvim',
requires = {
'nvim-lua/plenary.nvim',
},
config = function() require"octo".setup() end
}
use {
"sindrets/diffview.nvim",
requires = 'nvim-lua/plenary.nvim'
}
use {
"nvim-treesitter/nvim-treesitter",
requires = {
"nvim-treesitter/playground",
"nvim-treesitter/nvim-treesitter-textobjects",
},
run = function() vim.cmd("TSUpdate") end,
config = function() require("plugins.treesitter") end
}
-- Language Server Protocol
use {
"neovim/nvim-lspconfig",
config = function() require("plugins.lsp") end
}
use {
"j-hui/fidget.nvim",
config = function() require"fidget".setup() end
requires = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim" },
config = function()
require("lsp")
require("mason").setup()
end
}
use {
@ -201,21 +140,55 @@ packer.startup{
mode = 'symbol_text',
preset = 'codicons',
symbol_map = vim.g.icons.kind
symbol_map = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
}
}
end
}
use {
"L3MON4D3/LuaSnip",
requires = {
"rafamadriz/friendly-snippets",
},
config = function()
require("luasnip/loaders/from_vscode").lazy_load()
end
requires = {"rafamadriz/friendly-snippets"},
config = function() require("luasnip/loaders/from_vscode").lazy_load() end
}
use {
"jose-elias-alvarez/null-ls.nvim",
config = function() require("plugins.null-ls") end
}
use {
"SmiteshP/nvim-gps",
requires = "nvim-treesitter/nvim-treesitter",
config = function() require("nvim-gps").setup() end,
}
use {
"ray-x/lsp_signature.nvim",
@ -231,16 +204,8 @@ packer.startup{
}
use {
"SmiteshP/nvim-gps",
requires = "nvim-treesitter/nvim-treesitter",
config = function() require("nvim-gps").setup() end,
}
use {
"jose-elias-alvarez/null-ls.nvim",
config = function() require("plugins.null-ls") end
"j-hui/fidget.nvim",
config = function() require("fidget").setup() end
}
-- Debug Adapter Protocol
@ -264,6 +229,7 @@ packer.startup{
}
}
local function bootstrap()
local fn = vim.fn
local packer_install_path =

View File

@ -1,154 +0,0 @@
local fn = vim.fn
local api = vim.api
local M = {}
-- possible values are 'arrow' | 'rounded' | 'blank'
local active_sep = 'blank'
-- change them if you want to different separator
M.separators = {
arrow = { '', '' },
rounded = { '', '' },
blank = { '', '' },
}
-- highlight groups
M.colors = {
active = '%#StatusLine#',
inactive = '%#StatuslineNC#',
mode = '%#Mode#',
mode_alt = '%#ModeAlt#',
git = '%#Git#',
git_alt = '%#GitAlt#',
filetype = '%#Filetype#',
filetype_alt = '%#FiletypeAlt#',
line_col = '%#LineCol#',
line_col_alt = '%#LineColAlt#',
}
M.trunc_width = setmetatable({
mode = 80,
git_status = 90,
filename = 140,
line_col = 60,
}, {
__index = function()
return 80
end
})
M.is_truncated = function(_, width)
local current_width = api.nvim_win_get_width(0)
return current_width < width
end
M.modes = setmetatable({
['n'] = {'Normal', 'N'};
['no'] = {'N·Pending', 'N·P'} ;
['v'] = {'Visual', 'V' };
['V'] = {'V·Line', 'V·L' };
[''] = {'V·Block', 'V·B'}; -- this is not ^V, but it's , they're different
['s'] = {'Select', 'S'};
['S'] = {'S·Line', 'S·L'};
[''] = {'S·Block', 'S·B'}; -- same with this one, it's not ^S but it's 
['i'] = {'Insert', 'I'};
['ic'] = {'Insert', 'I'};
['R'] = {'Replace', 'R'};
['Rv'] = {'V·Replace', 'V·R'};
['c'] = {'Command', 'C'};
['cv'] = {'Vim·Ex ', 'V·E'};
['ce'] = {'Ex ', 'E'};
['r'] = {'Prompt ', 'P'};
['rm'] = {'More ', 'M'};
['r?'] = {'Confirm ', 'C'};
['!'] = {'Shell ', 'S'};
['t'] = {'Terminal ', 'T'};
}, {
__index = function()
return {'Unknown', 'U'} -- handle edge cases
end
})
M.get_current_mode = function(self)
local current_mode = api.nvim_get_mode().mode
if self:is_truncated(self.trunc_width.mode) then
return string.format(' %s ', self.modes[current_mode][2]):upper()
end
return string.format(' %s ', self.modes[current_mode][1]):upper()
end
M.get_git_status = function(self)
-- use fallback because it doesn't set this variable on the initial `BufEnter`
local signs = vim.b.gitsigns_status_dict or {head = '', added = 0, changed = 0, removed = 0}
local is_head_empty = signs.head ~= ''
if self:is_truncated(self.trunc_width.git_status) then
return is_head_empty and string.format('  %s ', signs.head or '') or ''
end
return is_head_empty and string.format(
' +%s ~%s -%s |  %s ',
signs.added, signs.changed, signs.removed, signs.head
) or ''
end
M.get_filename = function(self)
if self:is_truncated(self.trunc_width.filename) then return " %<%f " end
return " %<%F "
end
M.get_filetype = function()
local file_name, file_ext = fn.expand("%:t"), fn.expand("%:e")
local icon = require'nvim-web-devicons'.get_icon(file_name, file_ext, { default = true })
local filetype = vim.bo.filetype
if filetype == '' then return '' end
return string.format(' %s %s ', icon, filetype):lower()
end
M.get_line_col = function(self)
if self:is_truncated(self.trunc_width.line_col) then return ' %l:%c ' end
return ' Ln %l, Col %c '
end
M.set_active = function(self)
local colors = self.colors
local mode = colors.mode .. self:get_current_mode()
local mode_alt = colors.mode_alt .. self.separators[active_sep][1]
local git = colors.git .. self:get_git_status()
local git_alt = colors.git_alt .. self.separators[active_sep][1]
local filename = colors.inactive .. self:get_filename()
local filetype_alt = colors.filetype_alt .. self.separators[active_sep][2]
local filetype = colors.filetype .. self:get_filetype()
local line_col = colors.line_col .. self:get_line_col()
local line_col_alt = colors.line_col_alt .. self.separators[active_sep][2]
return table.concat({
colors.active, mode, mode_alt, git, git_alt,
"%=", filename, "%=",
filetype_alt, filetype, line_col_alt, line_col
})
end
M.set_inactive = function(self)
return self.colors.inactive .. '%= %F %='
end
M.set_explorer = function(self)
local title = self.colors.mode .. ''
local title_alt = self.colors.mode_alt .. self.separators[active_sep][2]
return table.concat({ self.colors.active, title, title_alt })
end
Statusline = setmetatable(M, {
__call = function(statusline, mode)
if mode == "active" then return statusline:set_active() end
if mode == "inactive" then return statusline:set_inactive() end
if mode == "explorer" then return statusline:set_explorer() end
end
})

View File

@ -0,0 +1,73 @@
local ok, lsp = pcall(require,"lspconfig")
if not ok then
vim.notify("Failed to load lspconfig\n\n")
return
end
local ok, mason_lsp = pcall(require, "mason-lspconfig")
if not ok then
vim.notify("Failed load mason-lspconfig")
end
local sign = vim.fn.sign_define
local sign_name = {"Error","Warn","Info","Hint"}
vim.g.lsp_path = os.getenv("HOME") .. "/.local/share/nvim/mason/bin/"
vim.g.lsp_capabilities = vim.lsp.protocol.make_client_capabilities()
vim.g.lsp_capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
vim.g.lsp_capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
vim.diagnostic.config {
signs = true,
underline = true,
update_in_insert = false,
severity_sort = false,
virtual_text = {prefix = 'x'},
float = {border = "rounded"},
}
vim.g.lsp_handler = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover,{border="rounded"}),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help,{border="rounded"})
}
for k, icon in pairs(vim.g.diagnostic_sings) do
sign("DiagnosticSign" .. sign_name[k],{text=icon,texthl="DiagnosticSign" .. sign_name[k]})
end
vim.g.lsp_on_attach = function(client,bufnr)
print("Attaching to:",client.name)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr,...) end
local opts = {noremap = true,silent=true}
buf_set_keymap('n','gd','<cmd>lua vim.lsp.buf.definition()<CR>',opts)
buf_set_keymap('n','K', '<cmd>lua vim.lsp.buf.hover()<CR>',opts)
buf_set_keymap('n','[d','<cmd>lua vim.diagnostic.goto_prev()<CR>',opts)
buf_set_keymap('n',']d','<cmd>lua vim.diagnostic.goto_next()<CR>',opts)
buf_set_keymap('n','<leader>d','<cmd>lua vim.diagnostic.open_float({border="rounded"})<CR>',opts)
buf_set_keymap('n','<space>f','<cmd>lua vim.lsp.buf.formatting()<CR>',opts)
end
local servers = mason_lsp.get_installed_servers()
for _, server in ipairs(servers) do
local ok, result = pcall(require, "lsp.servers."..server)
if ok then
local lsp_srv = lsp[server]
if lsp_srv ~= nil then
local ok, err = pcall(lsp_srv.setup, result)
if err ~= nil then
vim.pretty_print(err)
end
else
vim.notify("Missing server configuration for " .. server,"error")
vim.pretty_print({server = server, result = result})
end
end
end

View File

@ -0,0 +1,14 @@
return {
filetypes = {"c","cpp","objc","objcpp"},
on_attach = vim.g.lsp_on_attach,
handlers = vim.g.lsp_handlers,
capabilities = require('cmp_nvim_lsp').default_capabilities(vim.g.lsp_capabilities),
root_dir = require"lspconfig.util".root_pattern{
"CMakeList.txt",
"compile_flags.txt",
".git",
vim.fn.getcwd()
}
}

View File

@ -0,0 +1,14 @@
return {
filetypes = {"css", "scss", "less" },
cmd = { vim.g.lsp_path .. "vscode-css-language-server", "--stdio"},
on_attach = vim.g.lsp_on_attach,
handlers = vim.g.lsp_handler,
capabilities = require('cmp_nvim_lsp').default_capabilities(vim.g.lsp_capabilities),
root_dir = require"lspconfig.util".root_pattern{
"package.json",
".git"
},
}

View File

@ -0,0 +1,15 @@
return {
filetypes = {"go", "gomod"},
cmd = {vim.g.lsp_path .. "gopls"},
on_attach = vim.g.lsp_on_attach,
handlers = vim.g.lsp_handler,
capabilities = require('cmp_nvim_lsp').default_capabilities(vim.g.lsp_capabilities),
root_dir = require"lspconfig.util".root_pattern{
"go.mod",
".git",
vim.fn.getcwd(),
},
}

View File

@ -0,0 +1,10 @@
return {
filetypes = {"python"},
cmd = {vim.g.lsp_path .. "pyright-langserver", "--stdio"},
on_attach = vim.g.lsp_on_attach,
handlers = vim.g.lsp_handlers,
capabilities = require('cmp_nvim_lsp').default_capabilities(vim.g.lsp_capabilities),
}

View File

@ -32,7 +32,6 @@ cmp.setup {
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- local kind = string.format("%s %s",vim.g.icons.kind[vim_item.kind], vim_item.kind)
local kind = require("lspkind").cmp_format({mode = "symbol_text", maxwidth = 50})(entry, vim_item)
local strings = vim.split(kind.kind, "%s",{trimempty = true})
@ -40,14 +39,6 @@ cmp.setup {
kind.menu = " (" .. strings[2] .. ")"
return kind
-- vim_item.menu = ({
-- nvim_lsp = "[LSP]",
-- nvim_lua = "[Lua]",
-- buffer = "[BUF]",
-- })[entry.source.name]
--
-- return vim_item
end
},

View File

@ -1,85 +0,0 @@
local ok,nvim_lsp = pcall(require,"lspconfig")
if not ok then
vim.notify("Failed to load lspconfig\n\n")
return
end
local utils = require"core.utils"
local root_pattern = require"lspconfig.util".root_pattern
local sign = vim.fn.sign_define
local capabilities = vim.lsp.protocol.make_client_capabilities()
local handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover,{border = "rounded"}),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help,{border = "rounded"}),
}
local function DiagnosticSign(name,icon,color)
sign("DiagnosticSign"..name,{text=icon,texthl="DiagnosticSign"..name})
if (color ~= "Default") then
utils.highlight{"Diagnostic"..name,fg=color}
end
end
for _,sign in pairs(vim.g.diagnostics_signs) do
DiagnosticSign(sign.name,sign.icon,sign.color)
end
vim.diagnostic.config {
signs = true,
underline = true,
update_in_insert = false,
severity_sort = false,
virtual_text = {prefix = 'x'},
float = {border = "rounded"},
}
local on_attach = function(client,bufnr)
print("Attaching to:",client.name)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr,...) end
local opts = {noremap = true,silent=true}
buf_set_keymap('n','gd','<cmd>lua vim.lsp.buf.definition()<CR>',opts)
buf_set_keymap('n','K', '<cmd>lua vim.lsp.buf.hover()<CR>',opts)
buf_set_keymap('n','[d','<cmd>lua vim.diagnostic.goto_prev()<CR>',opts)
buf_set_keymap('n',']d','<cmd>lua vim.diagnostic.goto_next()<CR>',opts)
buf_set_keymap('n','<leader>d','<cmd>lua vim.diagnostic.open_float({border="rounded"})<CR>',opts)
buf_set_keymap('n','<space>f','<cmd>lua vim.lsp.buf.formatting()<CR>',opts)
end
-- LSP Servers
nvim_lsp.clangd.setup {
filetypes = {"c","cpp","objc","objcpp"},
on_attach = on_attach,
handlers = handlers,
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities),
root_dir = root_pattern {
"CMakeList.txt",
"compile_flags.txt",
".git",
vim.fn.getcwd()
}
}
nvim_lsp.pyright.setup{
on_attach = on_attach,
handlers = handlers,
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities),
}
nvim_lsp.gopls.setup {
cmd = {"gopls","server"},
filetypes = {"go", "gomod"},
on_attach = on_attach,
handlers = handlers,
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities),
root_dir = root_pattern{
"go.mod",
".git",
vim.fn.getcwd(),
},
}