Compare commits
8 Commits
1d941bca87
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71d63723fd | ||
|
|
8ebc69c5ba | ||
|
|
4a2df5a9b9 | ||
|
|
db62d51b65 | ||
|
|
edcfba22ad | ||
|
|
288621e1a4 | ||
|
|
5123a6cc03 | ||
|
|
ae30620d2a |
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" },
|
"blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" },
|
||||||
"fzf-lua": { "branch": "main", "commit": "9d579feab4d3035627150e5e9b6e8fbf5e814ef6" },
|
"fzf-lua": { "branch": "main", "commit": "d59f857c76eb474ec00debcf043f14fd001805cc" },
|
||||||
"gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" },
|
"gruvbox.nvim": { "branch": "main", "commit": "a472496e1a4465a2dd574389dcf6cdb29af9bf1b" },
|
||||||
"image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" },
|
"image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "0b9bb925c000ae649ff7e7149c8cd00031f4b539" },
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "0b9bb925c000ae649ff7e7149c8cd00031f4b539" },
|
||||||
"mini.icons": { "branch": "main", "commit": "ff2e4f1d29f659cc2bad0f9256f2f6195c6b2428" },
|
"mini.icons": { "branch": "main", "commit": "efc85e42262cd0c9e1fdbf806c25cb0be6de115c" },
|
||||||
"molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" },
|
"molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" },
|
||||||
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
|
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
|
||||||
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "effe4bf2e1afb881ea67291c648b68dd3dfc927a" },
|
"nvim-lspconfig": { "branch": "master", "commit": "effe4bf2e1afb881ea67291c648b68dd3dfc927a" },
|
||||||
"nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" },
|
"nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" },
|
||||||
"nvim-treesitter": { "branch": "main", "commit": "8cdffc6d334731ce3703b6d870a5a34fd878208a" },
|
"nvim-treesitter": { "branch": "main", "commit": "568ede7e79172a0fe7c9d631454a97ad968deaf2" },
|
||||||
"oil.nvim": { "branch": "master", "commit": "3b249b71957ee35d5adbfb21f77992809a4c4683" },
|
"oil.nvim": { "branch": "master", "commit": "f55b25e493a7df76371cfadd0ded5004cb9cd48a" },
|
||||||
"render-markdown.nvim": { "branch": "main", "commit": "b2b135347e299ffbf7f4123fb7811899b0c9f4b8" },
|
"render-markdown.nvim": { "branch": "main", "commit": "b2b135347e299ffbf7f4123fb7811899b0c9f4b8" },
|
||||||
"undotree": { "branch": "master", "commit": "0f1c9816975b5d7f87d5003a19c53c6fd2ff6f7f" },
|
"undotree": { "branch": "master", "commit": "178d19e00a643f825ea11d581b1684745d0c4eda" },
|
||||||
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }
|
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,17 @@ local function tex()
|
|||||||
vim.notify(pdflatex_result.stderr, vim.log.levels.ERROR);
|
vim.notify(pdflatex_result.stderr, vim.log.levels.ERROR);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function biber()
|
||||||
|
local biber_process = vim.system({
|
||||||
|
"biber",
|
||||||
|
vim.fn.expand("%:p:r") .. ".bcf"
|
||||||
|
})
|
||||||
|
local biber_result = biber_process:wait()
|
||||||
|
|
||||||
|
vim.notify(biber_result.stdout, vim.log.levels.INFO)
|
||||||
|
vim.notify(biber_result.stderr, vim.log.levels.ERROR)
|
||||||
|
end
|
||||||
|
|
||||||
local default = {
|
local default = {
|
||||||
__index = function()
|
__index = function()
|
||||||
return function() end
|
return function() end
|
||||||
@@ -121,6 +132,7 @@ setmetatable(fttable, default)
|
|||||||
local fttable2 = {
|
local fttable2 = {
|
||||||
["markdown"] = function() markdown(vim.fn.input("enter additional options")) end,
|
["markdown"] = function() markdown(vim.fn.input("enter additional options")) end,
|
||||||
["arduino"] = function() arduino(vim.fn.input("enter preprocessor defines")) end,
|
["arduino"] = function() arduino(vim.fn.input("enter preprocessor defines")) end,
|
||||||
|
["tex"] = function () biber() end,
|
||||||
}
|
}
|
||||||
setmetatable(fttable2, fttable)
|
setmetatable(fttable2, fttable)
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,13 @@
|
|||||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||||
|
|
||||||
|
-- move to line start/end
|
||||||
|
vim.keymap.set('i', "<C-e>", "<C-o>$")
|
||||||
|
vim.keymap.set('i', "<C-a>", "<C-o>^")
|
||||||
|
|
||||||
|
vim.keymap.set({ 'n', 'v' }, "<C-e>", '$')
|
||||||
|
vim.keymap.set({ 'n', 'v' }, "<C-a>", '^')
|
||||||
|
|
||||||
-- yank to clipboard
|
-- yank to clipboard
|
||||||
vim.keymap.set("n", "<leader>y", "\"+y")
|
vim.keymap.set("n", "<leader>y", "\"+y")
|
||||||
vim.keymap.set("v", "<leader>y", "\"+y")
|
vim.keymap.set("v", "<leader>y", "\"+y")
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ local config = {
|
|||||||
},
|
},
|
||||||
filetypes = {
|
filetypes = {
|
||||||
"arduino",
|
"arduino",
|
||||||
"cpp",
|
|
||||||
},
|
},
|
||||||
root_dir = function (bufnr, on_dir)
|
root_dir = function (bufnr, on_dir)
|
||||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
|
|||||||
104
lua/lsp/clangd.lua
Normal file
104
lua/lsp/clangd.lua
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
---@brief
|
||||||
|
---
|
||||||
|
--- https://clangd.llvm.org/installation.html
|
||||||
|
---
|
||||||
|
--- - **NOTE:** Clang >= 11 is recommended! See [#23](https://github.com/neovim/nvim-lspconfig/issues/23).
|
||||||
|
--- - If `compile_commands.json` lives in a build directory, you should
|
||||||
|
--- symlink it to the root of your source tree.
|
||||||
|
--- ```
|
||||||
|
--- ln -s /path/to/myproject/build/compile_commands.json /path/to/myproject/
|
||||||
|
--- ```
|
||||||
|
--- - clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
|
||||||
|
--- specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson
|
||||||
|
|
||||||
|
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
|
||||||
|
local function switch_source_header(bufnr, client)
|
||||||
|
local method_name = 'textDocument/switchSourceHeader'
|
||||||
|
---@diagnostic disable-next-line:param-type-mismatch
|
||||||
|
if not client or not client:supports_method(method_name) then
|
||||||
|
return vim.notify(('method %s is not supported by any servers active on the current buffer'):format(method_name))
|
||||||
|
end
|
||||||
|
local params = vim.lsp.util.make_text_document_params(bufnr)
|
||||||
|
---@diagnostic disable-next-line:param-type-mismatch
|
||||||
|
client:request(method_name, params, function(err, result)
|
||||||
|
if err then
|
||||||
|
error(tostring(err))
|
||||||
|
end
|
||||||
|
if not result then
|
||||||
|
vim.notify('corresponding file cannot be determined')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
vim.cmd.edit(vim.uri_to_fname(result))
|
||||||
|
end, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function symbol_info(bufnr, client)
|
||||||
|
local method_name = 'textDocument/symbolInfo'
|
||||||
|
---@diagnostic disable-next-line:param-type-mismatch
|
||||||
|
if not client or not client:supports_method(method_name) then
|
||||||
|
return vim.notify('Clangd client not found', vim.log.levels.ERROR)
|
||||||
|
end
|
||||||
|
local win = vim.api.nvim_get_current_win()
|
||||||
|
local params = vim.lsp.util.make_position_params(win, client.offset_encoding)
|
||||||
|
---@diagnostic disable-next-line:param-type-mismatch
|
||||||
|
client:request(method_name, params, function(err, res)
|
||||||
|
if err or #res == 0 then
|
||||||
|
-- Clangd always returns an error, there is no reason to parse it
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local container = string.format('container: %s', res[1].containerName) ---@type string
|
||||||
|
local name = string.format('name: %s', res[1].name) ---@type string
|
||||||
|
vim.lsp.util.open_floating_preview({ name, container }, '', {
|
||||||
|
height = 2,
|
||||||
|
width = math.max(string.len(name), string.len(container)),
|
||||||
|
focusable = false,
|
||||||
|
focus = false,
|
||||||
|
title = 'Symbol Info',
|
||||||
|
})
|
||||||
|
end, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@class ClangdInitializeResult: lsp.InitializeResult
|
||||||
|
---@field offsetEncoding? string
|
||||||
|
|
||||||
|
---@type vim.lsp.Config
|
||||||
|
local config = {
|
||||||
|
cmd = { 'clangd' },
|
||||||
|
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
|
||||||
|
root_markers = {
|
||||||
|
'.clangd',
|
||||||
|
'.clang-tidy',
|
||||||
|
'.clang-format',
|
||||||
|
'compile_commands.json',
|
||||||
|
'compile_flags.txt',
|
||||||
|
'configure.ac', -- AutoTools
|
||||||
|
'.git',
|
||||||
|
},
|
||||||
|
capabilities = {
|
||||||
|
textDocument = {
|
||||||
|
completion = {
|
||||||
|
editsNearCursor = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
offsetEncoding = { 'utf-8', 'utf-16' },
|
||||||
|
},
|
||||||
|
---@param init_result ClangdInitializeResult
|
||||||
|
on_init = function(client, init_result)
|
||||||
|
if init_result.offsetEncoding then
|
||||||
|
client.offset_encoding = init_result.offsetEncoding
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdSwitchSourceHeader', function()
|
||||||
|
switch_source_header(bufnr, client)
|
||||||
|
end, { desc = 'Switch between source/header' })
|
||||||
|
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdShowSymbolInfo', function()
|
||||||
|
symbol_info(bufnr, client)
|
||||||
|
end, { desc = 'Show symbol info' })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['clangd'] = config
|
||||||
|
vim.lsp.enable('clangd')
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
# https://github.com/neovim/nvim-lspconfig/blob/master/lsp
|
# https://github.com/neovim/nvim-lspconfig/blob/master/lsp
|
||||||
require("lsp.arduino")
|
require("lsp.arduino")
|
||||||
|
require("lsp.clangd")
|
||||||
|
require("lsp.julia")
|
||||||
require("lsp.latex")
|
require("lsp.latex")
|
||||||
require("lsp.lua")
|
require("lsp.lua")
|
||||||
require("lsp.python")
|
require("lsp.python")
|
||||||
|
|
||||||
|
|||||||
136
lua/lsp/julia.lua
Normal file
136
lua/lsp/julia.lua
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
---@brief
|
||||||
|
---
|
||||||
|
--- https://github.com/julia-vscode/julia-vscode
|
||||||
|
---
|
||||||
|
--- LanguageServer.jl, SymbolServer.jl and StaticLint.jl can be installed with `julia` and `Pkg`:
|
||||||
|
--- ```sh
|
||||||
|
--- julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.add("LanguageServer"); Pkg.add("SymbolServer"); Pkg.add("StaticLint")'
|
||||||
|
--- ```
|
||||||
|
--- where `~/.julia/environments/nvim-lspconfig` is the location where
|
||||||
|
--- the default configuration expects LanguageServer.jl, SymbolServer.jl and StaticLint.jl to be installed.
|
||||||
|
---
|
||||||
|
--- To update an existing install, use the following command:
|
||||||
|
--- ```sh
|
||||||
|
--- julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.update()'
|
||||||
|
--- ```
|
||||||
|
---
|
||||||
|
--- Note: In order to have LanguageServer.jl pick up installed packages or dependencies in a
|
||||||
|
--- Julia project, you must make sure that the project is instantiated:
|
||||||
|
--- ```sh
|
||||||
|
--- julia --project=/path/to/my/project -e 'using Pkg; Pkg.instantiate()'
|
||||||
|
--- ```
|
||||||
|
---
|
||||||
|
--- Note: The julia programming language searches for global environments within the `environments/`
|
||||||
|
--- folder of `$JULIA_DEPOT_PATH` entries. By default this simply `~/.julia/environments`
|
||||||
|
|
||||||
|
local root_files = { 'Project.toml', 'JuliaProject.toml' }
|
||||||
|
|
||||||
|
local function activate_env(path)
|
||||||
|
assert(vim.fn.has 'nvim-0.10' == 1, 'requires Nvim 0.10 or newer')
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
local julials_clients = vim.lsp.get_clients { bufnr = bufnr, name = 'julials' }
|
||||||
|
assert(
|
||||||
|
#julials_clients > 0,
|
||||||
|
'method julia/activateenvironment is not supported by any servers active on the current buffer'
|
||||||
|
)
|
||||||
|
local function _activate_env(environment)
|
||||||
|
if environment then
|
||||||
|
for _, julials_client in ipairs(julials_clients) do
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
|
julials_client:notify('julia/activateenvironment', { envPath = environment })
|
||||||
|
end
|
||||||
|
vim.notify('Julia environment activated: \n`' .. environment .. '`', vim.log.levels.INFO)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if path then
|
||||||
|
path = vim.fs.normalize(vim.fn.fnamemodify(vim.fn.expand(path), ':p'))
|
||||||
|
local found_env = false
|
||||||
|
for _, project_file in ipairs(root_files) do
|
||||||
|
local file = vim.uv.fs_stat(vim.fs.joinpath(path, project_file))
|
||||||
|
if file and file.type then
|
||||||
|
found_env = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not found_env then
|
||||||
|
vim.notify('Path is not a julia environment: \n`' .. path .. '`', vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_activate_env(path)
|
||||||
|
else
|
||||||
|
local depot_paths = vim.env.JULIA_DEPOT_PATH
|
||||||
|
and vim.split(vim.env.JULIA_DEPOT_PATH, vim.fn.has 'win32' == 1 and ';' or ':')
|
||||||
|
or { vim.fn.expand '~/.julia' }
|
||||||
|
local environments = {}
|
||||||
|
vim.list_extend(environments, vim.fs.find(root_files, { type = 'file', upward = true, limit = math.huge }))
|
||||||
|
for _, depot_path in ipairs(depot_paths) do
|
||||||
|
local depot_env = vim.fs.joinpath(vim.fs.normalize(depot_path), 'environments')
|
||||||
|
vim.list_extend(
|
||||||
|
environments,
|
||||||
|
vim.fs.find(function(name, env_path)
|
||||||
|
return vim.tbl_contains(root_files, name) and string.sub(env_path, #depot_env + 1):match '^/[^/]*$'
|
||||||
|
end, { path = depot_env, type = 'file', limit = math.huge })
|
||||||
|
)
|
||||||
|
end
|
||||||
|
environments = vim.tbl_map(vim.fs.dirname, environments)
|
||||||
|
vim.ui.select(environments, { prompt = 'Select a Julia environment' }, _activate_env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmd = {
|
||||||
|
'julia',
|
||||||
|
'--startup-file=no',
|
||||||
|
'--history-file=no',
|
||||||
|
'-e',
|
||||||
|
[[
|
||||||
|
# Load LanguageServer.jl: attempt to load from ~/.julia/environments/nvim-lspconfig
|
||||||
|
# with the regular load path as a fallback
|
||||||
|
ls_install_path = joinpath(
|
||||||
|
get(DEPOT_PATH, 1, joinpath(homedir(), ".julia")),
|
||||||
|
"environments", "nvim-lspconfig"
|
||||||
|
)
|
||||||
|
pushfirst!(LOAD_PATH, ls_install_path)
|
||||||
|
using LanguageServer, SymbolServer, StaticLint
|
||||||
|
popfirst!(LOAD_PATH)
|
||||||
|
depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
|
||||||
|
project_path = let
|
||||||
|
dirname(something(
|
||||||
|
## 1. Finds an explicitly set project (JULIA_PROJECT)
|
||||||
|
Base.load_path_expand((
|
||||||
|
p = get(ENV, "JULIA_PROJECT", nothing);
|
||||||
|
p === nothing ? nothing : isempty(p) ? nothing : p
|
||||||
|
)),
|
||||||
|
## 2. Look for a Project.toml file in the current working directory,
|
||||||
|
## or parent directories, with $HOME as an upper boundary
|
||||||
|
Base.current_project(),
|
||||||
|
## 3. First entry in the load path
|
||||||
|
get(Base.load_path(), 1, nothing),
|
||||||
|
## 4. Fallback to default global environment,
|
||||||
|
## this is more or less unreachable
|
||||||
|
Base.load_path_expand("@v#.#"),
|
||||||
|
))
|
||||||
|
end
|
||||||
|
@info "Running language server" VERSION pwd() project_path depot_path
|
||||||
|
server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path)
|
||||||
|
server.runlinter = true
|
||||||
|
run(server)
|
||||||
|
]],
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type vim.lsp.Config
|
||||||
|
local config = {
|
||||||
|
cmd = cmd,
|
||||||
|
filetypes = { 'julia' },
|
||||||
|
root_markers = root_files,
|
||||||
|
on_attach = function(_, bufnr)
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, 'LspJuliaActivateEnv', activate_env, {
|
||||||
|
desc = 'Activate a Julia environment',
|
||||||
|
nargs = '?',
|
||||||
|
complete = 'file',
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.config['julials'] = config
|
||||||
|
vim.lsp.enable('julials')
|
||||||
|
|
||||||
@@ -12,5 +12,6 @@ return {
|
|||||||
window_overlap_clear_enabled = true,
|
window_overlap_clear_enabled = true,
|
||||||
window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', '', },
|
window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', '', },
|
||||||
},
|
},
|
||||||
|
lazy = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
return {
|
return {
|
||||||
'nvim-mini/mini.icons',
|
'nvim-mini/mini.icons',
|
||||||
|
lazy = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,5 +7,6 @@ return {
|
|||||||
vim.g.molten_image_provider = 'image.nvim'
|
vim.g.molten_image_provider = 'image.nvim'
|
||||||
vim.g.molten_output_win_max_height = 20
|
vim.g.molten_output_win_max_height = 20
|
||||||
end,
|
end,
|
||||||
|
enabled = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
return {
|
return {
|
||||||
'stevearc/oil.nvim',
|
'stevearc/oil.nvim',
|
||||||
|
--dependencies = { "nvim-mini/mini.icons" },
|
||||||
|
|
||||||
---@module 'oil'
|
---@module 'oil'
|
||||||
---@type oil.SetupOpts
|
---@type oil.SetupOpts
|
||||||
opts = {
|
opts = {
|
||||||
|
|||||||
Reference in New Issue
Block a user