Setup nvim for elm-development
This commit is contained in:
@@ -76,6 +76,8 @@ for_window [instance="^file_progress"] floating enable
|
|||||||
for_window [instance="^arandr"] floating enable resize set width 900
|
for_window [instance="^arandr"] floating enable resize set width 900
|
||||||
for_window [class="jetbrains-idea" title="splash"] floating enable
|
for_window [class="jetbrains-idea" title="splash"] floating enable
|
||||||
for_window [class="^Microsoft Teams - Preview$"] floating enable
|
for_window [class="^Microsoft Teams - Preview$"] floating enable
|
||||||
|
for_window [title="^Elm Debugger"] floating enable
|
||||||
|
for_window [class="^com-intellij-updater-Runner"] floating enable
|
||||||
|
|
||||||
# If I have opened the nm-openconnect-auth-dialog I set focus by myself,
|
# If I have opened the nm-openconnect-auth-dialog I set focus by myself,
|
||||||
# otherwise it appeared automatically and I don't want the focus!
|
# otherwise it appeared automatically and I don't want the focus!
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ vim.api.nvim_create_autocmd("FileType", {
|
|||||||
callback = function()
|
callback = function()
|
||||||
vim.opt_local.shiftwidth = 4
|
vim.opt_local.shiftwidth = 4
|
||||||
vim.opt_local.tabstop = 4
|
vim.opt_local.tabstop = 4
|
||||||
|
vim.opt_local.colorcolumn = "80"
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
-- git
|
-- git
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ return {
|
|||||||
"terraformls",
|
"terraformls",
|
||||||
"ts_ls",
|
"ts_ls",
|
||||||
"vue_ls",
|
"vue_ls",
|
||||||
|
"elmls",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
local vue_language_server_path = vim.fn.expand '$MASON/packages' ..
|
local vue_language_server_path = vim.fn.expand '$MASON/packages' ..
|
||||||
@@ -122,7 +123,20 @@ return {
|
|||||||
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
|
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
|
||||||
})
|
})
|
||||||
vim.lsp.config('vue_ls', opts)
|
vim.lsp.config('vue_ls', opts)
|
||||||
|
vim.lsp.config('elmls', {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
on_attach(client, bufnr)
|
||||||
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
callback = function ()
|
||||||
|
vim.lsp.buf.format({ async = false })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
vim.lsp.enable({
|
vim.lsp.enable({
|
||||||
|
"elmls",
|
||||||
"cssls",
|
"cssls",
|
||||||
"eslint",
|
"eslint",
|
||||||
"html",
|
"html",
|
||||||
|
|||||||
267
.config/nvim/snippets/elm.snippets
Normal file
267
.config/nvim/snippets/elm.snippets
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
snippet mod Module definition
|
||||||
|
module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` exposing (${1})
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet imp Import
|
||||||
|
import ${0:Http}
|
||||||
|
|
||||||
|
snippet impe Exposing import
|
||||||
|
import ${1:Html} exposing (${0:..})
|
||||||
|
|
||||||
|
snippet impae Exposing import alias
|
||||||
|
import ${1:Json.Encode} as ${2:Encode} exposing (${0:Value})
|
||||||
|
|
||||||
|
snippet fn Function
|
||||||
|
${1:fn} : ${2:a} -> ${3:a}
|
||||||
|
$1 ${4} =
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet fnn Bi-Function
|
||||||
|
${1:fn} : ${2:a} -> ${3:a} -> ${4:a}
|
||||||
|
$1 ${5} =
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet fnnn Tri-Function
|
||||||
|
${1:fn} : ${2:a} -> ${3:a} -> ${4:a} -> ${5:a}
|
||||||
|
$1 ${6} =
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet var Null-Function
|
||||||
|
${1:fn} : ${2:a}
|
||||||
|
$1 =
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet case Case
|
||||||
|
case ${1} of
|
||||||
|
${2} ->
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet - ->
|
||||||
|
${1} ->
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet let Let
|
||||||
|
let
|
||||||
|
${1} =
|
||||||
|
${2}
|
||||||
|
in
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet if If-Else
|
||||||
|
if ${1} then
|
||||||
|
${2:${VISUAL}}
|
||||||
|
else
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet ty Type
|
||||||
|
type ${1:Msg}
|
||||||
|
= ${0}
|
||||||
|
|
||||||
|
snippet tya Type alias
|
||||||
|
type alias ${1:Model} =
|
||||||
|
${0}
|
||||||
|
|
||||||
|
snippet test Test
|
||||||
|
test "${1}" <| \_ -> $0
|
||||||
|
|
||||||
|
snippet desc Description (Test)
|
||||||
|
describe "${1}" [ $0 ]
|
||||||
|
|
||||||
|
snippet doc Multiline comment
|
||||||
|
{-| ${0}
|
||||||
|
-}
|
||||||
|
|
||||||
|
snippet p Pipe
|
||||||
|
|> ${0}
|
||||||
|
|
||||||
|
snippet application Elm 0.19 application
|
||||||
|
module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` exposing (main)
|
||||||
|
|
||||||
|
import Browser
|
||||||
|
import Browser.Navigation as Nav
|
||||||
|
import Html
|
||||||
|
import Url
|
||||||
|
import Url.Parser as Parser exposing ((</>), s)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- MAIN
|
||||||
|
|
||||||
|
|
||||||
|
main : Program () Model Msg
|
||||||
|
main =
|
||||||
|
Browser.application
|
||||||
|
{ init = init
|
||||||
|
, view = view
|
||||||
|
, update = update
|
||||||
|
, subscriptions = subscriptions
|
||||||
|
, onUrlRequest = onUrlRequest
|
||||||
|
, onUrlChange = onUrlChange
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- MODEL
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
{ key : Nav.Key
|
||||||
|
, page : Page
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type Page
|
||||||
|
= NotFound
|
||||||
|
| Root
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- SUBSCRIPTIONS
|
||||||
|
|
||||||
|
|
||||||
|
subscriptions : Model -> Sub Msg
|
||||||
|
subscriptions _ =
|
||||||
|
Sub.none
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- VIEW
|
||||||
|
|
||||||
|
|
||||||
|
view : Model -> Browser.Document Msg
|
||||||
|
view model =
|
||||||
|
case model.page of
|
||||||
|
_ ->
|
||||||
|
{ title = "Not Found"
|
||||||
|
, body = [ Html.div [] [ Html.text "Not Found" ] ]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- INIT
|
||||||
|
|
||||||
|
|
||||||
|
init : () -> Url.Url -> Nav.Key -> ( Model, Cmd Msg )
|
||||||
|
init _ url key =
|
||||||
|
pageUrl url
|
||||||
|
{ key = key
|
||||||
|
, page = NotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- UPDATE
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= NoOp
|
||||||
|
| UrlRequest Browser.UrlRequest
|
||||||
|
| UrlChanged Url.Url
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
|
update message model =
|
||||||
|
case message of
|
||||||
|
NoOp ->
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
UrlRequest urlRequest ->
|
||||||
|
case urlRequest of
|
||||||
|
Browser.Internal url ->
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
Browser.External url ->
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
UrlChanged url ->
|
||||||
|
pageUrl url model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- ROUTER
|
||||||
|
|
||||||
|
|
||||||
|
onUrlRequest : Browser.UrlRequest -> Msg
|
||||||
|
onUrlRequest =
|
||||||
|
UrlRequest
|
||||||
|
|
||||||
|
|
||||||
|
onUrlChange : Url.Url -> Msg
|
||||||
|
onUrlChange =
|
||||||
|
UrlChanged
|
||||||
|
|
||||||
|
|
||||||
|
pageUrl : Url.Url -> Model -> ( Model, Cmd Msg )
|
||||||
|
pageUrl url model =
|
||||||
|
let
|
||||||
|
routeParser =
|
||||||
|
Parser.oneOf
|
||||||
|
[ Parser.map Root Parser.top
|
||||||
|
]
|
||||||
|
in
|
||||||
|
case Parser.parse routeParser url of
|
||||||
|
Just page ->
|
||||||
|
( { model | page = page }
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
( { model | page = NotFound }
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
snippet element Elm 0.18 element
|
||||||
|
module Main exposing (Model, Msg(..), init, main, subscriptions, update, view)
|
||||||
|
|
||||||
|
import Browser
|
||||||
|
import Html exposing (..)
|
||||||
|
import Json.Encode
|
||||||
|
|
||||||
|
|
||||||
|
main : Program Flags Model Msg
|
||||||
|
main =
|
||||||
|
Browser.element
|
||||||
|
{ init = init
|
||||||
|
, update = update
|
||||||
|
, subscriptions = subscriptions
|
||||||
|
, view = view
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
type alias Flags =
|
||||||
|
Json.Encode.Value
|
||||||
|
|
||||||
|
|
||||||
|
init : Flags -> ( Model, Cmd Msg )
|
||||||
|
init flags_ =
|
||||||
|
( {}
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= Noop
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
|
update msg model =
|
||||||
|
case msg of
|
||||||
|
Noop ->
|
||||||
|
( model
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
subscriptions : Model -> Sub Msg
|
||||||
|
subscriptions model =
|
||||||
|
Sub.none
|
||||||
|
|
||||||
|
|
||||||
|
view : Model -> Html Msg
|
||||||
|
view model =
|
||||||
|
h1 [] [ text "Hello, world!" ]
|
||||||
Reference in New Issue
Block a user