diff options
Diffstat (limited to 'ftplugin')
-rw-r--r-- | ftplugin/c.lua | 16 | ||||
-rw-r--r-- | ftplugin/css.lua | 3 | ||||
-rw-r--r-- | ftplugin/dart.lua | 14 | ||||
-rw-r--r-- | ftplugin/euphoria3.lua | 2 | ||||
-rw-r--r-- | ftplugin/go.lua | 15 | ||||
-rw-r--r-- | ftplugin/java.lua | 44 | ||||
-rw-r--r-- | ftplugin/javascript.lua | 2 | ||||
-rw-r--r-- | ftplugin/json.lua | 14 | ||||
l--------- | ftplugin/less.lua | 1 | ||||
-rw-r--r-- | ftplugin/lua.lua | 28 | ||||
-rw-r--r-- | ftplugin/php.lua | 14 | ||||
-rw-r--r-- | ftplugin/python.lua | 20 | ||||
-rw-r--r-- | ftplugin/ruby.lua | 14 | ||||
-rw-r--r-- | ftplugin/rust.lua | 18 | ||||
l--------- | ftplugin/sass.lua | 1 | ||||
l--------- | ftplugin/scss.lua | 1 | ||||
-rw-r--r-- | ftplugin/sh.lua | 15 | ||||
-rw-r--r-- | ftplugin/tex.lua | 30 | ||||
-rw-r--r-- | ftplugin/tf.lua | 16 | ||||
-rw-r--r-- | ftplugin/yaml.lua | 14 | ||||
-rw-r--r-- | ftplugin/zsh.lua | 1 |
21 files changed, 259 insertions, 24 deletions
diff --git a/ftplugin/c.lua b/ftplugin/c.lua index f9064213..8beaae5d 100644 --- a/ftplugin/c.lua +++ b/ftplugin/c.lua @@ -1,3 +1,19 @@ +O.formatters.filetype["c"] = { + function() + return { + exe = O.lang.c.formatter.exe, + args = O.lang.c.formatter.args, + stdin = not (O.lang.c.formatter.stdin ~= nil), + } + end, +} +O.formatters.filetype["cpp"] = O.formatters.filetype["c"] + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} + if require("lv-utils").check_lsp_client_active "clangd" then return end diff --git a/ftplugin/css.lua b/ftplugin/css.lua index ff8c1004..9cd7cc71 100644 --- a/ftplugin/css.lua +++ b/ftplugin/css.lua @@ -1,4 +1,6 @@ if not require("lv-utils").check_lsp_client_active "cssls" then + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true -- npm install -g vscode-css-languageserver-bin require("lspconfig").cssls.setup { cmd = { @@ -7,6 +9,7 @@ if not require("lv-utils").check_lsp_client_active "cssls" then "--stdio", }, on_attach = require("lsp").common_on_attach, + capabilities = capabilities, } end diff --git a/ftplugin/dart.lua b/ftplugin/dart.lua index a0de0fd5..f9b68e9d 100644 --- a/ftplugin/dart.lua +++ b/ftplugin/dart.lua @@ -1,3 +1,17 @@ +O.formatters.filetype["dart"] = { + function() + return { + exe = O.lang.dart.formatter.exe, + args = O.lang.dart.formatter.args, + stdin = not (O.lang.dart.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} if require("lv-utils").check_lsp_client_active "dartls" then return end diff --git a/ftplugin/euphoria3.lua b/ftplugin/euphoria3.lua index 7c3a1da3..b59a265a 100644 --- a/ftplugin/euphoria3.lua +++ b/ftplugin/euphoria3.lua @@ -2,7 +2,7 @@ if require("lv-utils").check_lsp_client_active "elixirls" then return end --- TODO Remove this at some point +-- TODO: Remove this at some point require("lspconfig").elixirls.setup { cmd = { DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh" }, } diff --git a/ftplugin/go.lua b/ftplugin/go.lua index fbad5a2b..47de932f 100644 --- a/ftplugin/go.lua +++ b/ftplugin/go.lua @@ -1,3 +1,18 @@ +O.formatters.filetype["go"] = { + function() + return { + exe = O.lang.go.formatter.exe, + args = O.lang.go.formatter.args, + stdin = not (O.lang.go.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} + if not require("lv-utils").check_lsp_client_active "gopls" then require("lspconfig").gopls.setup { cmd = { DATA_PATH .. "/lspinstall/go/gopls" }, diff --git a/ftplugin/java.lua b/ftplugin/java.lua index bba968b9..7db90f0e 100644 --- a/ftplugin/java.lua +++ b/ftplugin/java.lua @@ -1,3 +1,28 @@ +vim.cmd "let proj = FindRootDirectory()" +local root_dir = vim.api.nvim_get_var "proj" + +-- use the global prettier if you didn't find the local one +local prettier_instance = root_dir .. "/node_modules/.bin/prettier" +if vim.fn.executable(prettier_instance) ~= 1 then + prettier_instance = O.lang.tsserver.formatter.exe +end + +O.formatters.filetype["java"] = { + function() + return { + exe = prettier_instance, + -- TODO: allow user to override this + args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0) }, + stdin = true, + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} + if require("lv-utils").check_lsp_client_active "jdtls" then return end @@ -18,11 +43,24 @@ if O.lang.java.java_tools.active then cmd = { JAVA_LS_EXECUTABLE, WORKSPACE_PATH .. vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") }, } + vim.api.nvim_set_keymap( + "n", + "<leader>la", + ":lua require('jdtls').code_action()<CR>", + { noremap = true, silent = true } + ) + vim.api.nvim_set_keymap( + "n", + "<leader>lR", + ":lua require('jdtls').code_action(false, 'refactor')<CR>", + { noremap = true, silent = true } + ) + vim.cmd "command! -buffer JdtCompile lua require('jdtls').compile()" vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()" - vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" + -- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()" - vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" + -- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" else local util = require "lspconfig/util" @@ -48,7 +86,7 @@ end -- init_options = {bundles = bundles} -- }) --- TODO setup autoformat stuff later +-- TODO: setup autoformat stuff later -- _java = { -- -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'}, -- { diff --git a/ftplugin/javascript.lua b/ftplugin/javascript.lua index f74b54e9..fc59ab68 100644 --- a/ftplugin/javascript.lua +++ b/ftplugin/javascript.lua @@ -1,3 +1 @@ require "lsp.tsserver-ls" - -vim.cmd "setl ts=2 sw=2" diff --git a/ftplugin/json.lua b/ftplugin/json.lua index c7246e76..cb73995c 100644 --- a/ftplugin/json.lua +++ b/ftplugin/json.lua @@ -1,3 +1,17 @@ +O.formatters.filetype["json"] = { + function() + return { + exe = O.lang.json.formatter.exe, + args = O.lang.json.formatter.args, + stdin = not (O.lang.json.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} if require("lv-utils").check_lsp_client_active "jsonls" then return end diff --git a/ftplugin/less.lua b/ftplugin/less.lua new file mode 120000 index 00000000..6b9e5a8d --- /dev/null +++ b/ftplugin/less.lua @@ -0,0 +1 @@ +css.lua
\ No newline at end of file diff --git a/ftplugin/lua.lua b/ftplugin/lua.lua index 2ffaa472..eb7b9944 100644 --- a/ftplugin/lua.lua +++ b/ftplugin/lua.lua @@ -1,3 +1,17 @@ +O.formatters.filetype["lua"] = { + function() + return { + exe = O.lang.lua.formatter.exe, + args = O.lang.lua.formatter.args, + stdin = not (O.lang.lua.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} if not require("lv-utils").check_lsp_client_active "sumneko_lua" then -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) local sumneko_root_path = DATA_PATH .. "/lspinstall/lua" @@ -31,17 +45,3 @@ if not require("lv-utils").check_lsp_client_active "sumneko_lua" then }, } end - -if O.lang.lua.autoformat then - require("lv-utils").define_augroups { - _lua_autoformat = { - { - "BufWritePre", - "*.lua", - "lua vim.lsp.buf.formatting_sync(nil, 1000)", - }, - }, - } -end - -vim.cmd "setl ts=2 sw=2" diff --git a/ftplugin/php.lua b/ftplugin/php.lua index 713ef44e..054dff79 100644 --- a/ftplugin/php.lua +++ b/ftplugin/php.lua @@ -1,3 +1,17 @@ +O.formatters.filetype["php"] = { + function() + return { + exe = O.lang.php.formatter.exe, + args = O.lang.php.formatter.args, + stdin = not (O.lang.php.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} if require("lv-utils").check_lsp_client_active "intelephense" then return end diff --git a/ftplugin/python.lua b/ftplugin/python.lua index 0cf7c1a7..d2ade7e2 100644 --- a/ftplugin/python.lua +++ b/ftplugin/python.lua @@ -1,6 +1,21 @@ +O.formatters.filetype["python"] = { + function() + return { + exe = O.lang.python.formatter.exe, + args = O.lang.python.formatter.args, + stdin = not (O.lang.python.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} + local python_arguments = {} --- TODO replace with path argument +-- TODO: replace with path argument local flake8 = { LintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -", lintStdin = true, @@ -25,6 +40,7 @@ if not require("lv-utils").check_lsp_client_active "efm" then -- init_options = {initializationOptions}, cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, init_options = { documentFormatting = true, codeAction = false }, + root_dir = require("lspconfig").util.root_pattern(".git/", "requirements.txt"), filetypes = { "python" }, settings = { rootMarkers = { ".git/", "requirements.txt" }, @@ -63,7 +79,7 @@ if not require("lv-utils").check_lsp_client_active "pyright" then } end -if O.plugin.debug.active and O.plugin.dap_install.active then +if O.plugin.dap.active then local dap_install = require "dap-install" dap_install.config("python_dbg", {}) end diff --git a/ftplugin/ruby.lua b/ftplugin/ruby.lua index 7f86ffb9..ff7e7c8b 100644 --- a/ftplugin/ruby.lua +++ b/ftplugin/ruby.lua @@ -1,3 +1,17 @@ +O.formatters.filetype["ruby"] = { + function() + return { + exe = O.lang.ruby.formatter.exe, + args = O.lang.ruby.formatter.args, + stdin = not (O.lang.ruby.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} if require("lv-utils").check_lsp_client_active "solargraph" then return end diff --git a/ftplugin/rust.lua b/ftplugin/rust.lua index 4fb47582..dd34483e 100644 --- a/ftplugin/rust.lua +++ b/ftplugin/rust.lua @@ -1,3 +1,17 @@ +O.formatters.filetype["rust"] = { + function() + return { + exe = O.lang.rust.formatter.exe, + args = O.lang.rust.formatter.args, + stdin = not (O.lang.rust.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} if require("lv-utils").check_lsp_client_active "rust_analyzer" then return end @@ -81,11 +95,11 @@ else cmd = { DATA_PATH .. "/lspinstall/rust/rust-analyzer" }, on_attach = require("lsp").common_on_attach, filetypes = { "rust" }, - root_dir = require("lspconfig.util").root_pattern("Cargo.toml", "rust-project.json"), + root_dir = require("lspconfig.util").root_pattern("Carrust.toml", "rust-project.json"), } end --- TODO fix these mappings +-- TODO: fix these mappings vim.api.nvim_exec( [[ autocmd Filetype rust nnoremap <leader>lm <Cmd>RustExpandMacro<CR> diff --git a/ftplugin/sass.lua b/ftplugin/sass.lua new file mode 120000 index 00000000..6b9e5a8d --- /dev/null +++ b/ftplugin/sass.lua @@ -0,0 +1 @@ +css.lua
\ No newline at end of file diff --git a/ftplugin/scss.lua b/ftplugin/scss.lua new file mode 120000 index 00000000..6b9e5a8d --- /dev/null +++ b/ftplugin/scss.lua @@ -0,0 +1 @@ +css.lua
\ No newline at end of file diff --git a/ftplugin/sh.lua b/ftplugin/sh.lua index c299f2de..54002f19 100644 --- a/ftplugin/sh.lua +++ b/ftplugin/sh.lua @@ -1,3 +1,17 @@ +O.formatters.filetype["sh"] = { + function() + return { + exe = O.lang.sh.formatter.exe, + args = O.lang.sh.formatter.args, + stdin = not (O.lang.sh.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} if not require("lv-utils").check_lsp_client_active "bashls" then -- npm i -g bash-language-server require("lspconfig").bashls.setup { @@ -26,6 +40,7 @@ if not require("lv-utils").check_lsp_client_active "efm" then -- init_options = {initializationOptions}, cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, init_options = { documentFormatting = true, codeAction = false }, + root_dir = require("lspconfig").util.root_pattern ".git/", filetypes = { "sh" }, settings = { rootMarkers = { ".git/" }, diff --git a/ftplugin/tex.lua b/ftplugin/tex.lua index 7ad35000..c5748189 100644 --- a/ftplugin/tex.lua +++ b/ftplugin/tex.lua @@ -6,3 +6,33 @@ require("lspconfig").texlab.setup { cmd = { DATA_PATH .. "/lspinstall/latex/texlab" }, on_attach = require("lsp").common_on_attach, } + +vim.g.vimtex_compiler_method = "latexmk" +vim.g.vimtex_view_method = "zathura" +vim.g.vimtex_fold_enabled = 0 +vim.g.vimtex_quickfix_ignore_filters = O.lang.latex.ignore_errors + +O.plugin.which_key.mappings["L"] = { + name = "+Latex", + c = { "<cmd>VimtexCompile<cr>", "Toggle Compilation Mode" }, + f = { "<cmd>call vimtex#fzf#run()<cr>", "Fzf Find" }, + i = { "<cmd>VimtexInfo<cr>", "Project Information" }, + s = { "<cmd>VimtexStop<cr>", "Stop Project Compilation" }, + t = { "<cmd>VimtexTocToggle<cr>", "Toggle Table Of Content" }, + v = { "<cmd>VimtexView<cr>", "View PDF" }, +} + +-- Compile on initialization, cleanup on quit +vim.api.nvim_exec( + [[ + augroup vimtex_event_1 + au! + au User VimtexEventQuit call vimtex#compiler#clean(0) + au User VimtexEventInitPost call vimtex#compiler#compile() + augroup END + ]], + false +) +if O.lang.latex.auto_save then + vim.api.nvim_exec([[au FocusLost * :wa]], false) +end diff --git a/ftplugin/tf.lua b/ftplugin/tf.lua index 7291cbd8..a328f7c2 100644 --- a/ftplugin/tf.lua +++ b/ftplugin/tf.lua @@ -1,3 +1,19 @@ +O.formatters.filetype["hcl"] = { + function() + return { + exe = O.lang.terraform.formatter.exe, + args = O.lang.terraform.formatter.args, + stdin = not (O.lang.terraform.formatter.stdin ~= nil), + } + end, +} +O.formatters.filetype["tf"] = O.formatters.filetype["hcl"] + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} + if require("lv-utils").check_lsp_client_active "terraformls" then return end diff --git a/ftplugin/yaml.lua b/ftplugin/yaml.lua index 219022f5..f1dfc5dc 100644 --- a/ftplugin/yaml.lua +++ b/ftplugin/yaml.lua @@ -1,3 +1,17 @@ +O.formatters.filetype["yaml"] = { + function() + return { + exe = O.lang.yaml.formatter.exe, + args = O.lang.yaml.formatter.args, + stdin = not (O.lang.yaml.formatter.stdin ~= nil), + } + end, +} + +require("formatter.config").set_defaults { + logging = false, + filetype = O.formatters.filetype, +} if require("lv-utils").check_lsp_client_active "yamlls" then return end diff --git a/ftplugin/zsh.lua b/ftplugin/zsh.lua index 49cd103d..750e8ede 100644 --- a/ftplugin/zsh.lua +++ b/ftplugin/zsh.lua @@ -24,6 +24,7 @@ if not require("lv-utils").check_lsp_client_active "efm" then -- init_options = {initializationOptions}, cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, init_options = { documentFormatting = true, codeAction = false }, + root_dir = require("lspconfig").util.root_pattern ".git/", filetypes = { "zsh" }, settings = { rootMarkers = { ".git/" }, |