Compare commits

...

3 Commits

Author SHA1 Message Date
Rob Watson 56c6370a73 feat(nvim): rustfmt config
continuous-integration/drone/push Build is passing Details
2023-11-06 07:36:32 +01:00
Rob Watson 5443f5f067 chore(nvim): re-add Get_project_node_modules_path 2023-11-06 07:36:10 +01:00
Rob Watson 97f4f9d636 chore(nvim): disable LSP snippet support 2023-11-06 07:35:44 +01:00
3 changed files with 25 additions and 3 deletions

View File

@ -1,6 +1,6 @@
local prettier = function()
return {
exe = vim.fn.getcwd() .. "/node_modules/.bin/prettier",
exe = Get_project_node_modules_path() .. "/.bin/prettier",
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
stdin = true,
}
@ -22,6 +22,14 @@ local goimports = function()
}
end
local rustfmt = function()
return {
exe = "rustfmt",
args = { "--edition", "2021" },
stdin = true,
}
end
require("formatter").setup({
log_level = vim.log.levels.INFO,
filetype = {
@ -29,6 +37,7 @@ require("formatter").setup({
typescript = { prettier },
typescriptreact = { prettier },
go = { goimports },
rust = { rustfmt },
-- https://github.com/JohnnyMorganz/StyLua
-- cargo install stylua --features lua54
@ -43,7 +52,7 @@ vim.api.nvim_exec2(
[[
augroup FormatAutogroup
autocmd!
autocmd BufWritePost *.js,*.ts,*.tsx,*.go,*.lua silent FormatWrite
autocmd BufWritePost *.js,*.ts,*.tsx,*.go,*.lua,*.rs silent FormatWrite
augroup END
]],
{ output = true }

View File

@ -1,3 +1,16 @@
-- Return the node_modules path for this project. If the project root contains a
-- frontend/ directory, assume node_modules lives there.
function Get_project_node_modules_path()
local root_path = vim.fn.getcwd()
local frontend_path = root_path .. "/frontend"
local is_frontend = vim.fn.isdirectory(frontend_path) ~= 0
local base_path = root_path
if is_frontend then
base_path = frontend_path
end
return base_path .. "/node_modules"
end
-- Return the project's go module path from go.mod, or an empty string if the file cannot be read.
function Get_project_go_module_path()
local root_path = vim.fn.getcwd()

View File

@ -41,7 +41,7 @@ end
-- Go
local capabilities = require("cmp_nvim_lsp").default_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
capabilities.textDocument.completion.completionItem.snippetSupport = false
capabilities.textDocument.completion.completionItem.resolveSupport = {
properties = {
"documentation",